Skip to content
This repository has been archived by the owner on Jul 30, 2020. It is now read-only.

Visual Studio Code

Ben Deeming edited this page Sep 20, 2018 · 15 revisions

Install extension

Install the cquery extension from the marketplace here. The source code is located at https://github.com/cquery-project/vscode-cquery.

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

Setting up the extension

To tell the extension where to find cquery, either add cquery to your PATH or set "cquery.launch.command" in User Settings to the absolute path pointing to cquery.

{
    "cquery.launch.command": "/absolute/path/to/cquery/release/bin/cquery",
    "cquery.cacheDirectory": "/home/.cquery-cache/"
}

cquery.index.extraClangArguments

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

Semantic highlighting

The Visual Studio Code cquery extension supports semantic highlighting. To enable, put into settings.conf (or workspace configuration):

"cquery.highlighting.enabled.types": true,
"cquery.highlighting.enabled.freeStandingFunctions": true,
"cquery.highlighting.enabled.memberFunctions": true,
"cquery.highlighting.enabled.freeStandingVariables": true,
"cquery.highlighting.enabled.memberVariables": true,
"cquery.highlighting.enabled.namespaces": true,
"cquery.highlighting.enabled.macros": true,
"cquery.highlighting.enabled.enums": true,
"cquery.highlighting.enabled.typeAliases": true,
"cquery.highlighting.enabled.enumConstants": true,
"cquery.highlighting.enabled.staticMemberFunctions": true,
"cquery.highlighting.enabled.parameters": true,
"cquery.highlighting.enabled.templateParameters": true,
"cquery.highlighting.enabled.staticMemberVariables": true,
"cquery.highlighting.enabled.globalVariables": true,

Complimentary VS Code Extensions

Toggle header/source files with vscode-header-source

The vscode-header-source extension allows you to press F4 (configurable action), while in a C++ file, to toggle between the header & source files.

Using vscode-cquery along side vscode-cpptools extension for debugger support

The vscode-cquery extension doesn't provide any debugger integration. One popular option is to use the vscode-cpptools extension for this aspect. By default however, vscode-cpptools provides editor features that overlap with CQuery, which yields duplicate results in things like autocomplete. The following settings may be applied to disable the editor support of vscode-cpptools to prevent this from happening, while still retaining the debugger features.

{
  "C_Cpp.autocomplete": "Disabled",
  "C_Cpp.formatting": "Disabled",
  "C_Cpp.errorSquiggles": "Disabled",
  "C_Cpp.intelliSenseEngine": "Disabled",
}