Skip to content
Alick Zhao edited this page Apr 18, 2018 · 7 revisions

Installing server

Refer https://github.com/jacobdufault/cquery/wiki for installing cquery.

Registering in .vimrc

if executable('cquery')
   au User lsp_setup call lsp#register_server({
      \ 'name': 'cquery',
      \ 'cmd': {server_info->['cquery']},
      \ 'root_uri': {server_info->lsp#utils#path_to_uri(lsp#utils#find_nearest_parent_file_directory(lsp#utils#get_buffer_path(), 'compile_commands.json'))},
      \ 'initialization_options': { 'cacheDirectory': '/path/to/cquery/cache' },
      \ 'whitelist': ['c', 'cpp', 'objc', 'objcpp', 'cc'],
      \ })
endif

where /path/to/cquery/cache can be e.g. /tmp/cquery/cache.

Additional cquery features

If you want to use cquery features that use extensions to language server protocol, vim-lsp-cquery plugin may help you. It adds commands to get all functions that override this one, or get a list of all variables that are objects of some user-defined class.

Project configuration

Note, that as many clang/llvm based tools do, cquery, in order to work properly, requires a file compile_commands.json, that store a description of how compiler is invoked, what macro definitions are passed to it, etc. Use your build system of choice to generate it. See llvm page about compilation database.