aboutsummaryrefslogtreecommitdiff
path: root/.vim/plugin/lsp.vim
diff options
context:
space:
mode:
authorgxlin <[email protected]>2021-07-20 23:30:18 +0800
committergxlin <[email protected]>2021-07-20 23:30:18 +0800
commita83dea3c8c92a30c83760c0e71bb35322190105b (patch)
tree92e28e0d2edcbb5be734b329e01a4f302cdabb8e /.vim/plugin/lsp.vim
parent79deeb3d8f888fadd8fef49086f34ae7ff74e08f (diff)
downloaddotfiles-a83dea3c8c92a30c83760c0e71bb35322190105b.tar.gz
dotfiles-a83dea3c8c92a30c83760c0e71bb35322190105b.tar.bz2
dotfiles-a83dea3c8c92a30c83760c0e71bb35322190105b.zip
Config of vim lsp
Diffstat (limited to '.vim/plugin/lsp.vim')
-rw-r--r--.vim/plugin/lsp.vim38
1 files changed, 38 insertions, 0 deletions
diff --git a/.vim/plugin/lsp.vim b/.vim/plugin/lsp.vim
new file mode 100644
index 0000000..2816300
--- /dev/null
+++ b/.vim/plugin/lsp.vim
@@ -0,0 +1,38 @@
+if executable('gopls')
+ au User lsp_setup call lsp#register_server({
+ \ 'name': 'gopls',
+ \ 'cmd': {server_info->['gopls']},
+ \ 'allowlist': ['go'],
+ \ })
+endif
+
+function! s:on_lsp_buffer_enabled() abort
+ setlocal omnifunc=lsp#complete
+ setlocal signcolumn=no
+ 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)
+ inoremap <buffer> <expr><c-f> lsp#scroll(+4)
+ inoremap <buffer> <expr><c-d> lsp#scroll(-4)
+
+ let g:lsp_format_sync_timeout = 1000
+ autocmd! BufWritePre *.rs,*.go call execute('LspDocumentFormatSync')
+
+ " refer to doc to add more commands
+endfunction
+
+augroup lsp_install
+ au!
+ " call s:on_lsp_buffer_enabled only for languages that has the server registered.
+ autocmd User lsp_buffer_enabled call s:on_lsp_buffer_enabled()
+augroup END
+
+let g:lsp_settings_filetype_lua = 'sumneko-lua-language-server'