@@ -19,6 +19,8 @@ You can also install the hook as a step of running `./x.py setup`!
19
19
20
20
## Configuring ` rust-analyzer ` for ` rustc `
21
21
22
+ ### Visual Studio Code
23
+
22
24
` rust-analyzer ` can help you check and format your code whenever you save
23
25
a file. By default, ` rust-analyzer ` runs the ` cargo check ` and ` rustfmt `
24
26
commands, but you can override these commands to use more adapted versions
@@ -31,9 +33,6 @@ If you have enough free disk space and you would like to be able to run `x.py` c
31
33
rust-analyzer runs in the background, you can also add ` --build-dir build-rust-analyzer ` to the
32
34
` overrideCommand ` to avoid x.py locking.
33
35
34
- If you're running ` coc.nvim ` , you can use ` :CocLocalConfig ` to create a
35
- ` .vim/coc-settings.json ` and copy the settings from [ this file] ( https://github.com/rust-lang/rust/blob/master/src/etc/vscode_settings.json ) .
36
-
37
36
If running ` ./x.py check ` on save is inconvenient, in VS Code you can use a [ Build
38
37
Task] instead:
39
38
@@ -56,6 +55,35 @@ Task] instead:
56
55
57
56
[ Build Task ] : https://code.visualstudio.com/docs/editor/tasks
58
57
58
+
59
+ ### Neovim
60
+
61
+ For Neovim users there are several options for configuring for rustc. The easiest way is by using
62
+ [ neoconf.nvim] ( https://github.com/folke/neoconf.nvim/ ) , which allows for project-local
63
+ configuration files with the native LSP. The steps for how to use it are below. Note that requires
64
+ Rust-Analyzer to already be configured with Neovim. Steps for this can be
65
+ [ found here] ( https://rust-analyzer.github.io/manual.html#nvim-lsp ) .
66
+
67
+ 1 . First install the plugin. This can be done by following the steps in the README.
68
+ 2 . Run ` x.py setup ` , which will have a prompt for it to create a ` .vscode/settings.json ` file.
69
+ ` neoconf ` is able to read and update Rust-Analyzer settings automatically when the project is
70
+ opened when this file is detected.
71
+
72
+ If you're running ` coc.nvim ` , you can use ` :CocLocalConfig ` to create a
73
+ ` .vim/coc-settings.json ` and copy the settings from
74
+ [ this file] ( https://github.com/rust-lang/rust/blob/master/src/etc/vscode_settings.json ) .
75
+
76
+ Another way is without a plugin, and creating your own logic in your configuration. To do this you
77
+ must translate the JSON to Lua yourself. The translation is 1:1 and fairly straight-forward. It
78
+ must be put in the ` ["rust-analyzer"] ` key of the setup table, which is
79
+ [ shown here] ( https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md#rust_analyzer )
80
+
81
+ If you would like to use the build task that is described above, you may either make your own
82
+ command in your config, or you can install a plugin such as
83
+ [ overseer.nvim] ( https://github.com/stevearc/overseer.nvim ) that can [ read VSCode's ` task.json `
84
+ files] ( https://github.com/stevearc/overseer.nvim/blob/master/doc/guides.md#vs-code-tasks ) , and
85
+ follow the same instructions as above.
86
+
59
87
## Check, check, and check again
60
88
61
89
When doing simple refactorings, it can be useful to run ` ./x.py check `
0 commit comments