Skip to content

Commit

Permalink
Merge branch 'master' into distinct-output-base
Browse files Browse the repository at this point in the history
  • Loading branch information
cameron-martin authored Apr 8, 2024
2 parents c591a66 + a93e19a commit 76142f8
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 16 deletions.
12 changes: 8 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,16 @@ 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 the LSP (Experimental)
## Using a language server (experimental)

This extension can use [Facebook's starlark project](https://github.com/facebookexperimental/starlark-rust) as a language server.
This extension can use a language server for various features, such as go to definition and completions. There are currently two compatible language servers:

1. Install the LSP using cargo: `cargo install starlark_bin`
2. Enable the LSP extension by setting `bazel.lsp.enabled` to `true`.
- [bazel-lsp](https://github.com/cameron-martin/bazel-lsp) is based on Facebook's Starlark language server and extends it with additional, Bazel-specific functionality.
- [starpls](https://github.com/withered-magic/starpls) is an implementation based on rust-analyzer which also provides Bazel-specific functionality.

In general, you need to install the language server binary and then set the `bazel.lsp.command` setting. See the README of the corresponding repo for more specific setup instructions.

We can't currently make any recommendation between these two. Both are under active development and are rapidly gaining more functionality.

## Bazel tasks

Expand Down
14 changes: 3 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -181,25 +181,17 @@
"default": "...:*",
"description": "A [query language expression](https://bazel.build/query/language) which determines the packages displayed in the workspace tree and quick picker. The default inspects the entire workspace, but you could narrow it. For example: `//part/you/want/...:*`"
},
"bazel.lsp.enabled": {
"type": "boolean",
"default": false,
"description": "Enable the LSP (experimental)"
},
"bazel.lsp.command": {
"type": "string",
"default": "starlark",
"description": "The executable to launch for the LSP"
"default": "",
"description": "The executable to launch for the LSP (experimental). Providing this disables certain features in the extension on the basis that they'll be provided by this language server."
},
"bazel.lsp.args": {
"type": "array",
"items": {
"type": "string"
},
"default": [
"--lsp",
"--bazel"
],
"default": [],
"description": "The arguments to pass to the LSP executable"
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/extension/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export async function activate(context: vscode.ExtensionContext) {
completionItemProvider.refresh();

const config = vscode.workspace.getConfiguration("bazel");
const lspEnabled = config.get<boolean>("lsp.enabled");
const lspEnabled = !!config.get<string>("lsp.command");

if (lspEnabled) {
const lspClient = createLsp(config);
Expand Down

0 comments on commit 76142f8

Please sign in to comment.