You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This change adds `rust_analyzer` binaries to `rust_analyzer_toolchain`
so that it can be used with a new `//tools/rust_analyzer/validate`
target to ensure generated `rust-project.json` files are actually
correct.
Then you can use a prototype [rust-analyzer plugin](https://marketplace.visualstudio.com/items?itemName=MattStark.bazel-rust-analyzer) that automatically collects the outputs whenever you recompile.
111
112
112
113
## Project auto-discovery
114
+
113
115
### Setup
114
116
115
117
Auto-discovery makes `rust-analyzer` behave in a Bazel project in a similar fashion to how it does
116
-
in a Cargo project. This is achieved by generating a structure similar to what `rust-project.json`
117
-
contains but, instead of writing that to a file, the data gets piped to `rust-analyzer` directly
118
+
in a Cargo project. This is achieved by generating a structure similar to what `rust-project.json`
119
+
contains but, instead of writing that to a file, the data gets piped to `rust-analyzer` directly
118
120
through `stdout`. To use auto-discovery the `rust-analyzer` IDE settings must be configured similar to:
119
121
120
122
```json
@@ -130,7 +132,7 @@ through `stdout`. To use auto-discovery the `rust-analyzer` IDE settings must be
130
132
```
131
133
132
134
The shell script passed to `discoverConfig.command` is typically meant to wrap the bazel rule invocation,
133
-
primarily for muting `stderr` (because `rust-analyzer` will consider that an error has occurred if anything
135
+
primarily for muting `stderr` (because `rust-analyzer` will consider that an error has occurred if anything
134
136
is passed through `stderr`) and, additionally, for specifying rule arguments. E.g:
135
137
136
138
```shell
@@ -150,7 +152,7 @@ enabled. The script path should be either absolute or relative to the project ro
150
152
### Workspace splitting
151
153
152
154
The above configuration treats the entire project as a single workspace. However, large codebases might be
153
-
too much to handle for `rust-analyzer` all at once. This can be addressed by splitting the codebase in
155
+
too much to handle for `rust-analyzer` all at once. This can be addressed by splitting the codebase in
154
156
multiple workspaces by extending the `discoverConfig.command` setting:
155
157
156
158
```json
@@ -169,11 +171,9 @@ multiple workspaces by extending the `discoverConfig.command` setting:
169
171
that gets opened.
170
172
171
173
The root of the workspace will, in this configuration, be the package the crate currently being worked on
172
-
belongs to. This means that only that package and its dependencies get built and indexed by `rust-analyzer`,
173
-
thus allowing for a smaller footprint.
174
+
belongs to. This means that only that package and its dependencies get built and indexed by `rust-analyzer`,
175
+
thus allowing for a smaller footprint.
174
176
175
177
`rust-analyzer` will switch workspaces whenever an out-of-tree file gets opened, essentially indexing that
176
-
crate and its dependencies separately. A caveat of this is that *dependents* of the crate currently being
178
+
crate and its dependencies separately. A caveat of this is that _dependents_ of the crate currently being
177
179
worked on are not indexed and won't be tracked by `rust-analyzer`.
0 commit comments