" 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 " For MacVim set guifont=6x13:h13 " fzf plugin 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 autocmd BufNewFile,BufRead *.go setlocal noexpandtab tabstop=4 shiftwidth=4 let g:netrw_browsex_viewer = "xdg-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 " MacOS: Open QuickLook on current file (for markdown preview mainly) noremap w :!ql % 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() " vim-lsp settings let g:lsp_diagnostics_enabled = 0 let g:lsp_document_code_action_signs_enabled = 0 let g:lsp_document_highlight_enabled = 0 if executable('gopls') au User lsp_setup call lsp#register_server({ \ 'name': 'gopls', \ 'cmd': {server_info->['gopls', '-remote=auto']}, \ 'allowlist': ['go', 'gomod', 'gohtmltmpl', 'gotexttmpl'], \ }) autocmd BufWritePre *.go \ call execute('LspDocumentFormatSync') | \ call execute('LspCodeActionSync source.organizeImports') endif if executable('gnopls') au User lsp_setup call lsp#register_server({ \ 'name': 'gnopls', \ 'cmd': {server_info->['gnopls', '-remote=auto']}, \ 'allowlist': ['gno', 'gnomod'], \ }) autocmd BufWritePre *.gno \ call execute('LspDocumentFormatSync') | \ call execute('LspCodeActionSync source.organizeImports') endif if executable('clangd') au User lsp_setup call lsp#register_server({ \ 'name': 'clangd', \ 'cmd': {server_info->['clangd', '-background-index']}, \ 'whitelist': ['c', 'cpp', 'objc', 'objcpp'], \ }) endif function! s:on_lsp_buffer_enabled() abort setlocal omnifunc=lsp#complete if exists('+tagfunc') | setlocal tagfunc=lsp#tagfunc | endif nmap gd (lsp-definition) nmap gs (lsp-document-symbol-search) nmap gS (lsp-workspace-symbol-search) nmap gr (lsp-references) nmap gi (lsp-implementation) nmap gy (lsp-type-definition) nmap rn (lsp-rename) nmap [g (lsp-previous-diagnostic) nmap ]g (lsp-next-diagnostic) nmap K (lsp-hover) endfunction augroup lsp_install au! autocmd User lsp_buffer_enabled call s:on_lsp_buffer_enabled() augroup END " Git blame command! Blame normal!:let @a=expand('%'):let @b=line('.'):new:set bt=nofile:%!git blame -wM --date=short a:b