Skip to content

Commit 75e38b8

Browse files
authored
Rewrite README (#84)
* Rewrite README * More LSP feature descriptions
1 parent 686800b commit 75e38b8

File tree

3 files changed

+253
-49
lines changed

3 files changed

+253
-49
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# Change Log
22

3+
## 1.5.0 (Nov 14 2021)
4+
5+
- Add buildozer activity component.
6+
- Bump bzl to `1.1.1` (new LSP autocompletion, improved hover support)
7+
38
## 1.4.0 (Nov 4 2021)
49

510
- Add buildozer wizard.

README.md

Lines changed: 245 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<table><tr>
66
<td style="width: 120px; text-align: center"><img src="https://upload.wikimedia.org/wikipedia/en/thumb/7/7d/Bazel_logo.svg/240px-Bazel_logo.svg.png" height="120"/></td>
77
<td style="width: 120px; text-align: center"><img src="https://user-images.githubusercontent.com/50580/78734740-486ba400-7906-11ea-89fa-f207544de185.png" height="100"/></td>
8-
<td style="width: 120px; text-align: center"><img src="https://user-images.githubusercontent.com/29654835/27530004-e789a11e-5a13-11e7-8a34-870da7e678ac.PNG" height="90"/></td>
8+
<td style="width: 120px; text-align: center"><img src="https://user-images.githubusercontent.com/29654835/27530004-e789a11e-5a13-11e7-8a34-870da7e678ac.PNG" height="100"/></td>
99
</tr><tr>
1010
<td style="text-align: center">Bazel</td>
1111
<td style="text-align: center">Stack</td>
@@ -20,72 +20,269 @@
2020

2121
<https://marketplace.visualstudio.com/items?itemName=StackBuild.bazel-stack-vscode>
2222

23-
## Basic Features:
23+
This extension provides editor support for the starlark language and the bazel
24+
dialect of starlark.
2425

25-
- `bazel` and `starlark` files (`BUILD`, `.bazel`, `WORKSPACE`, `*.bzl`, `.star`, `*.sky`):
26-
- syntax highlighting
27-
- [formatting](#Build-File-Formatting) & [linting diagnostics](#Build-File-Linting-Diagnostics) (via `buildifier`)
28-
- hover to get [links to bazel documentation](#Hover-Symbols-to-Get-Documentation-Links)
29-
- hover to get [bazel rule & starlark function
30-
reference](#Hover-Symbols-to-Get-Inline-Documentation) (via Starlark
31-
Language Server)
32-
- [go to definition](https://stackb.github.io/bazel-stack-vscode/jumping) for bazel labels
33-
34-
- `bazelrc` files (`*.bazelrc`):
35-
- syntax highlighting
36-
- hover to get [flag reference](#Hover-Flags-to-Get-Inline-Documentation) & links to bazel docs / bazel codesearch
37-
- completion for all 834 available flags by command (includes undocumented flags).
38-
- `launch.bazelrc` file (a file where you can stash frequently executed commands):
39-
- syntax highlighting
40-
- [hover over command name](#Launch-File-Codelens) to get a "codelens" (click to run the command)
41-
- repeat previous command for iterative development (`shift+ctrl+space`)
42-
- custom problem matcher for rules_go output
26+
The following operating systems are supported:
4327

44-
### Build File Formatting
28+
- linux
29+
- mac
30+
- windows
4531

46-
![1-format](https://user-images.githubusercontent.com/50580/89370237-7cc95400-d69d-11ea-8d6c-949fd099cf21.gif)
32+
> NOTE: while the list above is sorted alphabetically, windows is not an
33+
> afterthought; one of the main supporters of bazel-stack-vscode is a
34+
> windows-only shop).
4735
48-
### Build File Linting Diagnostics
36+
## Contributions
4937

50-
![1-lint](https://user-images.githubusercontent.com/50580/89370514-227cc300-d69e-11ea-8784-266e9756e8ec.gif)
38+
The major contribution points include:
5139

52-
### Go To Definition for Bazel Labels
40+
### Language
5341

54-
![jtd-1](https://user-images.githubusercontent.com/50580/97147747-9c699900-172f-11eb-87b8-6142563eaa62.gif)
42+
- `starlark` language (matches `.sky`, `.star` files).
43+
- `bazel` language (matches `BUILD`, `BUILD.bazel`, `.bzl` and related files).
44+
- `bazelrc` language (matches `.bazelrc` and related files).
5545

56-
### Hover Symbols to Get Inline Documentation
46+
### Grammar
5747

58-
![1-rulehover](https://user-images.githubusercontent.com/50580/89370355-c31eb300-d69d-11ea-8fc6-eeff04641dd0.gif)
48+
- `starlark` grammar (syntax highlighting for `starlark` language).
49+
- `bazel` grammar (syntax highlighting for `bazel` language).
50+
- `bazelrc` grammar (syntax highlighting for `bazelrc` language).
5951

60-
### Hover Symbols to Get Documentation Links
52+
### Commands
6153

62-
![1-bazeldoc](https://user-images.githubusercontent.com/50580/89370432-efd2ca80-d69d-11ea-97e3-cdc52925acf9.gif)
54+
See [Keybindings](#keybindings) for description of commands bound to keyboard
55+
shortcuts. Other commands included are typically meant to be activated by menus
56+
or buttons (see [Tools](#tools)).
6357

64-
### Hover Flags to Get Inline Documentation
58+
### Keybindings
6559

66-
![1-flaghover](https://user-images.githubusercontent.com/50580/89370676-8f905880-d69e-11ea-958b-5b7574abd067.gif)
60+
- `shift+cmd+space` runs the `bsv.bzl.redo` command; to use this, click on a
61+
build/test *code action* to run it the first time; then slap the space bar
62+
while holding down the command key to quickly rebuild/retest it.
63+
- `ctrl+shift+cmd+b` runs the `bsv.bzl.copyLabel` command. To use this, place
64+
your cursor in the `name` of a build rule (e.g. `name = "my_f|oo_library"`)
65+
and stroke the keybinding; the full label `//pkg/app:my_foo_library` will be
66+
copied to the clipboard.
67+
- `cmd+;` runs the `bsv.bzl.goToLabel` command. To use this, stroke the
68+
keybinding (designed to be ergonomically similar to the builtin `cmd+p` menu);
69+
this will open an input box where you can type/paste in a bazel label; press
70+
`ENTER` to move to the rule/file implied by the label.
71+
- `shift+cmd+t` runs the `workbench.view.extension.bazel-explorer` command. This
72+
will show the [Tools](#tools).
73+
- `ctrl+shift+cmd+p` runs the `bsv.buildozer.wizard` command. To use this,
74+
stroke the keybinding; a sequence of input boxes / picks will guide you
75+
through formulating a buildozer command.
6776

68-
> Includes all 834 flags (including undocumented options)
77+
### View
6978

70-
### Flag Autocomplete
79+
- The `bazel-explorer` contains a number of so-called **Tools**. Each tool has
80+
a similar look-and-feel for enablement, configuration, documentation/help, and
81+
possible launch/execution of the tool. See [Tools](#tools) for reference.
7182

72-
![1-flag-completion](https://user-images.githubusercontent.com/50580/89370594-5ce66000-d69e-11ea-8838-7520efd6531a.gif)
83+
### Debugger
7384

74-
> Use the `' '` (space) or `'='` (equals) to commit choice and continue typing
85+
- Support for `bazel` language debugging via the debug adapter protocol. See
86+
description of the [Starlark Debugger Tool](#starlark-debugger-tool) for
87+
details.
7588

76-
## Advanced Features:
89+
### Breakpoint
7790

78-
The advanced features are available with a [Bzl](https://bzl.io/product/bezel)
79-
subscription. Sign-up on the website or within the vscode extension. Read more
80-
about advanced features on the [documentation
81-
site](https://stackb.github.io/bazel-stack-vscode/).
91+
- Support for setting breakpoints for the `bazel` language. See
92+
[Debugger](#debugger).
8293

83-
---
94+
### Snippet
8495

85-
**Github Rate Limits**: This extension makes requests to the github v3 API. If
86-
you experience errors due to rate limits, `export
87-
GITHUB_TOKEN={MY_PERSONAL_TOKEN}` and relaunch vscode to get higher rate
88-
limits.
96+
Assorted `bazel` language snippets for templating out rule, provider
97+
implementations, etc.
8998

90-
> NOTE: portions of this extension were adapted from
91-
> https://github.com/bazelbuild/vscode-bazel (Apache 2.0).
99+
## Tools
100+
101+
The *activity view* contains a list of tree items; each top-level item
102+
represents a "tool". The tool may be something like `buildifier`, which
103+
actually downloads and runs an executable; or something like a *service* that
104+
shows information (e.g. `bazel info`).
105+
106+
Each "tool" component has a set of configurable elements; to configure them
107+
either expand the **Settings** tree item and click on it, or go directly to your
108+
user/workspace settings and hunt for the corresponding configuration item (e.g.
109+
`bsv.bzl.lsp.enableCodelenses`).
110+
111+
112+
### Buildifier Tool
113+
114+
Buildifier provides linting and formatting support for the `bazel` language. It
115+
is highly recommended to always format on save: to do this, add the following to
116+
your `settings.json`:
117+
118+
```json
119+
"[bazel]": {
120+
"editor.formatOnSave": true
121+
}
122+
```
123+
124+
### Buildozer Tool
125+
126+
Buildozer performs bulk editing of BUILD files and can be very useful for
127+
various refactoring activities. If you are buildozer expert, you may not need
128+
this. For the rest of us who use buildozer relatively infrequently, you can use
129+
the `bsv.buildozer.wizard` to help step through the various possibilities and
130+
construct a buildozer command. See [Keybindings](#keybindings).
131+
132+
### Starlark Debugger Tool
133+
134+
The starlark debugger tool launches the debug adapter tool when a `bazel`
135+
language debug session is starting. You can customize the settings used for the
136+
adapter or the bazel server.
137+
138+
See the [Debugging](https://stackb.github.io/bazel-stack-vscode/debugging)
139+
section of the docs for more details.
140+
141+
### Starlark Language Server Tool
142+
143+
The starlark language server provides LSP support for the `bazel` and `starlark`
144+
languages. Supported features include:
145+
146+
- **code actions**: code action links for `[LABEL]`, `build`, `test`, `run`, `debug`,
147+
`codesearch`, and `ui`.
148+
- `[LABEL]`: clicking on this code action will copy the label to the clipboard.
149+
- `build`: clicking on this code action will run `bazel build [LABEL]` in an
150+
integrated terminal.
151+
- `test`: clicking on this code action will run `bazel test [LABEL]` in an
152+
integrated terminal.
153+
- `run`: clicking on this code action will run `bazel run [LABEL]` in an
154+
integrated terminal.
155+
- `debug`: clicking on this code action will run `bazel build [LABEL]
156+
--experimental_skylark_debug` and start a starlark debugging session.
157+
- `codesearch`: clicking on this code action will show the [Codesearch
158+
UI](#code-search-tool) for that label. This allows you to "livegrep"
159+
withing the transitive set of source files required to build `[LABEL]`.
160+
- `ui`: clicking on this code action will open an external link to the
161+
`[LABEL]` in the [Bzl UI](#bzl-ui-tool).
162+
- **hover**:
163+
- hover over a rule/provider/aspect to get documentation about the it (e.g. `ge*nrule`).
164+
- hover over a rule attribute to get documentation about the attribute (e.g.
165+
`s*rcs = ["...]`).
166+
- hover over a function to get documentation about the function (e.g.
167+
`ran*ge(1, 1, 1)`).
168+
- **completion**:
169+
- completion for core starlark functions (e.g. type `rev` ->
170+
`reversed(sequence)`).
171+
- completion for bazel builtin function/rules/providers/attributes (e.g. `jav`
172+
-> `java_binary(...)`).
173+
- completion for third-party and custom starlark rules is available on a
174+
subscription basis.
175+
- **jump-to-definition**:
176+
- `F12` on any string literal; if it looks like a relative or canonical bazel
177+
label, will open the corresponding BUILD or source file (works with default and
178+
external workspaces).
179+
180+
### Remote Cache Tool
181+
182+
The `bzl` tool contains a lightweight and fast LRU [remote
183+
cache](https://docs.bazel.build/versions/main/remote-caching.html)
184+
implementation.
185+
186+
This "locally-running" remote cache is actually 30% faster than using the
187+
`--disk_cache` option (and manages disk usage better). If you have multiple
188+
bazel repositories on your workstation (or are frequently switching git
189+
branches) it is highly recommended to run this remote cache locally, at all
190+
times.
191+
192+
The cache implementation also provides nice progress notifications for uploads
193+
with a terminal-based progress bar.
194+
195+
Given that you may or may not have a vscode window running at all times, the
196+
recommended strategy is to keep a terminal running (or system service) with
197+
`/path/to/bzl cache --progress` and put the following in your `$HOME/.bazelrc`
198+
file:
199+
200+
```bazelrc
201+
build --remote_cache=grpc://localhost:2020
202+
```
203+
204+
This will give a nice speedup for many actions that you'd otherwise be waiting
205+
to unnecessarily rebuild.
206+
207+
### Bazel Tool
208+
209+
The bazel tool provides a view of the `bazel info` for a workspace. It is also
210+
used to configure default build/test flags used on conjuction with the language
211+
server (see [Starlark Language Server](#starlark-language-server-tool)).
212+
213+
### Stack.Build Account Tool
214+
215+
The account tool is used to view account settings and/or signup for a pro
216+
subscription. If you and your team members are using the `bazel-stack-vscode`
217+
extension at work, please encourage your product owner / manager / corp-entity
218+
to get your team signed up.
219+
220+
Benefits of `pro` subscriptions include:
221+
222+
1. Autocompletion, hover documentation, and jump-to-definition for
223+
third-party/custom rulesets. For example, this will automagically produce
224+
autocompletion for a `go_binary` rule from `@io_bazel_rules_go//go:def.bzl`,
225+
or for a `my_custom_rule` from `//bazel/internal/corp.bzl`. [COMING SOON].
226+
2. Invocation details and build events within VSCode.
227+
3. Execution log diff tool.
228+
4. Running the `bzl` tool as a service within your organization to share
229+
invocation details (as a developer support tool).
230+
5. Using the `bzl cache` tool in CI.
231+
6. User support via slack.
232+
233+
### Bzl UI Tool
234+
235+
The `bzl` tool runs a webserver by default at `http://localhost:8080`. The UI
236+
provides a navigable display of core bazel concepts such as:
237+
238+
1. Show bazel workspaces on current machine.
239+
2. Show packages within a workspace.
240+
3. Show rules within a workspace (by type).
241+
4. Show attributes of a rule.
242+
5. Show external workspaces.
243+
6. Codesearch UI.
244+
7. Clickable dependency graph.
245+
246+
The UI is intended to be used as a form of documentation for the workspace to
247+
assist with code presentations, code review, and onboarding of new team members.
248+
249+
### Code Search Tool
250+
251+
The code search tool implements a fast search code search engine. If you are
252+
familiar with [livegrep](https://github.com/livegrep/livegrep), this is like
253+
livegrep for bazel queries. The backend is not actually livegrep, but a custom
254+
regexp implementation similar to
255+
[google/codesearch](github.com/google/codesearch) with an API similar to
256+
livegrep.
257+
258+
Bzl codesearch is unlike any other codesearch tool as it naturally includes all
259+
source file dependencies in the query.
260+
261+
Using codesearch is a two-step process:
262+
263+
1. Build a search file index.
264+
2. Run queries against the index.
265+
266+
The codesearch UI will guide you through that process. See the docs for
267+
[Searching](https://stackb.github.io/bazel-stack-vscode/searching) for more
268+
details.
269+
270+
### Build Events Service Tool
271+
272+
The build event service configured the display of build events within VSCode.
273+
274+
### Invocations Service Tool
275+
276+
The invocation service tool allows you to view and/or replay invocations.
277+
278+
### Event Stream Tool
279+
280+
The event stream service tool provide a realtime view of build events for build
281+
invocations.
282+
283+
284+
## Bazelrc Language
285+
286+
- syntax highlighting
287+
- hover to get [flag reference](#Hover-Flags-to-Get-Inline-Documentation) & links to bazel docs / bazel codesearch
288+

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424
"Snippets"
2525
],
2626
"activationEvents": [
27+
"workspaceContains:WORKSPACE",
28+
"workspaceContains:WORKSPACE.bazel",
2729
"onDebug",
2830
"onUri",
2931
"onCommand:bsv.openExtensionSetting",
@@ -651,7 +653,7 @@
651653
"bazel-explorer": [
652654
{
653655
"id": "bsv.workspace",
654-
"name": "Stack VSCode v1.4.0",
656+
"name": "Stack VSCode v1.5.0",
655657
"icon": "media/bazel-wireframe.svg",
656658
"contextualTitle": "Current Bazel Workspace",
657659
"when": "resourceLangId == bazel"

0 commit comments

Comments
 (0)