forked from PegasusWang/vim-config
-
Notifications
You must be signed in to change notification settings - Fork 0
/
lsp.vim
48 lines (39 loc) · 1.5 KB
/
lsp.vim
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
" vim-lsp
" ---
" Apply settings for languages that registered LSP
function! s:on_lsp_buffer_enabled() abort
if empty(globpath(&rtp, 'autoload/lsp.vim'))
finish
endif
setlocal omnifunc=lsp#complete
if exists('+tagfunc')
setlocal tagfunc=lsp#tagfunc
endif
" Folds are really slow
" setlocal foldmethod=expr
" \ foldexpr=lsp#ui#vim#folding#foldexpr()
" \ foldtext=lsp#ui#vim#folding#foldtext()
" Prefer native help with vim files
if &filetype != 'vim'
nmap <silent><buffer> K <Plug>(lsp-hover)
endif
nmap <silent><buffer> gr <Plug>(lsp-references)
nmap <silent><buffer> gi <Plug>(lsp-peek-implementation)
nmap <silent><buffer> gy <Plug>(lsp-peek-type-definition)
nmap <silent><buffer> <C-]> <Plug>(lsp-definition)
nmap <silent><buffer> g<C-]> <Plug>(lsp-peek-definition)
nmap <silent><buffer> gd <Plug>(lsp-peek-declaration)
nmap <silent><buffer> gY <Plug>(lsp-type-hierarchy)
nmap <silent><buffer> ,s <Plug>(lsp-signature-help)
nmap <silent><buffer> [d <Plug>(lsp-previous-diagnostic)
nmap <silent><buffer> ]d <Plug>(lsp-next-diagnostic)
nmap <buffer> <Leader>rn <Plug>(lsp-rename)
nmap <buffer> <Leader>F <plug>(lsp-document-format)
vmap <buffer> <Leader>F <plug>(lsp-document-range-format)
endfunction
augroup lsp_user_plugin
autocmd!
autocmd User lsp_buffer_enabled call <SID>on_lsp_buffer_enabled()
autocmd CompleteDone * if pumvisible() == 0 | pclose | endif
" autocmd BufWinEnter * let g:lsp_preview_max_width = winwidth(0) / 2
augroup END