diff options
Diffstat (limited to 'docs/user')
-rw-r--r-- | docs/user/generated_config.adoc | 26 | ||||
-rw-r--r-- | docs/user/manual.adoc | 45 |
2 files changed, 43 insertions, 28 deletions
diff --git a/docs/user/generated_config.adoc b/docs/user/generated_config.adoc index cb2ae6fc1..3025dc8d6 100644 --- a/docs/user/generated_config.adoc +++ b/docs/user/generated_config.adoc | |||
@@ -5,7 +5,7 @@ rust-analyzer.assist.importPrefix (default: `"plain"`):: | |||
5 | rust-analyzer.callInfo.full (default: `true`):: | 5 | rust-analyzer.callInfo.full (default: `true`):: |
6 | Show function name and docs in parameter hints. | 6 | Show function name and docs in parameter hints. |
7 | rust-analyzer.cargo.autoreload (default: `true`):: | 7 | rust-analyzer.cargo.autoreload (default: `true`):: |
8 | Automatically refresh project info via `cargo metadata` on Cargo.toml changes. | 8 | Automatically refresh project info via `cargo metadata` on `Cargo.toml` changes. |
9 | rust-analyzer.cargo.allFeatures (default: `false`):: | 9 | rust-analyzer.cargo.allFeatures (default: `false`):: |
10 | Activate all available features. | 10 | Activate all available features. |
11 | rust-analyzer.cargo.features (default: `[]`):: | 11 | rust-analyzer.cargo.features (default: `[]`):: |
@@ -21,7 +21,7 @@ rust-analyzer.cargo.noSysroot (default: `false`):: | |||
21 | rust-analyzer.checkOnSave.enable (default: `true`):: | 21 | rust-analyzer.checkOnSave.enable (default: `true`):: |
22 | Run specified `cargo check` command for diagnostics on save. | 22 | Run specified `cargo check` command for diagnostics on save. |
23 | rust-analyzer.checkOnSave.allFeatures (default: `null`):: | 23 | rust-analyzer.checkOnSave.allFeatures (default: `null`):: |
24 | Check with all features (will be passed as `--all-features`). Defaults to `rust-analyzer.cargo.allFeatures`. | 24 | Check with all features (will be passed as `--all-features`). Defaults to `#rust-analyzer.cargo.allFeatures#`. |
25 | rust-analyzer.checkOnSave.allTargets (default: `true`):: | 25 | rust-analyzer.checkOnSave.allTargets (default: `true`):: |
26 | Check all targets and tests (will be passed as `--all-targets`). | 26 | Check all targets and tests (will be passed as `--all-targets`). |
27 | rust-analyzer.checkOnSave.command (default: `"check"`):: | 27 | rust-analyzer.checkOnSave.command (default: `"check"`):: |
@@ -29,11 +29,11 @@ rust-analyzer.checkOnSave.command (default: `"check"`):: | |||
29 | rust-analyzer.checkOnSave.noDefaultFeatures (default: `null`):: | 29 | rust-analyzer.checkOnSave.noDefaultFeatures (default: `null`):: |
30 | Do not activate the `default` feature. | 30 | Do not activate the `default` feature. |
31 | rust-analyzer.checkOnSave.target (default: `null`):: | 31 | rust-analyzer.checkOnSave.target (default: `null`):: |
32 | Check for a specific target. Defaults to `rust-analyzer.cargo.target`. | 32 | Check for a specific target. Defaults to `#rust-analyzer.cargo.target#`. |
33 | rust-analyzer.checkOnSave.extraArgs (default: `[]`):: | 33 | rust-analyzer.checkOnSave.extraArgs (default: `[]`):: |
34 | Extra arguments for `cargo check`. | 34 | Extra arguments for `cargo check`. |
35 | rust-analyzer.checkOnSave.features (default: `null`):: | 35 | rust-analyzer.checkOnSave.features (default: `null`):: |
36 | List of features to activate. Defaults to `rust-analyzer.cargo.features`. | 36 | List of features to activate. Defaults to `#rust-analyzer.cargo.features#`. |
37 | rust-analyzer.checkOnSave.overrideCommand (default: `null`):: | 37 | rust-analyzer.checkOnSave.overrideCommand (default: `null`):: |
38 | Advanced option, fully override the command rust-analyzer uses for checking. The command should include `--message-format=json` or similar option. | 38 | Advanced option, fully override the command rust-analyzer uses for checking. The command should include `--message-format=json` or similar option. |
39 | rust-analyzer.completion.addCallArgumentSnippets (default: `true`):: | 39 | rust-analyzer.completion.addCallArgumentSnippets (default: `true`):: |
@@ -43,7 +43,7 @@ rust-analyzer.completion.addCallParenthesis (default: `true`):: | |||
43 | rust-analyzer.completion.postfix.enable (default: `true`):: | 43 | rust-analyzer.completion.postfix.enable (default: `true`):: |
44 | Whether to show postfix snippets like `dbg`, `if`, `not`, etc. | 44 | Whether to show postfix snippets like `dbg`, `if`, `not`, etc. |
45 | rust-analyzer.completion.autoimport.enable (default: `true`):: | 45 | rust-analyzer.completion.autoimport.enable (default: `true`):: |
46 | Toggles the additional completions that automatically add imports when completed. Note that your client have to specify the `additionalTextEdits` LSP client capability to truly have this feature enabled. | 46 | Toggles the additional completions that automatically add imports when completed. Note that your client must specify the `additionalTextEdits` LSP client capability to truly have this feature enabled. |
47 | rust-analyzer.diagnostics.enable (default: `true`):: | 47 | rust-analyzer.diagnostics.enable (default: `true`):: |
48 | Whether to show native rust-analyzer diagnostics. | 48 | Whether to show native rust-analyzer diagnostics. |
49 | rust-analyzer.diagnostics.enableExperimental (default: `true`):: | 49 | rust-analyzer.diagnostics.enableExperimental (default: `true`):: |
@@ -51,9 +51,9 @@ rust-analyzer.diagnostics.enableExperimental (default: `true`):: | |||
51 | rust-analyzer.diagnostics.disabled (default: `[]`):: | 51 | rust-analyzer.diagnostics.disabled (default: `[]`):: |
52 | List of rust-analyzer diagnostics to disable. | 52 | List of rust-analyzer diagnostics to disable. |
53 | rust-analyzer.diagnostics.warningsAsHint (default: `[]`):: | 53 | rust-analyzer.diagnostics.warningsAsHint (default: `[]`):: |
54 | List of warnings that should be displayed with info severity.\nThe warnings will be indicated by a blue squiggly underline in code and a blue icon in the problems panel. | 54 | List of warnings that should be displayed with info severity.\n\nThe warnings will be indicated by a blue squiggly underline in code and a blue icon in the `Problems Panel`. |
55 | rust-analyzer.diagnostics.warningsAsInfo (default: `[]`):: | 55 | rust-analyzer.diagnostics.warningsAsInfo (default: `[]`):: |
56 | List of warnings that should be displayed with hint severity.\nThe warnings will be indicated by faded text or three dots in code and will not show up in the problems panel. | 56 | List of warnings that should be displayed with hint severity.\n\nThe warnings will be indicated by faded text or three dots in code and will not show up in the `Problems Panel`. |
57 | rust-analyzer.files.watcher (default: `"client"`):: | 57 | rust-analyzer.files.watcher (default: `"client"`):: |
58 | Controls file watching implementation. | 58 | Controls file watching implementation. |
59 | rust-analyzer.hoverActions.debug (default: `true`):: | 59 | rust-analyzer.hoverActions.debug (default: `true`):: |
@@ -71,7 +71,7 @@ rust-analyzer.hoverActions.linksInHover (default: `true`):: | |||
71 | rust-analyzer.inlayHints.chainingHints (default: `true`):: | 71 | rust-analyzer.inlayHints.chainingHints (default: `true`):: |
72 | Whether to show inlay type hints for method chains. | 72 | Whether to show inlay type hints for method chains. |
73 | rust-analyzer.inlayHints.maxLength (default: `null`):: | 73 | rust-analyzer.inlayHints.maxLength (default: `null`):: |
74 | Maximum length for inlay hints. | 74 | Maximum length for inlay hints. Default is unlimited. |
75 | rust-analyzer.inlayHints.parameterHints (default: `true`):: | 75 | rust-analyzer.inlayHints.parameterHints (default: `true`):: |
76 | Whether to show function parameter name inlay hints at the call site. | 76 | Whether to show function parameter name inlay hints at the call site. |
77 | rust-analyzer.inlayHints.typeHints (default: `true`):: | 77 | rust-analyzer.inlayHints.typeHints (default: `true`):: |
@@ -87,20 +87,20 @@ rust-analyzer.lens.run (default: `true`):: | |||
87 | rust-analyzer.lens.methodReferences (default: `false`):: | 87 | rust-analyzer.lens.methodReferences (default: `false`):: |
88 | Whether to show `Method References` lens. Only applies when `#rust-analyzer.lens.enable#` is set. | 88 | Whether to show `Method References` lens. Only applies when `#rust-analyzer.lens.enable#` is set. |
89 | rust-analyzer.linkedProjects (default: `[]`):: | 89 | rust-analyzer.linkedProjects (default: `[]`):: |
90 | Disable project auto-discovery in favor of explicitly specified set of projects. \nElements must be paths pointing to Cargo.toml, rust-project.json, or JSON objects in rust-project.json format. | 90 | Disable project auto-discovery in favor of explicitly specified set of projects.\n\nElements must be paths pointing to `Cargo.toml`, `rust-project.json`, or JSON objects in `rust-project.json` format. |
91 | rust-analyzer.lruCapacity (default: `null`):: | 91 | rust-analyzer.lruCapacity (default: `null`):: |
92 | Number of syntax trees rust-analyzer keeps in memory. | 92 | Number of syntax trees rust-analyzer keeps in memory. Defaults to 128. |
93 | rust-analyzer.notifications.cargoTomlNotFound (default: `true`):: | 93 | rust-analyzer.notifications.cargoTomlNotFound (default: `true`):: |
94 | Whether to show `can't find Cargo.toml` error message. | 94 | Whether to show `can't find Cargo.toml` error message. |
95 | rust-analyzer.procMacro.enable (default: `false`):: | 95 | rust-analyzer.procMacro.enable (default: `false`):: |
96 | Enable Proc macro support, cargo.loadOutDirsFromCheck must be enabled. | 96 | Enable Proc macro support, `#rust-analyzer.cargo.loadOutDirsFromCheck#` must be enabled. |
97 | rust-analyzer.runnables.overrideCargo (default: `null`):: | 97 | rust-analyzer.runnables.overrideCargo (default: `null`):: |
98 | Command to be executed instead of 'cargo' for runnables. | 98 | Command to be executed instead of 'cargo' for runnables. |
99 | rust-analyzer.runnables.cargoExtraArgs (default: `[]`):: | 99 | rust-analyzer.runnables.cargoExtraArgs (default: `[]`):: |
100 | Additional arguments to be passed to cargo for runnables such as tests or binaries.\nFor example, it may be '--release'. | 100 | Additional arguments to be passed to cargo for runnables such as tests or binaries.\nFor example, it may be `--release`. |
101 | rust-analyzer.rustcSource (default: `null`):: | 101 | rust-analyzer.rustcSource (default: `null`):: |
102 | Path to the rust compiler sources, for usage in rustc_private projects. | 102 | Path to the rust compiler sources, for usage in rustc_private projects. |
103 | rust-analyzer.rustfmt.extraArgs (default: `[]`):: | 103 | rust-analyzer.rustfmt.extraArgs (default: `[]`):: |
104 | Additional arguments to rustfmt. | 104 | Additional arguments to `rustfmt`. |
105 | rust-analyzer.rustfmt.overrideCommand (default: `null`):: | 105 | rust-analyzer.rustfmt.overrideCommand (default: `null`):: |
106 | Advanced option, fully override the command rust-analyzer uses for formatting. | 106 | Advanced option, fully override the command rust-analyzer uses for formatting. |
diff --git a/docs/user/manual.adoc b/docs/user/manual.adoc index 1ec6e81bb..e3082d584 100644 --- a/docs/user/manual.adoc +++ b/docs/user/manual.adoc | |||
@@ -46,8 +46,8 @@ You can install the latest release of the plugin from | |||
46 | https://marketplace.visualstudio.com/items?itemName=matklad.rust-analyzer[the marketplace]. | 46 | https://marketplace.visualstudio.com/items?itemName=matklad.rust-analyzer[the marketplace]. |
47 | 47 | ||
48 | Note that the plugin may cause conflicts with the | 48 | Note that the plugin may cause conflicts with the |
49 | https://marketplace.visualstudio.com/items?itemName=rust-lang.rust[official Rust plugin]. It is | 49 | https://marketplace.visualstudio.com/items?itemName=rust-lang.rust[official Rust plugin]. |
50 | recommended to disable the Rust plugin when using the rust-analyzer extension. | 50 | It is recommended to disable the Rust plugin when using the rust-analyzer extension. |
51 | 51 | ||
52 | By default, the plugin will prompt you to download the matching version of the server as well: | 52 | By default, the plugin will prompt you to download the matching version of the server as well: |
53 | 53 | ||
@@ -74,18 +74,21 @@ Note that we only support two most recent versions of VS Code. | |||
74 | 74 | ||
75 | ==== Updates | 75 | ==== Updates |
76 | 76 | ||
77 | The extension will be updated automatically as new versions become available. It will ask your permission to download the matching language server version binary if needed. | 77 | The extension will be updated automatically as new versions become available. |
78 | It will ask your permission to download the matching language server version binary if needed. | ||
78 | 79 | ||
79 | ===== Nightly | 80 | ===== Nightly |
80 | 81 | ||
81 | We ship nightly releases for VS Code. To help us out with testing the newest code and follow the bleeding edge of our `master`, please use the following config: | 82 | We ship nightly releases for VS Code. |
83 | To help us out with testing the newest code and follow the bleeding edge of our `master`, please use the following config: | ||
82 | 84 | ||
83 | [source,json] | 85 | [source,json] |
84 | ---- | 86 | ---- |
85 | { "rust-analyzer.updates.channel": "nightly" } | 87 | { "rust-analyzer.updates.channel": "nightly" } |
86 | ---- | 88 | ---- |
87 | 89 | ||
88 | You will be prompted to install the `nightly` extension version. Just click `Download now` and from that moment you will get automatic updates every 24 hours. | 90 | You will be prompted to install the `nightly` extension version. |
91 | Just click `Download now` and from that moment you will get automatic updates every 24 hours. | ||
89 | 92 | ||
90 | If you don't want to be asked for `Download now` every day when the new nightly version is released add the following to your `settings.json`: | 93 | If you don't want to be asked for `Download now` every day when the new nightly version is released add the following to your `settings.json`: |
91 | [source,json] | 94 | [source,json] |
@@ -160,7 +163,8 @@ $ chmod +x ~/.local/bin/rust-analyzer | |||
160 | 163 | ||
161 | Ensure `~/.local/bin` is listed in the `$PATH` variable. | 164 | Ensure `~/.local/bin` is listed in the `$PATH` variable. |
162 | 165 | ||
163 | Alternatively, you can install it from source using the following command: | 166 | Alternatively, you can install it from source using the command below. |
167 | You'll need the latest stable version of the Rust toolchain. | ||
164 | 168 | ||
165 | [source,bash] | 169 | [source,bash] |
166 | ---- | 170 | ---- |
@@ -198,7 +202,8 @@ Emacs support is maintained as part of the https://github.com/emacs-lsp/lsp-mode | |||
198 | 202 | ||
199 | === Vim/NeoVim | 203 | === Vim/NeoVim |
200 | 204 | ||
201 | Prerequisites: You have installed the <<rust-analyzer-language-server-binary,`rust-analyzer` binary>>. Not needed if the extension can install/update it on its own, coc-rust-analyzer is one example. | 205 | Prerequisites: You have installed the <<rust-analyzer-language-server-binary,`rust-analyzer` binary>>. |
206 | Not needed if the extension can install/update it on its own, coc-rust-analyzer is one example. | ||
202 | 207 | ||
203 | The are several LSP client implementations for vim or neovim: | 208 | The are several LSP client implementations for vim or neovim: |
204 | 209 | ||
@@ -270,14 +275,16 @@ Once `neovim/nvim-lspconfig` is installed, use `+lua require'nvim_lsp'.rust_anal | |||
270 | 275 | ||
271 | Prerequisites: You have installed the <<rust-analyzer-language-server-binary,`rust-analyzer` binary>>. | 276 | Prerequisites: You have installed the <<rust-analyzer-language-server-binary,`rust-analyzer` binary>>. |
272 | 277 | ||
273 | You also need the `LSP` package. To install it: | 278 | You also need the `LSP` package. |
279 | To install it: | ||
274 | 280 | ||
275 | 1. If you've never installed a Sublime Text package, install Package Control: | 281 | 1. If you've never installed a Sublime Text package, install Package Control: |
276 | * Open the command palette (Win/Linux: `ctrl+shift+p`, Mac: `cmd+shift+p`) | 282 | * Open the command palette (Win/Linux: `ctrl+shift+p`, Mac: `cmd+shift+p`) |
277 | * Type `Install Package Control`, press enter | 283 | * Type `Install Package Control`, press enter |
278 | 2. In the command palette, run `Package control: Install package`, and in the list that pops up, type `LSP` and press enter. | 284 | 2. In the command palette, run `Package control: Install package`, and in the list that pops up, type `LSP` and press enter. |
279 | 285 | ||
280 | Finally, with your Rust project open, in the command palette, run `LSP: Enable Language Server In Project` or `LSP: Enable Language Server Globally`, then select `rust-analyzer` in the list that pops up to enable the rust-analyzer LSP. The latter means that rust-analyzer is enabled by default in Rust projects. | 286 | Finally, with your Rust project open, in the command palette, run `LSP: Enable Language Server In Project` or `LSP: Enable Language Server Globally`, then select `rust-analyzer` in the list that pops up to enable the rust-analyzer LSP. |
287 | The latter means that rust-analyzer is enabled by default in Rust projects. | ||
281 | 288 | ||
282 | If it worked, you should see "rust-analyzer, Line X, Column Y" on the left side of the bottom bar, and after waiting a bit, functionality like tooltips on hovering over variables should become available. | 289 | If it worked, you should see "rust-analyzer, Line X, Column Y" on the left side of the bottom bar, and after waiting a bit, functionality like tooltips on hovering over variables should become available. |
283 | 290 | ||
@@ -285,7 +292,8 @@ If you get an error saying `No such file or directory: 'rust-analyzer'`, see the | |||
285 | 292 | ||
286 | === GNOME Builder | 293 | === GNOME Builder |
287 | 294 | ||
288 | GNOME Builder 3.37.1 and newer has native `rust-analyzer` support. If the LSP binary is not available, GNOME Builder can install it when opening a Rust file. | 295 | GNOME Builder 3.37.1 and newer has native `rust-analyzer` support. |
296 | If the LSP binary is not available, GNOME Builder can install it when opening a Rust file. | ||
289 | 297 | ||
290 | == Configuration | 298 | == Configuration |
291 | 299 | ||
@@ -294,6 +302,9 @@ GNOME Builder 3.37.1 and newer has native `rust-analyzer` support. If the LSP bi | |||
294 | rust-analyzer is configured via LSP messages, which means that it's up to the editor to decide on the exact format and location of configuration files. | 302 | rust-analyzer is configured via LSP messages, which means that it's up to the editor to decide on the exact format and location of configuration files. |
295 | Please consult your editor's documentation to learn how to configure LSP servers. | 303 | Please consult your editor's documentation to learn how to configure LSP servers. |
296 | 304 | ||
305 | To verify which configuration is actually used by rust-analyzer, set `RA_LOG` environment variable to `rust_analyzer=info` and look for config-related messages. | ||
306 | Logs should show both the JSON that rust-analyzer sees as well as the updated config. | ||
307 | |||
297 | This is the list of config options rust-analyzer supports: | 308 | This is the list of config options rust-analyzer supports: |
298 | 309 | ||
299 | include::./generated_config.adoc[] | 310 | include::./generated_config.adoc[] |
@@ -413,8 +424,8 @@ include::./generated_diagnostic.adoc[] | |||
413 | 424 | ||
414 | ==== Color configurations | 425 | ==== Color configurations |
415 | 426 | ||
416 | It is possible to change the foreground/background color of inlay hints. Just add this to your | 427 | It is possible to change the foreground/background color of inlay hints. |
417 | `settings.json`: | 428 | Just add this to your `settings.json`: |
418 | 429 | ||
419 | [source,jsonc] | 430 | [source,jsonc] |
420 | ---- | 431 | ---- |
@@ -436,7 +447,8 @@ It is possible to change the foreground/background color of inlay hints. Just ad | |||
436 | 447 | ||
437 | ==== Semantic style customizations | 448 | ==== Semantic style customizations |
438 | 449 | ||
439 | You can customize the look of different semantic elements in the source code. For example, mutable bindings are underlined by default and you can override this behavior by adding the following section to your `settings.json`: | 450 | You can customize the look of different semantic elements in the source code. |
451 | For example, mutable bindings are underlined by default and you can override this behavior by adding the following section to your `settings.json`: | ||
440 | 452 | ||
441 | [source,jsonc] | 453 | [source,jsonc] |
442 | ---- | 454 | ---- |
@@ -452,7 +464,9 @@ You can customize the look of different semantic elements in the source code. Fo | |||
452 | ---- | 464 | ---- |
453 | 465 | ||
454 | ==== Special `when` clause context for keybindings. | 466 | ==== Special `when` clause context for keybindings. |
455 | You may use `inRustProject` context to configure keybindings for rust projects only. For example: | 467 | You may use `inRustProject` context to configure keybindings for rust projects only. |
468 | For example: | ||
469 | |||
456 | [source,json] | 470 | [source,json] |
457 | ---- | 471 | ---- |
458 | { | 472 | { |
@@ -491,7 +505,8 @@ Or it is possible to specify vars more granularly: | |||
491 | ] | 505 | ] |
492 | ``` | 506 | ``` |
493 | 507 | ||
494 | You can use any valid RegExp as a mask. Also note that a full runnable name is something like *run bin_or_example_name*, *test some::mod::test_name* or *test-mod some::mod*, so it is possible to distinguish binaries, single tests, and test modules with this masks: `"^run"`, `"^test "` (the trailing space matters!), and `"^test-mod"` respectively. | 508 | You can use any valid regular expression as a mask. |
509 | Also note that a full runnable name is something like *run bin_or_example_name*, *test some::mod::test_name* or *test-mod some::mod*, so it is possible to distinguish binaries, single tests, and test modules with this masks: `"^run"`, `"^test "` (the trailing space matters!), and `"^test-mod"` respectively. | ||
495 | 510 | ||
496 | ==== Compiler feedback from external commands | 511 | ==== Compiler feedback from external commands |
497 | 512 | ||