Skip to content

Commit 58465d1

Browse files
committed
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.
1 parent 2562a10 commit 58465d1

File tree

1 file changed

+28
-8
lines changed

1 file changed

+28
-8
lines changed

src/building/suggested.md

+28-8
Original file line numberDiff line numberDiff line change
@@ -21,19 +21,18 @@ You can also install the hook as a step of running `./x setup`!
2121

2222
## Configuring `rust-analyzer` for `rustc`
2323

24-
### Visual Studio Code
24+
### Project-local rust-analyzer setup
2525

2626
`rust-analyzer` can help you check and format your code whenever you save
2727
a file. By default, `rust-analyzer` runs the `cargo check` and `rustfmt`
2828
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.
3432

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
3736
check the part you are working on to save checking time. For example, if you are working on
3837
the compiler, you can override the command to `x check compiler --json-output` to only
3938
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
4241
rust-analyzer runs in the background, you can also add `--build-dir build-rust-analyzer` to the
4342
`overrideCommand` to avoid x locking.
4443

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+
4550
If running `./x check` on save is inconvenient, in VS Code you can use a [Build
4651
Task] instead:
4752

@@ -93,6 +98,21 @@ command in your config, or you can install a plugin such as
9398
files](https://github.com/stevearc/overseer.nvim/blob/master/doc/guides.md#vs-code-tasks), and
9499
follow the same instructions as above.
95100

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+
96116
## Check, check, and check again
97117

98118
When doing simple refactorings, it can be useful to run `./x check`

0 commit comments

Comments
 (0)