Version: 1.8.x

Starlark Language Server

The Starlark Language Server component provides intellisense features for BUILD, BUILD.bazel, WORKSPACE, *.bzl and related files.

A different feature set is provided for .bazelrc files.

Configuration

The language server is configured automatically, no specific configuration is required. To increase logging level, add --log_level=info to the bsv.bzl.lsp.command setting.

You can enable/disable various codelens actions via the settings if you find them overly intrusive.

Codelens

Codelens actions are the little links that appear above rule declarations:

image

  • //example/routeguide:routeguide_proto the codelens with the full label will copy the bazel label to the clipboard.

  • build will run bazel build LABEL in an integrated terminal.

  • test will run bazel test LABEL in an integrated terminal.

  • run will run bazel run LABEL in an integrated terminal.

  • debug will launch a debug session with bazel build LABEL --experimental_skylark_debug.

  • codesearch will open up the codesearch webview that will search within the bazel query defined by deps(LABEL).

  • browse will open a browser tab in the Bezel UI at the corresponding rule.

Hover

Hover over any builtin rule/function/provider/attribute to get inline documentation:

image

Hover over any custom starlark rule to get inline documentation:

info

Hover documentation for custom/third-party rules is a subscription feature.

image

Hover over flags in a .bazelrc file to get flag documentation:

image

Click on the provided link to go to the bazel docs, or perform a codesearch for the flag in https://cs.opensource.google/bazel/bazel.

Signature Help

Signature help (aka "Parameter Hints") are available for rules and starlark functions:

image

Completion

Type to get autocompletion for builtin rules:

info

Autocompletion for custom and third-party starlark rules (ones defined in .bzl files within your repo, or an external repository) is a subscription feature.

image

Use ctrl+space within the context of a rule/function to get completion suggestions without typing.

Type "" in a load statement to get autocompletion of available load symbols:

info

Completion for load symbols is a subscription feature.

image

Completion for flags is provided within .bazelrc files:

image

Definition

Type F12 in a bazel label (string literal) to jump to the definition of the label:

lsp-label-jump-to-definition

F12 over a rule name to jump the file where the symbol is declared:

info

Jump-to-definition for custom/third-party rules is a subscription feature.

jump-to-rule-definition

Jump-to-label

Use the bsv.bzl.goToLabel command (mac: โŒ˜+;; just below the familiar โŒ˜+p accelerator) to pop open an input box. Enter the bazel label to navigate to and press ENTER:

jump-to-label

Syntax Highlighting

Syntax highlighting is provided for bazel and starlark files.