blob: ea2f62d0a63c3d02640ddc879ff564e8e60a0ace (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
func! s:setup_ls(...) abort
let l:servers = lsp#get_allowed_servers()
" key mappings
for l:server in l:servers
let l:cap = lsp#get_server_capabilities(l:server)
if has_key(l:cap, 'completionProvider')
setlocal completefunc=lsp#complete
endif
if has_key(l:cap, 'hoverProvider')
setlocal keywordprg=:LspHover
endif
if has_key(l:cap, 'codeActionProvider')
nmap <silent><buffer>ga <plug>(lsp-code-action)
endif
if has_key(l:cap, 'definitionProvider')
nmap <silent><buffer>gd <plug>(lsp-definition)
nmap <silent><buffer>gk <plug>(lsp-peek-definition)
endif
endfor
endfunc
" register language server
augroup LSC
autocmd!
autocmd User lsp_setup call lsp#register_server({
\ 'name': 'gopls',
\ 'cmd': {_->['gopls']},
\ 'allowlist': ['go']
\})
autocmd User lsp_server_init call <SID>setup_ls()
autocmd BufEnter * call <SID>setup_ls()
augroup END
" disable diagnostics etc.
let g:lsp_diagnostics_enabled = 0
let g:lsp_diagnostics_signs_enabled = 0
let g:lsp_diagnostics_virtual_text_enabled = 0
let g:lsp_diagnostics_highlights_enabled = 0
let g:lsp_document_code_action_signs_enabled = 0
|