diff options
author | Aleksey Kladov <[email protected]> | 2018-09-16 13:36:09 +0100 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2018-09-16 13:36:09 +0100 |
commit | b5cb53ea93f2573b76515a0b651eeb13bb5a74f0 (patch) | |
tree | 193a7f6125a281a46093049148c0dc1b6a00cece /editors | |
parent | cc76b0d31d8ba013c499dd3a4ca69b37004795e6 (diff) |
tweak readme
Diffstat (limited to 'editors')
-rw-r--r-- | editors/README.md | 89 |
1 files changed, 89 insertions, 0 deletions
diff --git a/editors/README.md b/editors/README.md new file mode 100644 index 000000000..798c08581 --- /dev/null +++ b/editors/README.md | |||
@@ -0,0 +1,89 @@ | |||
1 | To install experimental VS Code plugin: | ||
2 | |||
3 | ``` | ||
4 | $ cargo install-code | ||
5 | ``` | ||
6 | |||
7 | This will run `cargo install --packge ra_lsp_server` to install the | ||
8 | server binary into `~/.cargo/bin`, and then will build and install | ||
9 | plugin from `editors/code`. See | ||
10 | [this](https://github.com/matklad/rust-analyzer/blob/cc76b0d31d8ba013c499dd3a4ca69b37004795e6/crates/tools/src/main.rs#L192) | ||
11 | for details | ||
12 | |||
13 | It's better to remove existing Rust plugins to avoid interference. | ||
14 | |||
15 | ### Features: | ||
16 | |||
17 | * syntax highlighting (LSP does not have API for it, so impl is hacky | ||
18 | and sometimes fall-backs to the horrible built-in highlighting) | ||
19 | |||
20 | * **Go to symbol in workspace** (`ctrl+t`) | ||
21 | - `#Foo` searches for `Foo` type in the current workspace | ||
22 | - `#foo#` searches for `foo` function in the current workspace | ||
23 | - `#Foo*` searches for `Foo` type among dependencies, excluding `stdlib` | ||
24 | - Sorry for a weired UI, neither LSP, not VSCode have any sane API for filtering! :) | ||
25 | |||
26 | * **Go to symbol in file** (`alt+shift+o`) | ||
27 | |||
28 | * **Go to definition** ("correct" for `mod foo;` decls, approximate for other things). | ||
29 | |||
30 | * commands (`ctrl+shift+p` or keybindings) | ||
31 | - **Show Rust Syntax Tree** (use it to verify that plugin works) | ||
32 | - **Rust Extend Selection**. Extends the current selection to the | ||
33 | encompassing syntactic construct (expression, statement, item, | ||
34 | module, etc). It works with multiple cursors. Do bind this command | ||
35 | to a key, its super-useful! | ||
36 | - **Rust Matching Brace**. If the cursor is on any brace | ||
37 | (`<>(){}[]`) which is a part of a brace-pair, moves cursor to the | ||
38 | matching brace. | ||
39 | - **Rust Parent Module**. Navigate to the parent module of the current module | ||
40 | - **Rust Join Lines**. Join selected lines into one, smartly fixing | ||
41 | up whitespace and trailing commas. | ||
42 | - **Run test at caret**. When cursor is inside a function marked | ||
43 | `#[test]`, this action runs this specific test. If the cursor is | ||
44 | outside of the test function, this re-runs the last test. Do bind | ||
45 | this to a shortcut! | ||
46 | |||
47 | * code actions (use `ctrl+.` to activate). | ||
48 | |||
49 | `<|>` signifies cursor position | ||
50 | |||
51 | - Flip `,` | ||
52 | |||
53 | ``` | ||
54 | // before: | ||
55 | fn foo(x: usize,<|> dim: (usize, usize)) | ||
56 | // after: | ||
57 | fn foo(dim: (usize, usize), x: usize) | ||
58 | ``` | ||
59 | |||
60 | - Add `#[derive]` | ||
61 | |||
62 | ``` | ||
63 | // before: | ||
64 | struct Foo { | ||
65 | <|>x: i32 | ||
66 | } | ||
67 | // after: | ||
68 | #[derive(<|>)] | ||
69 | struct Foo { | ||
70 | x: i32 | ||
71 | } | ||
72 | ``` | ||
73 | |||
74 | - Add `impl` | ||
75 | |||
76 | ``` | ||
77 | // before: | ||
78 | struct Foo<'a, T: Debug> { | ||
79 | <|>t: T | ||
80 | } | ||
81 | // after: | ||
82 | struct Foo<'a, T: Debug> { | ||
83 | t: T | ||
84 | } | ||
85 | |||
86 | impl<'a, T: Debug> Foo<'a, T> { | ||
87 | <|> | ||
88 | } | ||
89 | ``` | ||