1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
|
To install experimental VS Code plugin:
```
$ git clone https://github.com/rust-analyzer/rust-analyzer.git
$ cd rust-analyzer
$ cargo install-code
```
This will run `cargo install --packge ra_lsp_server` to install the
server binary into `~/.cargo/bin`, and then will build and install
plugin from `editors/code`. See
[this](https://github.com/matklad/rust-analyzer/blob/cc76b0d31d8ba013c499dd3a4ca69b37004795e6/crates/tools/src/main.rs#L192)
for details
It's better to remove existing Rust plugins to avoid interference.
### Features:
* syntax highlighting (LSP does not have API for it, so impl is hacky
and sometimes fall-backs to the horrible built-in highlighting)
* **Go to symbol in workspace** (`ctrl+t`)
- `#Foo` searches for `Foo` type in the current workspace
- `#foo#` searches for `foo` function in the current workspace
- `#Foo*` searches for `Foo` type among dependencies, excluding `stdlib`
- Sorry for a weired UI, neither LSP, not VSCode have any sane API for filtering! :)
* **Go to symbol in file** (`alt+shift+o`)
* **Go to definition** ("correct" for `mod foo;` decls, approximate for other things).
* commands (`ctrl+shift+p` or keybindings)
- **Show Rust Syntax Tree** (use it to verify that plugin works)
- **Rust Extend Selection**. Extends the current selection to the
encompassing syntactic construct (expression, statement, item,
module, etc). It works with multiple cursors. Do bind this command
to a key, its super-useful!
- **Rust Matching Brace**. If the cursor is on any brace
(`<>(){}[]`) which is a part of a brace-pair, moves cursor to the
matching brace.
- **Rust Parent Module**. Navigate to the parent module of the current module
- **Rust Join Lines**. Join selected lines into one, smartly fixing
up whitespace and trailing commas.
- **Run test at caret**. When cursor is inside a function marked
`#[test]`, this action runs this specific test. If the cursor is
outside of the test function, this re-runs the last test. Do bind
this to a shortcut!
- **Format document**. Formats the current file with rustfmt.
Rustfmt must be installed separately with `rustup component add rustfmt`.
* Typing assists
- typing `let =` tries to smartly add `;` if `=` is followed by an existing expression.
- Enter inside comments continues comment (`<|>` signifies cursor position):
```
/// Docs<|>
fn foo() {}
```
```
/// Docs
/// <|>
fn foo() {}
```
* code actions (use `ctrl+.` to activate).
- Flip `,`
```
// before:
fn foo(x: usize,<|> dim: (usize, usize))
// after:
fn foo(dim: (usize, usize), x: usize)
```
- Add `#[derive]`
```
// before:
struct Foo {
<|>x: i32
}
// after:
#[derive(<|>)]
struct Foo {
x: i32
}
```
- Add `impl`
```
// before:
struct Foo<'a, T: Debug> {
<|>t: T
}
// after:
struct Foo<'a, T: Debug> {
t: T
}
impl<'a, T: Debug> Foo<'a, T> {
<|>
}
```
|