diff options
Diffstat (limited to '.vimrc')
| -rw-r--r-- | .vimrc | 105 |
1 files changed, 50 insertions, 55 deletions
@@ -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 <leader>z :FZF ~/Wiki<CR> " 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 <leader>b <Plug>(go-build) -autocmd FileType go nmap <leader>i <Plug>(go-info) -autocmd FileType go nmap <leader>l <Plug>(go-meta-lint) -autocmd FileType go nmap <leader>r <Plug>(go-run) -autocmd FileType go nmap <leader>t <Plug>(go-test) -" the following collides with reformat -"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 + autocmd BufNewFile,BufRead *.go setlocal noexpandtab tabstop=4 shiftwidth=4 let g:netrw_browsex_viewer = "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 +" autocmd filetype python,yaml set ts=2 sts=2 sw=2 et :set wrap :set linebreak @@ -112,28 +89,6 @@ noremap <leader>o :!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 - -noremap <leader>s :cs find s <C-R>=expand("<cword>")<CR><CR><tab> -noremap <leader>g :cs find g <C-R>=expand("<cword>")<CR><CR><tab> -noremap <leader>c :cs find c <C-R>=expand("<cword>")<CR><CR><tab> -noremap <leader>t :cs find t <C-R>=expand("<cword>")<CR><CR><tab> -noremap <leader>e :cs find e <C-R>=expand("<cword>")<CR><CR><tab> -noremap <leader>i :cs find i <C-R>=expand("<cfile>")<CR><CR><tab> -" noremap <leader>f :cs find f <C-R>=expand("<cfile>")<CR><CR><tab> -noremap <leader>d :cs find d <C-R>=expand("<cword>")<CR><CR><tab> - " MacOS: Open QuickLook on current file (for markdown preview mainly) noremap <leader>w :!ql %<CR><CR> @@ -153,9 +108,49 @@ endfunction noremap <leader><leader> :call CloseOnLast()<cr> -" NERDTree settings -let g:NERDTreeNodeDelimiter = "\u00a0" -" autocmd BufWinEnter * if getcmdwintype() == '' | silent NERDTreeMirror | endif -nnoremap <leader>n :NERDTreeFocus<CR> -" nnoremap <C-r> :NERDTreeFind<CR> -nnoremap <C-n> :NERDTreeMirror<CR>:NERDTreeFocus<CR> +" 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 <buffer> gd <plug>(lsp-definition) + nmap <buffer> gs <plug>(lsp-document-symbol-search) + nmap <buffer> gS <plug>(lsp-workspace-symbol-search) + nmap <buffer> gr <plug>(lsp-references) + nmap <buffer> gi <plug>(lsp-implementation) + nmap <buffer> gt <plug>(lsp-type-definition) + nmap <buffer> <leader>rn <plug>(lsp-rename) + nmap <buffer> [g <plug>(lsp-previous-diagnostic) + nmap <buffer> ]g <plug>(lsp-next-diagnostic) + nmap <buffer> K <plug>(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('%')<CR>:let @b=line('.')<CR>:new<CR>:set bt=nofile<CR>:%!git blame -wM --date=short <C-R>a<CR>:<C-R>b<CR> |
