]> Sergey Matveev's repositories - dotfiles.git/blob - vim/.vim/plugin/lsp.vim
1adfbe5a9448533f7fcc4571e71b32ea57ecc26f
[dotfiles.git] / vim / .vim / plugin / lsp.vim
1 vim9script
2
3 # go get golang.org/x/tools/gopls@latest
4 # pip install 'python-language-server[all]'
5
6 var lspServers: list<dict<any>>
7
8 for d in [
9     {
10         filetype: ["c", "cpp"],
11         path: "clangd",
12         args: ["--log=error"],
13     },
14     {
15         filetype: ["go"],
16         path: "gopls",
17         syncInit: true,
18     },
19 ]
20     if executable(d["path"])
21         add(lspServers, d)
22     endif
23 endfor
24
25 var lspOpts = {
26     ignoreMissingServer: true,
27     autoComplete: false,
28     autoHighlight: true,
29     autoPopulateDiags: true,
30     showSignature: false,
31 }
32
33 autocmd VimEnter * call LspAddServer(lspServers)
34 autocmd VimEnter * call LspOptionsSet(lspOpts)
35 autocmd CursorMoved * silent! LspDiagCurrent
36 nmap gd :LspGotoDefinition<CR>
37 nmap <C-W>gd :vert LspGotoDefinition<CR>
38 nmap <F6> :lopen<CR>