Skip to content

Commit d835aee

Browse files
committed
Added rust-analyzer instructions for Helix
1 parent a7b01ce commit d835aee

File tree

3 files changed

+91
-38
lines changed

3 files changed

+91
-38
lines changed

CONTRIBUTING.md

+32-38
Original file line numberDiff line numberDiff line change
@@ -195,48 +195,42 @@ installed (`cargo install hyperfine`).
195195

196196
## Configuring `rust-analyzer`
197197

198-
To configure `rust-analyzer` and VS Code for working on Miri, save the following
199-
to `.vscode/settings.json` in your local Miri clone:
200-
201-
```json
202-
{
203-
"rust-analyzer.rustc.source": "discover",
204-
"rust-analyzer.linkedProjects": [
205-
"Cargo.toml",
206-
"cargo-miri/Cargo.toml",
207-
"miri-script/Cargo.toml",
208-
],
209-
"rust-analyzer.check.invocationLocation": "root",
210-
"rust-analyzer.check.invocationStrategy": "once",
211-
"rust-analyzer.check.overrideCommand": [
212-
"env",
213-
"MIRI_AUTO_OPS=no",
214-
"./miri",
215-
"clippy", // make this `check` when working with a locally built rustc
216-
"--message-format=json",
217-
],
218-
// Contrary to what the name suggests, this also affects proc macros.
219-
"rust-analyzer.cargo.buildScripts.invocationLocation": "root",
220-
"rust-analyzer.cargo.buildScripts.invocationStrategy": "once",
221-
"rust-analyzer.cargo.buildScripts.overrideCommand": [
222-
"env",
223-
"MIRI_AUTO_OPS=no",
224-
"./miri",
225-
"check",
226-
"--message-format=json",
227-
],
228-
}
229-
```
198+
To configure `rust-analyzer` and the IDE for working on Miri, use one of the provided
199+
configuration files according to the instructions below.
200+
201+
202+
### Visual Studio Code
230203

231-
> #### Note
204+
Copy [`etc/rust_analyzer_vscode.json`] to `.vscode/settings.json` in the project root directory.
205+
206+
> #### Hint
232207
>
233-
> If you are [building Miri with a locally built rustc][], set
234-
> `rust-analyzer.rustcSource` to the relative path from your Miri clone to the
235-
> root `Cargo.toml` of the locally built rustc. For example, the path might look
236-
> like `../rust/Cargo.toml`.
208+
> To keep the `rust-analyzer` configuration up-to-date, make a symbolic link to one
209+
> of the provided files depending on the IDE you use.
210+
211+
[`etc/rust_analyzer_vscode.json`]: https://github.com/rust-lang/miri/blob/master/etc/rust_analyzer_vscode.json
212+
213+
### Helix
214+
215+
Copy [`etc/rust_analyzer_helix.toml`] to `.helix/languages.toml` in the project root directory.
216+
217+
Since working on Miri requires a custom toolchain, and Helix requires the language server
218+
to be installed with the toolchain, you have to run `./miri toolchain -c rust-analyzer`
219+
when installing the Miri toolchain. Alternatively, set the `RUSTUP_TOOLCHAIN` environment variable according to
220+
[the documentation](https://rust-analyzer.github.io/manual.html#toolchain).
221+
222+
[`etc/rust_analyzer_helix.toml`]: https://github.com/rust-lang/miri/blob/master/etc/rust_analyzer_helix.toml
223+
224+
### Advanced configuration
225+
226+
If you are building Miri with a locally built rustc, set
227+
`rust-analyzer.rustcSource` to the relative path from your Miri clone to the
228+
root `Cargo.toml` of the locally built rustc. For example, the path might look
229+
like `../rust/Cargo.toml`. In addition to that, replace `clippy` by `check`
230+
in the `rust-analyzer.check.overrideCommand` setting.
237231

238232
See the rustc-dev-guide's docs on ["Configuring `rust-analyzer` for `rustc`"][rdg-r-a]
239-
for more information about configuring VS Code and `rust-analyzer`.
233+
for more information about configuring the IDE and `rust-analyzer`.
240234

241235
[rdg-r-a]: https://rustc-dev-guide.rust-lang.org/building/suggested.html#configuring-rust-analyzer-for-rustc
242236

etc/rust_analyzer_helix.toml

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
[language-server.rust-analyzer.config.rustc]
2+
source = "discover"
3+
4+
[language-server.rust-analyzer.config]
5+
linkedProjects = [
6+
"Cargo.toml",
7+
"cargo-miri/Cargo.toml",
8+
"miri-script/Cargo.toml",
9+
]
10+
11+
[language-server.rust-analyzer.config.check]
12+
invocationLocation = "root"
13+
invocationStrategy = "once"
14+
overrideCommand = [
15+
"env",
16+
"MIRI_AUTO_OPS=no",
17+
"./miri",
18+
"clippy", # make this `check` when working with a locally built rustc
19+
"--message-format=json",
20+
]
21+
22+
# Contrary to what the name suggests, this also affects proc macros.
23+
[language-server.rust-analyzer.config.buildScripts]
24+
invocationLocation = "root"
25+
invocationStrategy = "once"
26+
overrideCommand = [
27+
"env",
28+
"MIRI_AUTO_OPS=no",
29+
"./miri",
30+
"check",
31+
"--message-format=json",
32+
]

etc/rust_analyzer_vscode.json

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
{
2+
"rust-analyzer.rustc.source": "discover",
3+
"rust-analyzer.linkedProjects": [
4+
"Cargo.toml",
5+
"cargo-miri/Cargo.toml",
6+
"miri-script/Cargo.toml",
7+
],
8+
"rust-analyzer.check.invocationLocation": "root",
9+
"rust-analyzer.check.invocationStrategy": "once",
10+
"rust-analyzer.check.overrideCommand": [
11+
"env",
12+
"MIRI_AUTO_OPS=no",
13+
"./miri",
14+
"clippy", // make this `check` when working with a locally built rustc
15+
"--message-format=json",
16+
],
17+
// Contrary to what the name suggests, this also affects proc macros.
18+
"rust-analyzer.cargo.buildScripts.invocationLocation": "root",
19+
"rust-analyzer.cargo.buildScripts.invocationStrategy": "once",
20+
"rust-analyzer.cargo.buildScripts.overrideCommand": [
21+
"env",
22+
"MIRI_AUTO_OPS=no",
23+
"./miri",
24+
"check",
25+
"--message-format=json",
26+
],
27+
}

0 commit comments

Comments
 (0)