Skip to content

Latest commit

 

History

History
35 lines (28 loc) · 1.93 KB

vscode.md

File metadata and controls

35 lines (28 loc) · 1.93 KB

Set up VSCode

  1. In Node.js working directory, run ./configure -C (if building with ninja, run ./configure --ninja -C).
  2. This creates the compile_commands.json file that clangd requires for indexing. Re-run this tool every time you pull in (or make) significant changes (in particular: adding, moving, or removing files).
  3. Install VSCode extensions:
  4. C/C++ (by Microsoft)
  5. clangd (by LLVM)
  6. Configure settings. See the example settings.json below for inspiration.
  7. Note that there are ~/.config/Code/User/settings.json for system-wide config and ./.vscode/settings.json for project-specific settings. Choose wisely which setting goes where.
  8. on Windows, the paths are %AppData%\Code\User\settings.json and .\code\settings.json, respectively.

Notes and gotchas:

clangd sometimes crashes (e.g. when you keep making changes quicker than it can index them, it sometimes gets confused). VSCode will give up on restarting it if this happens too frequently. In that case, hit F1 (or Ctrl+Shift+P), type "reload", and select "Developer: Reload Window" to reload VSCode.

Example settings.json:

{
  "clangd.arguments": [
    "-header-insertion=never"  // More annoying than helpful
  ],
  "clangd.onConfigChanged": "restart",
  // Let clangd take care of these features.
  "C_Cpp.autocomplete": "disabled",
  "C_Cpp.errorSquiggles": "disabled",
  "C_Cpp.intelliSenseEngine": "disabled"
}

If you want to use VSCode's "build tasks" feature to build from the IDE (default shortcut: Ctrl+Shift+B), set up a task to your liking. See the example in .vscode/ for inspiration.

See also how to setup VSCode for V8 and Chromium: