aboutsummaryrefslogtreecommitdiff
path: root/docs/user/features.md
diff options
context:
space:
mode:
Diffstat (limited to 'docs/user/features.md')
-rw-r--r--docs/user/features.md96
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 @@
1This document is an index of features that the rust-analyzer language server
2provides. Shortcuts are for the default VS Code layout. If there's no shortcut,
3you 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
10Toggle inlay hints view for the current workspace.
11It is recommended to assign a shortcut for this command to quickly turn off
12inlay hints when they prevent you from reading/writing the code.
13
14### Magic Completions
15
16In addition to usual reference completion, rust-analyzer provides some ✨magic✨
17completions as well:
18
19Keywords like `if`, `else` `while`, `loop` are completed with braces, and cursor
20is placed at the appropriate position. Even though `if` is easy to type, you
21still want to complete it, to get ` { }` for free! `return` is inserted with a
22space or `;` depending on the return type of the function.
23
24When completing a function call, `()` are automatically inserted. If a function
25takes arguments, the cursor is positioned inside the parenthesis.
26
27There 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
38There 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)]
51mod tests {
52 use super::*;
53
54 #[test]
55 fn test_fn() {}
56}
57```
58
59### Code Highlighting
60
61Experimental feature to let rust-analyzer highlight Rust code instead of using the
62default highlighter.
63
64#### Rainbow Highlighting
65
66Experimental feature that, given code highlighting using rust-analyzer is
67active, will pick unique colors for identifiers.
68
69### Code hints
70
71Rust-analyzer has two types of hints to show the information about the code:
72
73* hover hints, appearing on hover on any element.
74
75These contain extended information on the hovered language item.
76
77* inlay hints, shown near the element hinted directly in the editor.
78
79Two 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
87In 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.
95This 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).