" General vim defaults " set background= " set t_te= t_ti= set ls=1 ruler set ai ts=4 sw=4 noet " Not a good idea to activate mouse, as it disables cut & paste in MacOS "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 set autochdir " ignore case when searching, except mixing upper and lower set ignorecase set smartcase " No bell set belloff=all set guifont=6x13:h13 set rtp+=/opt/homebrew/opt/fzf let g:fzf_preview = 'cat {}' " set grepprg=rg\ --vimgrep\ --smart-case\ --hidden\ --follow " nnoremap \ :Rg " nnoremap :Files nnoremap b :Buffers nnoremap s :Blines " vimki plugin autocmd filetype vimki syntax on autocmd filetype vimki set autowrite " autocmd filetype vimki setlocal spell spelllang=fr autocmd filetype vimki nmap z :FZF ~/Wiki autocmd filetype markdown,text,vimki setlocal textwidth=72 " vim-go plugin let g:go_gopls_enabled = 1 let g:go_def_mode = "gopls" let g:go_info_mode = "gopls" 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" let g:go_list_type = "quickfix" "autocmd FileType go syntax on autocmd FileType go nmap b (go-build) autocmd FileType go nmap i (go-info) autocmd FileType go nmap l (go-meta-lint) autocmd FileType go nmap r (go-run) autocmd FileType go nmap t (go-test) autocmd FileType go nmap f (go-test-func) autocmd FileType go nmap v (go-referrers) autocmd FileType go nmap n :cnext autocmd FileType go nmap p :cprevious autocmd FileType go nmap a :cclose " autocmd BufNewFile,BufRead *.go setlocal noexpandtab tabstop=4 shiftwidth=4 let g:netrw_browsex_viewer = "open" let g:netrw_gx = "" 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 :!cscope -1 " noremap :!cscope -0 " noremap :!cscope -7 " Paragraph format / unformat " An alternate way is to use "gqip" to format. " noremap f !}fmt -72 -s -p " noremap F !}fmt -c -w 2048 noremap f gqip " noremap K :s,^,//, " noremap :s,^//,, " noremap # :s,^,#, " noremap @ :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 n :bn noremap :bd noremap o :!open & noremap :tag noremap :Files """"""""""""" 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 noremap s :cs find s =expand("") noremap g :cs find g =expand("") noremap c :cs find c =expand("") noremap t :cs find t =expand("") noremap e :cs find e =expand("") noremap i :cs find i =expand("") " noremap f :cs find f =expand("") noremap d :cs find d =expand("") function! CloseOnLast() let cnt = 0 for i in range(0, bufnr("$")) if buflisted(i) let cnt += 1 endif endfor if cnt <= 1 q else bd endif endfunction noremap :call CloseOnLast() " NERDTree settings let g:NERDTreeNodeDelimiter = "\u00a0" " autocmd BufWinEnter * if getcmdwintype() == '' | silent NERDTreeMirror | endif nnoremap n :NERDTreeFocus " nnoremap :NERDTreeFind nnoremap :NERDTreeMirror:NERDTreeFocus