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

Visual Studio Code

Fangrui Song edited this page Jan 18, 2018 · 15 revisions

Install extension

cquery includes a vscode extension; it is released in https://github.com/jacobdufault/cquery/releases. Launch vscode and install the vscode-extension.vsix 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 download it - it is still being developed.

See the wiki for additional details on setting up the extension.

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, set "cquery.launch.workingDirectory" in User Settings to the location where cquery is installed.

It's probably also worth mentioning that "cquery.launch.command" may need to be customized as well, especially if during building you used a prefix and installed into that prefix, and set "cquery.launch.workingDirectory" to the prefix (since then "cquery.launch.command" will need to be bin/cquery instead of the default release/bin/cquery).

    "cquery.launch.workingDirectory": "/path/to/cquery/build",
    "cquery.launch.command": "release/bin/cquery",
    "cquery.cacheDirectory": "/tmp/vscode-cquery",

# rainbow semantic highlighting
    "cquery.highlighting.enabled.freeStandingFunctions": true,
    "cquery.highlighting.enabled.freeStandingVariables": true,
    "cquery.highlighting.enabled.types": true,
    "cquery.highlighting.enabled.memberFunctions": true,
    "cquery.highlighting.enabled.memberVariables": true,

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.

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.

Publishing Extension

# Setup (just needs to be done once)
npm install -g vsce

# Package extension as vsix
cd vscode-client
python build.py

This will then create a vscode-extension.vsix package in the top-level cquery folder.

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": [
   ".*/src/base/third_party/.*",
   ".*/src/native_client/.*",
   ".*/src/native_client_sdk/.*",
   ".*/src/third_party/.*",
   ".*/src/v8/.*",
   ".*/src/webkit/.*"
  ]