Commit d3d385f0 authored by gagbo's avatar gagbo

LSP : Add true LSP client plugin with cquery/rls integration

The choice for the plugin is LanguageClient-neovim from autozimu because
there were less dependencies to pull through minpac. It works well with
these settings.
parent 735c2ac9
{
"initializationOptions": {
"cacheDirectory": "/tmp/cquery"
}
}
......@@ -110,6 +110,7 @@ runtime settings_gtags.vim
runtime settings_ale.vim
runtime settings_ultisnips.vim
runtime settings_fugitive.vim
runtime settings_lsp.vim
" Conveniences shipped with default config {{{1
augroup CursorAuto
......
......@@ -22,6 +22,14 @@ if exists('*minpac#init')
call minpac#add('davidhalter/jedi-vim')
endif
" Language Server Protocol
" I chose to use LanguageClient-neovim because :
" - fewer dependencies so the code is clearer from my point of view (aka
" only 1 plugin has to be pulled/managed here)
" - ALE has no plan currently to fully implement LSP, so to use RLS and
" Cquery fully it looks like the better solution
call minpac#add('autozimu/LanguageClient-neovim', { 'branch': 'next', 'do' : {-> system('./install.sh')}})
" New mappings on top of basic vim functions
" aka "Tpope's land"
call minpac#add('itchyny/lightline.vim')
......
" Settings for LanguageClient-neovim
let g:LanguageClient_serverCommands = {
\ 'rust': ['rustup', 'run', 'nightly', 'rls'],
\ 'cpp': ['/home/gagbo/soft/cquery/build/release/bin/cquery', '--log-file=/tmp/cq.log'],
\ 'c': ['/home/gagbo/soft/cquery/build/release/bin/cquery', '--log-file=/tmp/cq.log'],
\ }
let g:LanguageClient_loadSettings = 1 " Use an absolute configuration path if you want system-wide settings
let g:LanguageClient_settingsPath = '/home/gagbo/.config/nvim/cquery_init_settings.json'
" To set only for the relevant filetypes
" These mappings should be fine as they don't conflict with anything
nnoremap <F5> :call LanguageClient_contextMenu()<CR>
nnoremap <silent> gh :call LanguageClient#textDocument_hover()<CR>
nnoremap <silent> gd :call LanguageClient#textDocument_definition()<CR>
nnoremap <silent> gr :call LanguageClient#textDocument_references()<CR>
nnoremap <silent> gs :call LanguageClient#textDocument_documentSymbol()<CR>
nnoremap <silent> <F2> :call LanguageClient#textDocument_rename()<CR>
augroup LanguageClient_config
autocmd!
" Init the state of LanguageClient
autocmd BufEnter * let b:plugin_LanguageClient_started = 0
" Wire things up when the client is started
autocmd User LanguageClientStarted let b:plugin_LanguageClient_started = 1
autocmd User LanguageClientStarted setlocal signcolumn=auto
autocmd User LanguageClientStarted setlocal completefunc=LanguageClient#complete
autocmd User LanguageClientStarted setlocal formatexpr=LanguageClient_textDocument_rangeFormatting()
" Events when the client is active
autocmd CursorMoved * if b:plugin_LanguageClient_started | call LanguageClient#textDocument_hover() | endif
" Cleanup when the client is stopped
autocmd User LanguageClientStopped setlocal completefunc=
autocmd User LanguageClientStopped setlocal formatexpr=""
autocmd User LanguageClientStopped setlocal signcolumn=auto
autocmd User LanguageClientStopped let b:Plugin_LanguageClient_stopped = 0
augroup END
......@@ -123,6 +123,7 @@ runtime settings_ultisnips.vim
runtime settings_fugitive.vim
runtime settings_gtags.vim
runtime settings_ale.vim
runtime settings_lsp.vim
" Conveniences shipped with default config {{{1
augroup CursorAuto
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment