Bazel plugin for Visual Studio CodeThis extension provides support for Bazel in Visual Studio. Features
Configuring the ExtensionThis extension adds a Bazel section to the extension settings in Visual Studio Code. If you have Bazel installed in a location that is not on your system path or if you wish to use a different version in the IDE, you should set the Bazel: Executable setting to the location of the Bazel executable. Similarly, the Bazel: Buildifier Executable setting can be configured if you install Buildifier in a location that is not on your system path. When Buildifier is installed, the Format Document command in Visual Studio
code will reformat Using a separate output baseBy default this extension will use the default output base for running queries. This will cause builds to block queries, potentially causing degraded performance. In Bazel versions since 7.1 it is safe to disable this by changing the
See #216 and bazelbuild/bazel#106539. Using the Starlark DebuggerCurrently, the Starlark Debugger can be used by right-clicking a build target in the Bazel Build Targets view and selecting "Build Target with Starlark Debugger". This will start the build inside the Visual Studio Code debugger (output will be redirected to the Debug Console pane) and it will pause on any breakpoints hit during execution. When a Bazel thread is paused, you can step through Starlark code, add watch expressions, and execute arbitrary statements by typing them in the input area of the Debug Console. Clicking the "Stop" button in the debugger will kill the Bazel process being debugger, allowing you to halt the current build. The Bazel server, however, will continue running. Using a language server (experimental)This extension can use a language server for various features, such as go to definition and completions. There are currently two compatible language servers:
In general, you need to install the language server binary and then set the We can't currently make any recommendation between these two. Both are under active development and are rapidly gaining more functionality. Bazel tasksBazel tasks can be configured from the
Coverage support (Experimental)For all
You might need additional Bazel Code coverage support in this extension is still rather fresh and might still have rough edges. It was tested with the Java, C++, Go and Rust rules. In case you are using the code coverage integration with any other language (Python, Swift, Kotlin, Scala, ...), please let us know how things are going in bazelbuild/vscode-bazel#367. Please share both positive and negative experiences you might have. For C++ and Rust, make sure to have ContributingIf you would like to contribute to the Bazel Visual Studio extension, please refer to the contribution guidelines for information about our patch acceptance process and setting up your development environment. |