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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
|
packadd yegappan-lsp
if executable('gopls')
call LspAddServer([#{
\ name: 'golang',
\ filetype: ['go', 'gomod'],
\ omnicompl: v:true,
\ path: exepath('gopls'),
\ args: ['serve'],
\ syncInit: v:true
\ }])
endif
if executable('solargraph')
call LspAddServer([#{
\ name: 'ruby',
\ filetype: ['ruby'],
\ omnicompl: v:true,
\ path: exepath('solargraph'),
\ args: ['stdio'],
\ syncInit: v:true
\ }])
endif
if executable('rust-analyzer')
call LspAddServer([#{
\ name: 'rust',
\ filetype: ['rust'],
\ omnicompl: v:true,
\ path: exepath('rust-analyzer'),
\ args: [],
\ syncInit: v:true
\ }])
endif
call LspOptionsSet(#{
\ aleSupport: v:true,
\ autoComplete: v:false,
\ omniComplete: v:true,
\ completionMatcher: "fuzzy",
\ })
function! s:on_lsp_attached() abort
setlocal keywordprg=:LspHover
" setlocal formatexpr=lsp#lsp#FormatExpr()
nnoremap <buffer> gd <Cmd>LspGotoDefinition<CR>
nnoremap <buffer> <C-W>gd <Cmd>topleft LspGotoDefinition<CR>
nnoremap <buffer> <localleader>rn :LspRename<CR>
nnoremap <buffer> gr :LspShowReferences<CR>
nnoremap <buffer> gI <Cmd>LspGotoImpl<CR>
autocmd! BufWritePre *.rs,*.go call execute('LspFormat')
autocmd! BufRead *.go,*.rs setlocal tagfunc=lsp#lsp#TagFunc
endfunction
augroup lsp_attached
au!
autocmd User LspAttached call s:on_lsp_attached()
augroup END
|