From e6b66752b788aeac9e35d4917b2140a946398e65 Mon Sep 17 00:00:00 2001 From: Guangxiong Lin Date: Mon, 15 Jan 2024 20:26:09 +0800 Subject: Migrate from vim-lsp to yegappan-lsp --- .vim/after/plugin/lsp.vim | 1 + .vim/after/plugin/yegappan-lsp.vim | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+) create mode 100644 .vim/after/plugin/yegappan-lsp.vim (limited to '.vim/after/plugin') diff --git a/.vim/after/plugin/lsp.vim b/.vim/after/plugin/lsp.vim index be41ceb..6b323c8 100644 --- a/.vim/after/plugin/lsp.vim +++ b/.vim/after/plugin/lsp.vim @@ -1,3 +1,4 @@ +finish if has('nvim') finish endif diff --git a/.vim/after/plugin/yegappan-lsp.vim b/.vim/after/plugin/yegappan-lsp.vim new file mode 100644 index 0000000..42bb6cf --- /dev/null +++ b/.vim/after/plugin/yegappan-lsp.vim @@ -0,0 +1,34 @@ +packadd yegappan-lsp + +" Go language server +call LspAddServer([#{ + \ name: 'golang', + \ filetype: ['go', 'gomod'], + \ omnicompl: v:true, + \ path: exepath('gopls'), + \ args: ['serve'], + \ syncInit: v:true + \ }]) + +call LspOptionsSet(#{ + \ aleSupport: v:true, + \ autoComplete: v:false, + \ omniComplete: v:true, + \ completionMatcher: "fuzzy", + \ }) + +function! s:on_lsp_attached() abort + setlocal tagfunc=lsp#lsp#TagFunc + setlocal keywordprg=:LspHover + " setlocal formatexpr=lsp#lsp#FormatExpr() + + nnoremap rn :LspRename + nnoremap gr :LspShowReferences + + autocmd! BufWritePre *.rs,*.go call execute('LspFormat') +endfunction + +augroup lsp_attached + au! + autocmd User LspAttached call s:on_lsp_attached() +augroup END -- cgit v1.2.3