diff options
author | Aleksey Kladov <[email protected]> | 2020-05-31 10:29:19 +0100 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2020-05-31 10:29:19 +0100 |
commit | 1c6a2eb14a84c3a66972d1a6da429cca1aa8b40a (patch) | |
tree | adc80cc0840911ca3aa86fd03fff6e49d99cc821 /docs/user/features.md | |
parent | b795a07320e13bcbedb6435bcfddb3ecd0ed2bde (diff) |
Move the rest of the features to generated docs
Diffstat (limited to 'docs/user/features.md')
-rw-r--r-- | docs/user/features.md | 96 |
1 files changed, 0 insertions, 96 deletions
diff --git a/docs/user/features.md b/docs/user/features.md deleted file mode 100644 index ff8cb2d6e..000000000 --- a/docs/user/features.md +++ /dev/null | |||
@@ -1,96 +0,0 @@ | |||
1 | This document is an index of features that the rust-analyzer language server | ||
2 | provides. Shortcuts are for the default VS Code layout. If there's no shortcut, | ||
3 | you can use <kbd>Ctrl+Shift+P</kbd> to search for the corresponding action. | ||
4 | |||
5 | ### Commands <kbd>ctrl+shift+p</kbd> | ||
6 | |||
7 | |||
8 | #### Toggle inlay hints | ||
9 | |||
10 | Toggle inlay hints view for the current workspace. | ||
11 | It is recommended to assign a shortcut for this command to quickly turn off | ||
12 | inlay hints when they prevent you from reading/writing the code. | ||
13 | |||
14 | ### Magic Completions | ||
15 | |||
16 | In addition to usual reference completion, rust-analyzer provides some ✨magic✨ | ||
17 | completions as well: | ||
18 | |||
19 | Keywords like `if`, `else` `while`, `loop` are completed with braces, and cursor | ||
20 | is placed at the appropriate position. Even though `if` is easy to type, you | ||
21 | still want to complete it, to get ` { }` for free! `return` is inserted with a | ||
22 | space or `;` depending on the return type of the function. | ||
23 | |||
24 | When completing a function call, `()` are automatically inserted. If a function | ||
25 | takes arguments, the cursor is positioned inside the parenthesis. | ||
26 | |||
27 | There are postfix completions, which can be triggered by typing something like | ||
28 | `foo().if`. The word after `.` determines postfix completion. Possible variants are: | ||
29 | |||
30 | - `expr.if` -> `if expr {}` or `if let ... {}` for `Option` or `Result` | ||
31 | - `expr.match` -> `match expr {}` | ||
32 | - `expr.while` -> `while expr {}` or `while let ... {}` for `Option` or `Result` | ||
33 | - `expr.ref` -> `&expr` | ||
34 | - `expr.refm` -> `&mut expr` | ||
35 | - `expr.not` -> `!expr` | ||
36 | - `expr.dbg` -> `dbg!(expr)` | ||
37 | |||
38 | There also snippet completions: | ||
39 | |||
40 | #### Inside Expressions | ||
41 | |||
42 | - `pd` -> `println!("{:?}")` | ||
43 | - `ppd` -> `println!("{:#?}")` | ||
44 | |||
45 | #### Inside Modules | ||
46 | |||
47 | - `tfn` -> `#[test] fn f(){}` | ||
48 | - `tmod` -> | ||
49 | ```rust | ||
50 | #[cfg(test)] | ||
51 | mod tests { | ||
52 | use super::*; | ||
53 | |||
54 | #[test] | ||
55 | fn test_fn() {} | ||
56 | } | ||
57 | ``` | ||
58 | |||
59 | ### Code Highlighting | ||
60 | |||
61 | Experimental feature to let rust-analyzer highlight Rust code instead of using the | ||
62 | default highlighter. | ||
63 | |||
64 | #### Rainbow Highlighting | ||
65 | |||
66 | Experimental feature that, given code highlighting using rust-analyzer is | ||
67 | active, will pick unique colors for identifiers. | ||
68 | |||
69 | ### Code hints | ||
70 | |||
71 | Rust-analyzer has two types of hints to show the information about the code: | ||
72 | |||
73 | * hover hints, appearing on hover on any element. | ||
74 | |||
75 | These contain extended information on the hovered language item. | ||
76 | |||
77 | * inlay hints, shown near the element hinted directly in the editor. | ||
78 | |||
79 | Two types of inlay hints are displayed currently: | ||
80 | |||
81 | * type hints, displaying the minimal information on the type of the expression (if the information is available) | ||
82 | * method chaining hints, type information for multi-line method chains | ||
83 | * parameter name hints, displaying the names of the parameters in the corresponding methods | ||
84 | |||
85 | #### VS Code | ||
86 | |||
87 | In VS Code, the following settings can be used to configure the inlay hints: | ||
88 | |||
89 | * `rust-analyzer.inlayHints.typeHints` - enable hints for inferred types. | ||
90 | * `rust-analyzer.inlayHints.chainingHints` - enable hints for inferred types on method chains. | ||
91 | * `rust-analyzer.inlayHints.parameterHints` - enable hints for function parameters. | ||
92 | * `rust-analyzer.inlayHints.maxLength` — shortens the hints if their length exceeds the value specified. If no value is specified (`null`), no shortening is applied. | ||
93 | |||
94 | **Note:** VS Code does not have native support for inlay hints [yet](https://github.com/microsoft/vscode/issues/16221) and the hints are implemented using decorations. | ||
95 | This approach has limitations, the caret movement and bracket highlighting near the edges of the hint may be weird: | ||
96 | [1](https://github.com/rust-analyzer/rust-analyzer/issues/1623), [2](https://github.com/rust-analyzer/rust-analyzer/issues/3453). | ||