summaryrefslogtreecommitdiff
path: root/.vimrc
blob: c841320af4a425fef3930505e44c75641f5aefae (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
" General vim defaults
" set background=
"set t_te= t_ti=
set ls=1 ruler
set ai ts=4 sw=4 noet
set nohlsearch
set nois
"set mouse=a
syntax off
filetype on
filetype plugin on
filetype plugin indent on
let mapleader = ","

" Save all files at the same place
set backupdir=~/.vim/backup//
set directory=~/.vim/backup//
set undodir=~/.vim/backup//
set undofile
set backup

" Experiment: make the current dir be the same as edited file
set autochdir

"set rtp+=/opt/homebrew/opt/fzf
let g:fzf_preview = 'cat {}'

set grepprg=rg\ --vimgrep\ --smart-case\ --hidden\ --follow

nnoremap \ :Rg<CR>
nnoremap <C-T> :Files<cr>
nnoremap <Leader>b :Buffers<cr>
nnoremap <Leader>s :Blines<cr>

" vimki plugin
autocmd filetype vimki syntax on
autocmd filetype vimki set autowrite
" autocmd filetype vimki setlocal spell spelllang=fr
autocmd filetype vimki nmap <leader>z :FZF ~/Wiki<CR>

" vim-go plugin
"let g:go_def_mode = "gopls"
"let g:go_info_mode = "gopls"
"let g:go_list_type = "quickfix"
"let g:go_fmt_command = "gopls"
"let g:go_gopls_gofumpt = 1

let g:go_gopls_enabled = 0
let g:go_def_mode = "godef"
let g:go_fmt_command = "goimports"
let g:go_metalinter_command = "golangci-lint"
"autocmd FileType go syntax on
autocmd FileType go nmap <leader>b <Plug>(go-build)
autocmd FileType go nmap <leader>i <Plug>(go-info)
autocmd FileType go nmap <leader>r <Plug>(go-run)
autocmd FileType go nmap <leader>t <Plug>(go-test)
autocmd FileType go nmap <leader>f <Plug>(go-test-func)
autocmd FileType go nmap <leader>v <Plug>(go-referrers)
autocmd FileType go nmap <leader>n :cnext<CR>
autocmd FileType go nmap <leader>p :cprevious<CR>
autocmd FileType go nmap <leader>a :cclose<CR>
" autocmd BufNewFile,BufRead *.go setlocal noexpandtab tabstop=4 shiftwidth=4

let g:netrw_browsex_viewer = "xdg-open"
let g:netrw_gx = "<cWORD>"
let g:netrw_banner = 0

" python and yaml formatting:
autocmd filetype python,yaml set ts=2 sts=2 sw=2 et

:set wrap
:set linebreak
:set nolist
:set formatoptions-=t
" noremap <M-v> :!cscope -1 <cword>

" noremap <M-a> :!cscope -0 <cword>

" noremap <M-f> :!cscope -7 <cfile>


" Paragraph format / unformat
noremap <leader>f !}fmt
noremap <leader>F !}fmt -c -w 2048

" noremap <buffer> K :s,^,//,
" noremap <buffer> <C-K> :s,^//,,
noremap <buffer> # :s,^,#,
noremap <buffer> @ :s,^#,,
"hi MatchParen term=reverse ctermbg=magenta ctermfg=none
" hi MatchParen cterm=reverse term=reverse ctermfg=white
"

" Fix spell highlighting
hi clear SpellBad
hi SpellBad cterm=underline
hi SpellBad gui=undercurl

noremap <leader>n :bn<cr>
noremap <leader><leader> :bd<cr>
noremap <leader>o :!xdg-open <cWORD>&<cr><cr>
noremap  <C-g> :tag <c-r><c-w><cr>
noremap <C-p> :Files<cr>

""""""""""""" My cscope/vim key mappings
    "
    " The following maps all invoke one of the following cscope search types:
    "
    "   's'   symbol: find all references to the token under cursor
    "   'g'   global: find global definition(s) of the token under cursor
    "   'c'   calls:  find all calls to the function name under cursor
    "   't'   text:   find all instances of the text under cursor
    "   'e'   egrep:  egrep search for the word under cursor
    "   'f'   file:   open the filename under cursor
    "   'i'   includes: find files that include the filename under cursor
    "   'd'   called: find functions that function under cursor calls

if has("cscope")
	set csto=0
	set cst
	set nocsverb
	if filereadable("cscope.out")
		cs add cscope.out
	elseif $CSCOPE_DB
		cs add $CSCOPE_DB
	endif
	set csverb
endif

nmap <leader>cs :cs find s <C-R>=expand("<cword>")<CR><CR>
nmap <leader>cg :cs find g <C-R>=expand("<cword>")<CR><CR>
nmap <leader>cc :cs find c <C-R>=expand("<cword>")<CR><CR>
nmap <leader>ct :cs find t <C-R>=expand("<cword>")<CR><CR>
nmap <leader>ce :cs find e <C-R>=expand("<cword>")<CR><CR>
nmap <leader>ci :cs find i <C-R>=expand("<cfile>")<CR><CR>
nmap <leader>cf :cs find f <C-R>=expand("<cfile>")<CR><CR>
nmap <leader>cd :cs find d <C-R>=expand("<cword>")<CR><CR>