Skip to content
Neko edited this page Nov 20, 2018 · 14 revisions

CQuery is a Low-latency language server for large C++ code-bases, powered by libclang.

Configuration

let g:LanguageClient_serverCommands = {
\ 'cpp': ['yourCQueryDirectory/build/release/bin/cquery', 
\ '--log-file=/tmp/cq.log', 
# set cacheDirectory to /var/cquery may cause permission problem on linux
# set it to /tmp/cquery/ can fix it
\ '--init={"cacheDirectory":"/var/cquery/"}']                                                                                                                                                                              
\ }
" Use an absolute configuration path if you want system-wide settings
" let g:LanguageClient_settingsPath = '/home/yourusername/.config/nvim/settings.json'

Use with deoplete

Make sure you have installed the latest versions of deoplete (after cbcdf10-20171203) and LanguageClient-neovim (after https://github.com/autozimu/LanguageClient-neovim/pull/193 is merged).

Also install Neosnippet and configure:

imap <C-k>     <Plug>(neosnippet_expand_or_jump)
smap <C-k>     <Plug>(neosnippet_expand_or_jump)
xmap <C-k>     <Plug>(neosnippet_expand_target)

to your kepmappings. After that you may invoke <C-k> to expand and iterate over a completion item.

Troubleshooting

Completions are unexpectedly missing

If you notice that certain completion candidates are missing (e.g. you know a function exists but you aren't seeing completions for it), try disabling the completion.filterAndSort configuration option in cquery:

let g:LanguageClient_serverCommands = {
\ 'cpp': ['yourCQueryDirectory/build/release/bin/cquery', 
\ '--log-file=/tmp/cq.log', 
\ '--init={"cacheDirectory":"/var/cquery/", "completion": {"filterAndSort": false}}']                                                                                                                                                                              
\ }

Completion plugins such as Deoplete already implement filtering/sorting logic, and cquery may omit certain suggestions if the suggestion text already appears in the buffer you're editing.

Clone this wiki locally