How do I enable C++ intellisense for a Bazel project in VS code?

Viewed 3761

I would like to enable intellisense for my C++ project that is being built with bazel in VS code.

There used to be a an extension that could do it, but it has been discontinued since the release of the official vscode-bazel extension which lacks this ability.

1 Answers

There is an open issue on vscode-bazel regarding this feature.

Fortunately, somebody pointed to an other tool bazel-compilation-database which can automatically generate a compile_commands.json.

Once you have generated that file, add it to your .vscode/c_cpp_properties.json file by adding the line

"compileCommands": "${workspaceFolder}/compile_commands.json"

Intellisense should now be enabled assuming you have vscode-cpptools extension installed.

Related