Low-latency vscode language server for large C++ code-bases, powered by libclang.
C C++ TypeScript Python Emacs Lisp Shell
Switch branches/tags
Nothing to show
Failed to load latest commit information.
clang_resource_dir Add clang resource directory Oct 23, 2017
emacs [emacs] Add cquery-xref-find-locations-with-position (#121) Dec 10, 2017
full_tests Auto-index header files Apr 8, 2017
images Update demo image May 19, 2017
src Implement diagnostic range as per clang_formatDiagnostic Dec 11, 2017
tests Add operator test Dec 2, 2017
third_party Use indented TEST_SUITE Nov 19, 2017
vscode-client [package.json] Add missing dependency "vscode" Dec 11, 2017
.clang-format Add project .clang-format Nov 19, 2017
.clang_complete Misc formatting Mar 17, 2017
.gitattributes Readd image Apr 18, 2017
.gitignore Fix broken build (add lru_cache.h) Dec 4, 2017
.gitmodules First pass at logging using loguru Jul 28, 2017
.travis.yml travis: Disable cache; broken build Dec 7, 2017
.ycm_extra_conf.py Add src/ directory to .ycm_extra_conf.py Dec 7, 2017
README.md Rename clang_args to .cquery Nov 27, 2017
clang_compilation_database.py Fix waf generation of compile_comands.json Nov 20, 2017
compile_commands.json Use compile_commands.json in root directory in favor of clang_args Nov 20, 2017
format.ps1 Add powershell version of format script Nov 4, 2017
format.sh Update format.sh to not use clang-format -verbose Nov 19, 2017
style.md misc header cleanup Mar 25, 2017
test_runner_e2e.py Make some good progress on e2e tests. Sep 13, 2017
vscode-extension.vsix Update vscode extension Dec 6, 2017
waf Revert waf to original value Nov 17, 2017
wscript Fix waf build Dec 5, 2017



Join the chat at https://gitter.im/cquery-project/Lobby

cquery is a highly-scalable, low-latency language server for C/C++. It is tested and designed for large code bases like Chromium. cquery provides accurate and fast semantic analysis without interrupting workflow.


cquery implements almost the entire language server protocol and provides some extra features to boot:

  • code completion (with both signature help and snippets)
  • references
  • type hierarchy (parent type, derived types, expandable tree view)
  • calls to functions, calls to base and derived functions, call tree
  • symbol rename
  • goto definition, goto base method
  • document and global symbol search
  • hover tooltips showing symbol type
  • diagnostics
  • code actions (clang FixIts)
  • darken/fade code disabled by preprocessor
  • #include auto-complete, undefined type include insertion, include quick-jump (goto definition, document links)
  • auto-implement functions without a definition

Setup - build cquery, install extension, setup project

There are three steps to get cquery up and running. Eventually, cquery will be published in the vscode extension marketplace which will reduce these three steps to only project setup.

Build cquery

Building cquery is simple. The external dependencies are few:

  • relatively modern c++11 compiler (ie, clang 3.4 or greater)
  • python
  • git
$ clang --version  # if missing, sudo apt-get install clang
$ git clone https://github.com/jacobdufault/cquery --recursive
$ cd cquery
$ ./waf configure
$ ./waf build

Install extension

cquery includes a vscode extension; it is part of the repository. Launch vscode and install the vscode-extension.tsix extension. To do this:

  • Hit F1; execute the command Install from VSIX.
  • Select vscode-extension.vsix in the file chooser.

IMPORTANT: Please reinstall the extension when you sync the code base - it is still being developed.

If you run into issues, you can view debug output by running the (F1) View: Toggle Output command and opening the cquery output section.

Project setup

compile_commands.json (Best)

See wiki for how to generate compile_commands.json with CMake, Build EAR, Ninja, ...

If the compile_commands.json is not in the top-level workspace directory, then the cquery.misc.compilationDatabaseDirectory setting can be used to specify its location.


If for whatever reason you cannot generate a compile_commands.json file, you can add the flags to the cquery.index.extraClangArguments configuration option.


If for whatever reason you cannot generate a compile_commands.json file, you can add the flags to a file called .cquery located in the top-level workspace directory.

Each argument in that file is separated by a newline. Lines starting with # are skipped. Here's an example:

# Language

# Includes

Building extension

If you wish to modify the vscode extension, you will need to build it locally. Luckily, it is pretty easy - the only dependency is npm.

# Build extension
$ cd vscode-client
$ npm install
$ code .

When VSCode is running, you can hit F5 to build and launch the extension locally.


cquery is able to respond to queries quickly because it caches a huge amount of information. When a request comes in, cquery just looks it up in the cache without running many computations. As a result, there's a large memory overhead. For example, a full index of Chrome will take about 10gb of memory. If you exclude v8, webkit, and third_party, it goes down to about 6.5gb.


For Emacs/Vim/other editors integration and some additional tips, see wiki.

Chromium tips

Chromium is a very large codebase, so cquery benefits from a bit of tuning. Optionally add these to your settings:

  // Set slightly lower than your CPU core count to keep other tools responsive.
  "cquery.misc.indexerCount": 50,
  // Remove uncommonly used directories with large numbers of files.
  "cquery.index.blacklist": [