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
building/suggested: Add instructions for Emacs & Helix
Add instructions for setting up rust-analyzer with Emacs and Helix.
Additionally, move some content applicable to all editors out of the
vscode section into its own section for visibility.
Copy file name to clipboardExpand all lines: src/building/suggested.md
+28-8
Original file line number
Diff line number
Diff line change
@@ -21,19 +21,18 @@ You can also install the hook as a step of running `./x setup`!
21
21
22
22
## Configuring `rust-analyzer` for `rustc`
23
23
24
-
### Visual Studio Code
24
+
### Project-local rust-analyzer setup
25
25
26
26
`rust-analyzer` can help you check and format your code whenever you save
27
27
a file. By default, `rust-analyzer` runs the `cargo check` and `rustfmt`
28
28
commands, but you can override these commands to use more adapted versions
29
-
of these tools when hacking on `rustc`. For example, `x setup vscode` will prompt
30
-
you to create a `.vscode/settings.json` file which will configure Visual Studio code.
31
-
This will ask `rust-analyzer` to use `./x check` to check the sources, and the
32
-
stage 0 rustfmt to format them.
33
-
The recommended `rust-analyzer` settings live at [`src/etc/rust_analyzer_settings.json`].
29
+
of these tools when hacking on `rustc`.
30
+
With custom setup, `rust-analyzer` can use `./x check` to check the sources,
31
+
and the stage 0 rustfmt to format them.
34
32
35
-
The default `rust-analyzer.check.overrideCommand` command line will check all the crates and tools
36
-
in the repository. If you are working on a specific part, you can override the command to only
33
+
The default `rust-analyzer.check.overrideCommand` command line will check all
34
+
the crates and tools in the repository.
35
+
If you are working on a specific part, you can override the command to only
37
36
check the part you are working on to save checking time. For example, if you are working on
38
37
the compiler, you can override the command to `x check compiler --json-output` to only
39
38
check the compiler part. You can run `x check --help --verbose` to see the available parts.
@@ -42,6 +41,12 @@ If you have enough free disk space and you would like to be able to run `x` comm
42
41
rust-analyzer runs in the background, you can also add `--build-dir build-rust-analyzer` to the
43
42
`overrideCommand` to avoid x locking.
44
43
44
+
### Visual Studio Code
45
+
46
+
Running `x setup vscode` will prompt you to create a `.vscode/settings.json`
47
+
file which will configure Visual Studio code.
48
+
The recommended `rust-analyzer` settings live at [`src/etc/rust_analyzer_settings.json`].
49
+
45
50
If running `./x check` on save is inconvenient, in VS Code you can use a [Build
46
51
Task] instead:
47
52
@@ -93,6 +98,21 @@ command in your config, or you can install a plugin such as
93
98
files](https://github.com/stevearc/overseer.nvim/blob/master/doc/guides.md#vs-code-tasks), and
94
99
follow the same instructions as above.
95
100
101
+
### Emacs
102
+
103
+
Emacs provides support for rust-analyzer with project-local configuration through [Eglot](https://www.gnu.org/software/emacs/manual/html_node/eglot/).
104
+
Steps for setting up Eglot with rust-analyzer can be [found here](https://rust-analyzer.github.io/manual.html#eglot).
105
+
Having set up Emacs & Eglot for Rust development in general, you can use the configuration for rustc provided in [`src/etc/rust_analyzer_eglot.el`].
106
+
Simply copy the provided file to `.dir-locals.el` in the project root directory.
107
+
For more information on project-specific Eglot configuration, consult [the manual](https://www.gnu.org/software/emacs/manual/html_node/eglot/Project_002dspecific-configuration.html).
108
+
109
+
### Helix
110
+
111
+
Helix comes with built-in LSP and rust-analyzer support.
112
+
It can be configured through `languages.toml`, as described [here](https://docs.helix-editor.com/languages.html).
113
+
You can use the configuration for rustc provided in [`src/etc/rust_analyzer_helix.toml`].
114
+
Simply copy the provided file to `.helix/languages.toml` in the project root directory.
115
+
96
116
## Check, check, and check again
97
117
98
118
When doing simple refactorings, it can be useful to run `./x check`
0 commit comments