-
Couldn't load subscription status.
- Fork 274
LanguageClient neovim
- See Getting started to build the
cclsexecutable - Install LanguageClient-neovim You may use the plugin manager vim-plug
LanguageClient-neovim
nvim +PlugInstall +UpdateRemotePlugins +qa~/.config/nvim/settings.json (optional, by default it creates cache directory .ccls-cache in the project root)
{
"initializationOptions": {
"cacheDirectory": "/tmp/ccls"
}
}~/.config/nvim/init.vim
let g:LanguageClient_serverCommands = {
\ 'cpp': ['ccls', '--log-file=/tmp/cc.log'],
\ 'c': ['ccls', '--log-file=/tmp/cc.log'],
\ }
let g:LanguageClient_loadSettings = 1 " Use an absolute configuration path if you want system-wide settings
let g:LanguageClient_settingsPath = '/home/YOUR_USERNAME/.config/nvim/settings.json'Make sure you have .ccls or compile_commands.json in your project root. Open a file in the project, run :LanguageClientStart.
These features will work out-of-the-box.
nn <silent> <M-j> :call LanguageClient#textDocument_definition()<cr>
nn <silent> <C-,> :call LanguageClient#textDocument_references({'includeDeclaration': v:false})<cr>
nn <silent> K :call LanguageClient#textDocument_hover()<cr>augroup LanguageClient_config
au!
au BufEnter * let b:Plugin_LanguageClient_started = 0
au User LanguageClientStarted setl signcolumn=yes
au User LanguageClientStarted let b:Plugin_LanguageClient_started = 1
au User LanguageClientStopped setl signcolumn=auto
au User LanguageClientStopped let b:Plugin_LanguageClient_stopped = 0
au CursorMoved * if b:Plugin_LanguageClient_started | sil call LanguageClient#textDocument_documentHighlight() | endif
augroup ENDSemantic navigation. Roughly,
"D" => first child declaration "L" => previous declaration "R" => next declaration "U" => parent declaration
nn <silent> xh :call LanguageClient#findLocations({'method':'$ccls/navigate','direction':'L'})<cr>
nn <silent> xj :call LanguageClient#findLocations({'method':'$ccls/navigate','direction':'D'})<cr>
nn <silent> xk :call LanguageClient#findLocations({'method':'$ccls/navigate','direction':'U'})<cr>
nn <silent> xl :call LanguageClient#findLocations({'method':'$ccls/navigate','direction':'R'})<cr>" bases of up to 3 levels
nn <silent> xb :call LanguageClient#findLocations({'method':'$ccls/inheritanceHierarchy','flat':v:true,'levels':3,'derived':v:false})<cr>
" derived of up to 3 levels
nn <silent> xd :call LanguageClient#findLocations({'method':'$ccls/inheritanceHierarchy','flat':v:true,'levels':3,'derived':v:true})<cr>
nn <silent> xe :call LanguageClient#findLocations({'method':'$ccls/callers'})<cr>
nn <silent> xm :call LanguageClient#findLocations({'method':'$ccls/memberHierarchy','flat':v:true})<cr>
nn <silent> xt :call LanguageClient#textDocument_typeDefinition()<cr>
nn <silent> xv :call LanguageClient#findLocations({'method':'$ccls/vars'})<cr>
nn <silent> xV :call LanguageClient#findLocations({'method':'$ccls/vars','kind':1})<cr>
nn xx x$ccls/inheritanceHierarchy flat:t derived:false: base classes/overridden methods/specialized from
$ccls/inheritanceHierarchy flat:t derived:true
$ccls/callers: callers of a function
The more general $ccls/callHierarchy has not been implemented by a Vim plugin.
$ccls/vars: instances of a type
$ccls/memberHierarchy flat:t: fields of a struct/class/union/...





