LSP in Vim is EASY

1 year ago

I've seen too many posts and articles that mention the enormous difficulty of using an LSP in Vim or--worse--suggest that Vim does not support LSPs at all.

" plugins
prabirshrestha/vim-lsp
mattn/vim-lsp-settings
prabirshrestha/asyncomplete.vim
prabirshrestha/asyncomplete-lsp.vim
github/copilot.vim

" config
filetype plugin on

" copied (almost) directly from the vim-lsp docs:
function! s:on_lsp_buffer_enabled() abort
setlocal omnifunc=lsp#complete
setlocal signcolumn=yes
if exists('+tagfunc') | setlocal tagfunc=lsp#tagfunc | endif

let g:lsp_format_sync_timeout = 1000
autocmd! BufWritePre *.rs,*.go call execute('LspDocumentFormatSync')
endfunction

augroup lsp_install
au!
" call s:on_lsp_buffer_enabled (set the lsp shortcuts) when an lsp server
" is registered for a buffer.
autocmd User lsp_buffer_enabled call s:on_lsp_buffer_enabled()
augroup END

Loading comments...