summaryrefslogtreecommitdiffstats
path: root/src/doc/rustc-dev-guide/src/building/suggested.md
diff options
context:
space:
mode:
Diffstat (limited to 'src/doc/rustc-dev-guide/src/building/suggested.md')
-rw-r--r--src/doc/rustc-dev-guide/src/building/suggested.md96
1 files changed, 60 insertions, 36 deletions
diff --git a/src/doc/rustc-dev-guide/src/building/suggested.md b/src/doc/rustc-dev-guide/src/building/suggested.md
index f81daa5bc..2e2592094 100644
--- a/src/doc/rustc-dev-guide/src/building/suggested.md
+++ b/src/doc/rustc-dev-guide/src/building/suggested.md
@@ -19,51 +19,25 @@ You can also install the hook as a step of running `./x.py setup`!
## Configuring `rust-analyzer` for `rustc`
+### Visual Studio Code
+
`rust-analyzer` can help you check and format your code whenever you save
a file. By default, `rust-analyzer` runs the `cargo check` and `rustfmt`
commands, but you can override these commands to use more adapted versions
-of these tools when hacking on `rustc`. For example, for Visual Studio Code,
-you can write: <!-- date-check: nov 2022 --><!-- the date comment is for the edition below -->
-
-```JSON
-{
- "rust-analyzer.checkOnSave.overrideCommand": [
- "python3",
- "x.py",
- "check",
- "--json-output"
- ],
- "rust-analyzer.rustfmt.overrideCommand": [
- "./build/host/stage0/bin/rustfmt",
- "--edition=2021"
- ],
- "rust-analyzer.procMacro.server": "./build/host/stage0/libexec/rust-analyzer-proc-macro-srv",
- "rust-analyzer.procMacro.enable": true,
- "rust-analyzer.cargo.buildScripts.enable": true,
- "rust-analyzer.cargo.buildScripts.invocationLocation": "root",
- "rust-analyzer.cargo.buildScripts.invocationStrategy": "once",
- "rust-analyzer.cargo.buildScripts.overrideCommand": [
- "python3",
- "x.py",
- "check",
- "--json-output"
- ],
- "rust-analyzer.cargo.sysroot": "./build/host/stage0-sysroot",
- "rust-analyzer.rustc.source": "./Cargo.toml",
-}
-```
-
-in your `.vscode/settings.json` file. This will ask `rust-analyzer` to use
-`./x.py check` to check the sources, and the stage 0 rustfmt to format them.
+of these tools when hacking on `rustc`. For example, `x.py setup` will prompt
+you to create a `.vscode/settings.json` file which will configure Visual Studio code.
+This will ask `rust-analyzer` to use `./x.py check` to check the sources, and the
+stage 0 rustfmt to format them.
+The recommended `rust-analyzer` settings live at [`src/etc/vscode_settings.json`].
If you have enough free disk space and you would like to be able to run `x.py` commands while
rust-analyzer runs in the background, you can also add `--build-dir build-rust-analyzer` to the
`overrideCommand` to avoid x.py locking.
If you're running `coc.nvim`, you can use `:CocLocalConfig` to create a
-`.vim/coc-settings.json` and enter the same settings as above, but replacing
-`editor.formatOnSave: true,` with
-`"coc.preferences.formatOnSaveFiletypes": ["rust"],`.
+`.vim/coc-settings.json` and copy the settings from [`src/etc/vscode_settings.json`].
+
+[`src/etc/vscode_settings.json`]: https://github.com/rust-lang/rust/blob/master/src/etc/vscode_settings.json
If running `./x.py check` on save is inconvenient, in VS Code you can use a [Build
Task] instead:
@@ -87,6 +61,35 @@ Task] instead:
[Build Task]: https://code.visualstudio.com/docs/editor/tasks
+
+### Neovim
+
+For Neovim users there are several options for configuring for rustc. The easiest way is by using
+[neoconf.nvim](https://github.com/folke/neoconf.nvim/), which allows for project-local
+configuration files with the native LSP. The steps for how to use it are below. Note that requires
+Rust-Analyzer to already be configured with Neovim. Steps for this can be
+[found here](https://rust-analyzer.github.io/manual.html#nvim-lsp).
+
+1. First install the plugin. This can be done by following the steps in the README.
+2. Run `x.py setup`, which will have a prompt for it to create a `.vscode/settings.json` file.
+`neoconf` is able to read and update Rust-Analyzer settings automatically when the project is
+opened when this file is detected.
+
+If you're running `coc.nvim`, you can use `:CocLocalConfig` to create a
+`.vim/coc-settings.json` and copy the settings from
+[this file](https://github.com/rust-lang/rust/blob/master/src/etc/vscode_settings.json).
+
+Another way is without a plugin, and creating your own logic in your configuration. To do this you
+must translate the JSON to Lua yourself. The translation is 1:1 and fairly straight-forward. It
+must be put in the `["rust-analyzer"]` key of the setup table, which is
+[shown here](https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md#rust_analyzer)
+
+If you would like to use the build task that is described above, you may either make your own
+command in your config, or you can install a plugin such as
+[overseer.nvim](https://github.com/stevearc/overseer.nvim) that can [read VSCode's `task.json`
+files](https://github.com/stevearc/overseer.nvim/blob/master/doc/guides.md#vs-code-tasks), and
+follow the same instructions as above.
+
## Check, check, and check again
When doing simple refactorings, it can be useful to run `./x.py check`
@@ -175,6 +178,27 @@ You can also use `--keep-stage 1` when running tests. Something like this:
- Initial test run: `./x.py test tests/ui`
- Subsequent test run: `./x.py test tests/ui --keep-stage 1`
+## Using incremental compilation
+
+You can further enable the `--incremental` flag to save additional
+time in subsequent rebuilds:
+
+```bash
+./x.py test tests/ui --incremental --test-args issue-1234
+```
+
+If you don't want to include the flag with every command, you can
+enable it in the `config.toml`:
+
+```toml
+[rust]
+incremental = true
+```
+
+Note that incremental compilation will use more disk space than usual.
+If disk space is a concern for you, you might want to check the size
+of the `build` directory from time to time.
+
## Fine-tuning optimizations
Setting `optimize = false` makes the compiler too slow for tests. However, to