Skip to content

Commit b82e917

Browse files
mrkajetanpKobzol
authored andcommitted
building: Update instructions for ./x setup editor
1 parent e17bfa5 commit b82e917

File tree

2 files changed

+56
-40
lines changed

2 files changed

+56
-40
lines changed

src/building/quickstart.md

+31-21
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Quickstart
22

3-
This is a quickstart guide about getting the compiler running. For more information in the individual steps,
4-
see the other pages in this chapter.
3+
This is a quickstart guide about getting the compiler running. For more
4+
information on the individual steps, see the other pages in this chapter.
55

66
First, clone the repository:
77

@@ -10,34 +10,38 @@ git clone https://github.com/rust-lang/rust.git
1010
cd rust
1111
```
1212

13-
When building the compiler, we don't use `cargo` directly, instead we use a wrapper called "x".
14-
It is invoked with `./x`.
13+
When building the compiler, we don't use `cargo` directly, instead we use a
14+
wrapper called "x". It is invoked with `./x`.
1515

16-
We need to create a configuration for the build. Use `./x setup` to create a good default.
16+
We need to create a configuration for the build. Use `./x setup` to create a
17+
good default.
1718

1819
```sh
1920
./x setup
2021
```
2122

22-
Then, we can build the compiler. Use `./x build` to build the compiler, standard library and a few tools.
23-
You can also `./x check` to just check it.
24-
All these commands can take specific components/paths as arguments, for example `./x check compiler` to just check the compiler.
23+
Then, we can build the compiler. Use `./x build` to build the compiler, standard
24+
library and a few tools. You can also `./x check` to just check it. All these
25+
commands can take specific components/paths as arguments, for example `./x check
26+
compiler` to just check the compiler.
2527

2628
```sh
2729
./x build
2830
```
2931

30-
> When doing a change to the compiler that does not affect the way it compiles the standard library
31-
(so for example, a change to an error message), use `--keep-stage-std 1` to avoid recompiling it.
32+
> When doing a change to the compiler that does not affect the way it compiles
33+
the standard library (so for example, a change to an error message), use
34+
`--keep-stage-std 1` to avoid recompiling it.
3235

33-
After building the compiler and standard library, you now have a working compiler toolchain.
34-
You can use it with rustup by linking it.
36+
After building the compiler and standard library, you now have a working
37+
compiler toolchain. You can use it with rustup by linking it.
3538

3639
```sh
3740
rustup toolchain link stage1 build/host/stage1
3841
```
3942

40-
Now you have a toolchain called `stage1` linked to your build. You can use it to test the compiler.
43+
Now you have a toolchain called `stage1` linked to your build. You can use it to
44+
test the compiler.
4145

4246
```sh
4347
rustc +stage1 testfile.rs
@@ -46,19 +50,25 @@ rustc +stage1 testfile.rs
4650
After doing a change, you can run the compiler test suite with `./x test`.
4751

4852
`./x test` runs the full test suite, which is slow and rarely what you want.
49-
Usually, `./x test tests/ui` is what you want after a compiler change,
50-
testing all [UI tests](../tests/ui.md) that invoke the compiler on a specific test file and check the output.
53+
Usually, `./x test tests/ui` is what you want after a compiler change, testing
54+
all [UI tests](../tests/ui.md) that invoke the compiler on a specific test file
55+
and check the output.
5156

5257
```sh
5358
./x test tests/ui
5459
```
5560

56-
Use `--bless` if you've made a change and want to update the `.stderr` files with the new output.
61+
Use `--bless` if you've made a change and want to update the `.stderr` files
62+
with the new output.
5763

58-
> `./x suggest` can also be helpful for suggesting which tests to run after a change.
64+
> `./x suggest` can also be helpful for suggesting which tests to run after a
65+
> change.
5966
60-
Congrats, you are now ready to make a change to the compiler! If you have more questions,
61-
[the full chapter](./how-to-build-and-run.md) might contain the answers, and if it doesn't,
62-
feel free to ask for help on [Zulip](https://rust-lang.zulipchat.com/#narrow/stream/182449-t-compiler.2Fhelp).
67+
Congrats, you are now ready to make a change to the compiler! If you have more
68+
questions, [the full chapter](./how-to-build-and-run.md) might contain the
69+
answers, and if it doesn't, feel free to ask for help on
70+
[Zulip](https://rust-lang.zulipchat.com/#narrow/stream/182449-t-compiler.2Fhelp).
6371

64-
If you use VSCode, `./x setup` will ask you if you want to set up the config. For other editors, check out [suggested workflows](./suggested.md).
72+
If you use VSCode, Vim, Emacs or Helix, `./x setup` will ask you if you want to
73+
set up the editor config. For more information, check out [suggested
74+
workflows](./suggested.md).

src/building/suggested.md

+25-19
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,8 @@ par. If the hook fails then run `./x test tidy --bless` and commit the changes.
1515
If you decide later that the pre-push behavior is undesirable, you can delete
1616
the `pre-push` file in `.git/hooks`.
1717

18-
A prebuilt git hook lives at
19-
[`src/etc/pre-push.sh`](https://github.com/rust-lang/rust/blob/master/src/etc/pre-push.sh)
20-
which can be copied into your `.git/hooks` folder as `pre-push` (without the
21-
`.sh` extension!).
18+
A prebuilt git hook lives at [`src/etc/pre-push.sh`]. It can be copied into
19+
your `.git/hooks` folder as `pre-push` (without the `.sh` extension!).
2220

2321
You can also install the hook as a step of running `./x setup`!
2422

@@ -43,11 +41,16 @@ If you have enough free disk space and you would like to be able to run `x`
4341
commands while rust-analyzer runs in the background, you can also add
4442
`--build-dir build-rust-analyzer` to the `overrideCommand` to avoid x locking.
4543

44+
Running `./x setup editor` will prompt you to create a project-local LSP config
45+
file for one of the supported editors. You can also create the config file as a
46+
step of running `./x setup`.
47+
4648
### Visual Studio Code
4749

48-
Running `./x setup vscode` will prompt you to create a `.vscode/settings.json`
49-
file which will configure Visual Studio code. The recommended `rust-analyzer`
50-
settings live at [`src/etc/rust_analyzer_settings.json`].
50+
Selecting `vscode` in `./x setup editor` will prompt you to create a
51+
`.vscode/settings.json` file which will configure Visual Studio code. The
52+
recommended `rust-analyzer` settings live at
53+
[`src/etc/rust_analyzer_settings.json`].
5154

5255
If running `./x check` on save is inconvenient, in VS Code you can use a [Build
5356
Task] instead:
@@ -83,13 +86,14 @@ here](https://rust-analyzer.github.io/manual.html#nvim-lsp).
8386

8487
1. First install the plugin. This can be done by following the steps in the
8588
README.
86-
2. Run `x setup`, which will have a prompt for it to create a
89+
2. Run `./x setup editor`, and select `vscode` to create a
8790
`.vscode/settings.json` file. `neoconf` is able to read and update
8891
rust-analyzer settings automatically when the project is opened when this
8992
file is detected.
9093

91-
If you're running `coc.nvim`, you can use `:CocLocalConfig` to create a
92-
`.vim/coc-settings.json`, and copy the settings from
94+
If you're using `coc.nvim`, you can run `./x setup editor` and select `vim` to
95+
create a `.vim/coc-settings.json`. The settings can be edited with
96+
`:CocLocalConfig`. The recommended settings live at
9397
[`src/etc/rust_analyzer_settings.json`].
9498

9599
Another way is without a plugin, and creating your own logic in your
@@ -111,10 +115,10 @@ Emacs provides support for rust-analyzer with project-local configuration
111115
through [Eglot](https://www.gnu.org/software/emacs/manual/html_node/eglot/).
112116
Steps for setting up Eglot with rust-analyzer can be [found
113117
here](https://rust-analyzer.github.io/manual.html#eglot).
114-
Having set up Emacs & Eglot for Rust development in general, you can use the
115-
configuration for rustc provided in [`src/etc/rust_analyzer_eglot.el`](
116-
https://github.com/rust-lang/rust/blob/master/src/etc/rust_analyzer_eglot.el).
117-
Simply copy the provided file to `.dir-locals.el` in the project root directory.
118+
Having set up Emacs & Eglot for Rust development in general, you can run
119+
`./x setup editor` and select `emacs`, which will prompt you to create
120+
`.dir-locals.el` with the recommended configuration for Eglot.
121+
The recommended settings live at [`src/etc/rust_analyzer_eglot.el`].
118122
For more information on project-specific Eglot configuration, consult [the
119123
manual](https://www.gnu.org/software/emacs/manual/html_node/eglot/Project_002dspecific-configuration.html).
120124

@@ -123,14 +127,13 @@ manual](https://www.gnu.org/software/emacs/manual/html_node/eglot/Project_002dsp
123127
Helix comes with built-in LSP and rust-analyzer support.
124128
It can be configured through `languages.toml`, as described
125129
[here](https://docs.helix-editor.com/languages.html).
126-
You can use the configuration for rustc provided in
127-
[`src/etc/rust_analyzer_helix.toml`](https://github.com/rust-lang/rust/blob/master/src/etc/rust_analyzer_helix.toml).
128-
Simply copy the provided file to `.helix/languages.toml` in the project root
129-
directory.
130+
You can run `./x setup editor` and select `helix`, which will prompt you to
131+
create `languages.toml` with the recommended configuration for Helix. The
132+
recommended settings live at [`src/etc/rust_analyzer_helix.toml`].
130133

131134
## Check, check, and check again
132135

133-
When doing simple refactorings, it can be useful to run `./x check`
136+
When doing simple refactoring, it can be useful to run `./x check`
134137
continuously. If you set up `rust-analyzer` as described above, this will be
135138
done for you every time you save a file. Here you are just checking that the
136139
compiler can **build**, but often that is all you need (e.g., when renaming a
@@ -356,3 +359,6 @@ Adding this to your shell's startup script (e.g. `.bashrc`) will automatically
356359
load this completion.
357360

358361
[`src/etc/rust_analyzer_settings.json`]: https://github.com/rust-lang/rust/blob/master/src/etc/rust_analyzer_settings.json
362+
[`src/etc/rust_analyzer_eglot.el`]: https://github.com/rust-lang/rust/blob/master/src/etc/rust_analyzer_eglot.el
363+
[`src/etc/rust_analyzer_helix.toml`]: https://github.com/rust-lang/rust/blob/master/src/etc/rust_analyzer_helix.toml
364+
[`src/etc/pre-push.sh`]: https://github.com/rust-lang/rust/blob/master/src/etc/pre-push.sh

0 commit comments

Comments
 (0)