dotfiles/config/automatrop/roles/vim/templates/plugins/vim_lsp.j2

40 lines
1.5 KiB
Plaintext
Raw Normal View History

2021-07-03 14:13:25 +02:00
{# LSP client for Vim8 and neovim #}
{{ add_source('prabirshrestha/vim-lsp') -}}
{{ add_source('mattn/vim-lsp-settings') -}}
" (providers are automatically detected thanks to vim-lsp-settings.
" You can even install some locally using :LspInstallServer)
let g:lsp_signs_enabled = 1
let g:lsp_diagnostics_echo_cursor = 1
let g:lsp_signs_error = {'text': '✗'}
let g:lsp_signs_warning = {'text': '‼'}
let g:lsp_signs_information = {'text': ''}
let g:lsp_signs_hint = {'text': '?'}
let g:lsp_highlight_references_enabled = 1
2021-07-04 09:54:33 +02:00
function! s:on_lsp_buffer_enabled() abort
setlocal omnifunc=lsp#complete
setlocal signcolumn=yes
if exists('+tagfunc') | setlocal tagfunc=lsp#tagfunc | endif
nmap <buffer> gd <plug>(lsp-definition)
nmap <buffer> gD <plug>(lsp-declaration)
nmap <buffer> gr <plug>(lsp-references)
nmap <buffer> gi <plug>(lsp-implementation)
nmap <buffer> <space>rn <plug>(lsp-rename)
nmap <buffer> [d <plug>(lsp-previous-diagnostic)
nmap <buffer> ]d <plug>(lsp-next-diagnostic)
nmap <buffer> K <plug>(lsp-hover)
nmap <buffer> <space>f <plug>(lsp-document-format)
vmap <buffer> <space>f <plug>(lsp-document-range-format)
inoremap <buffer> <expr><c-f> lsp#scroll(+4)
inoremap <buffer> <expr><c-d> lsp#scroll(-4)
endfunction
augroup lsp_install
au!
" call s:on_lsp_buffer_enabled only for languages that has the server registered.
autocmd User lsp_buffer_enabled call s:on_lsp_buffer_enabled()
augroup END