aboutsummaryrefslogtreecommitdiff
path: root/.vim/after/plugin/yegappan-lsp.vim
blob: 1f1ef45ecad25d2e05ea2780aa17d43cf89b9934 (plain)
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
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 LspAddServer([#{
	\    name: 'ruby',
	\    filetype: ['ruby'],
	\    omnicompl: v:true,
	\    path: exepath('solargraph'),
	\    args: ['stdio'],
	\    syncInit: v:true
	\  }])

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>

	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