]> Sergey Matveev's repositories - dotfiles.git/blob - vim/.vim/plugin/lsp.vim
gomod is also LSPable
[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", "gomod"],
16         path: "gopls",
17         syncInit: true,
18     },
19     {
20         filetype: ["python"],
21         path: "pyls",
22         syncInit: true,
23         workspaceConfig: {pyls: {
24             configurationSources: ["flake8"],
25             plugins: {
26                 mccabe: {enabled: false},
27             },
28         }},
29     },
30 ]
31     if executable(d["path"])
32         add(lspServers, d)
33     endif
34 endfor
35
36 var lspOpts = {
37     ignoreMissingServer: true,
38     autoComplete: false,
39     autoHighlight: true,
40     autoPopulateDiags: true,
41     showSignature: false,
42 }
43
44 autocmd VimEnter * call LspAddServer(lspServers)
45 autocmd VimEnter * call LspOptionsSet(lspOpts)
46 autocmd CursorMoved * silent! LspDiagCurrent
47 nmap gd :LspGotoDefinition<CR>
48 nmap <C-W>gd :vert LspGotoDefinition<CR>
49 nmap <F6> :lopen<CR>