Skip to content

VS Code

njlr edited this page Feb 22, 2019 · 2 revisions

Buck (and therefore Buckaroo) can integrate with the C/C++ Extension for Visual Studio Code.

There is a complete example of how to set this up on GitHub.

Setup

Make sure you install the C/C++ Extension first!

The C/C++ Extension works on a compile_commands.json file. Buck can generate this for you using the compilation-database flavor.

If you want code completion for a target called //:app, then do:

buck build //:app#compilation-database --show-output

Buck probably put the file here (check the above command if your path differs):

cat buck-out/gen/__app#compilation-database/compile_commands.json

Next, we have to tell VS Code where to find it.

Create a file in the root of your project called .vscode/c_cpp_properties.json:

{
  "configurations": [
    {
      "name": "app",
      "compileCommands": "buck-out/gen/__app#compilation-database/compile_commands.json"
    }
  ],
  "version": 4
}

You should now see code completion in Visual Studio Code!

Note that to refresh the code completions, you will need to rebuild the database (buck build //:app#compilation-database) and refresh VS Code (https://github.com/Microsoft/vscode-cpptools/issues/2306). Unfortunately, most C++ tools are not built for fast iteration times like Buck! ⚡

Clone this wiki locally