From 307df21222316d35f32e1597824283797aa6a74c Mon Sep 17 00:00:00 2001 From: Marc Vertes Date: Wed, 15 Jan 2025 11:44:13 +0100 Subject: update --- .vimrc | 105 +++++++++++++++++++++++++++++++---------------------------------- 1 file changed, 50 insertions(+), 55 deletions(-) (limited to '.vimrc') diff --git a/.vimrc b/.vimrc index 7ce1619..08f71e4 100644 --- a/.vimrc +++ b/.vimrc @@ -18,7 +18,7 @@ set undodir=~/.vim/backup// set undofile set backup -set autochdir +" set autochdir " ignore case when searching, except mixing upper and lower set ignorecase @@ -29,6 +29,7 @@ set belloff=all set guifont=6x13:h13 +" fzf plugin set rtp+=/opt/homebrew/opt/fzf let g:fzf_preview = 'cat {}' @@ -46,38 +47,14 @@ autocmd filetype vimki set autowrite 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) -" the following collides with reformat -"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 + 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 +" autocmd filetype python,yaml set ts=2 sts=2 sw=2 et :set wrap :set linebreak @@ -112,28 +89,6 @@ 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("") - " MacOS: Open QuickLook on current file (for markdown preview mainly) noremap w :!ql % @@ -153,9 +108,49 @@ 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 +" 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('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 gt (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 -- cgit v1.2.3