diff options
Diffstat (limited to 'docs')
-rw-r--r-- | docs/user/features.md | 30 | ||||
-rw-r--r-- | docs/user/readme.adoc | 19 |
2 files changed, 24 insertions, 25 deletions
diff --git a/docs/user/features.md b/docs/user/features.md index a00fa35da..f705e5115 100644 --- a/docs/user/features.md +++ b/docs/user/features.md | |||
@@ -1,10 +1,10 @@ | |||
1 | This documents is an index of features that rust-analyzer language server | 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, | 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. | 3 | you can use <kbd>Ctrl+Shift+P</kbd> to search for the corresponding action. |
4 | 4 | ||
5 | ### Workspace Symbol <kbd>ctrl+t</kbd> | 5 | ### Workspace Symbol <kbd>ctrl+t</kbd> |
6 | 6 | ||
7 | Uses fuzzy-search to find types, modules and function by name across your | 7 | Uses fuzzy-search to find types, modules and functions by name across your |
8 | project and dependencies. This is **the** most useful feature, which improves code | 8 | project and dependencies. This is **the** most useful feature, which improves code |
9 | navigation tremendously. It mostly works on top of the built-in LSP | 9 | navigation tremendously. It mostly works on top of the built-in LSP |
10 | functionality, however `#` and `*` symbols can be used to narrow down the | 10 | functionality, however `#` and `*` symbols can be used to narrow down the |
@@ -13,7 +13,7 @@ search. Specifically, | |||
13 | - `Foo` searches for `Foo` type in the current workspace | 13 | - `Foo` searches for `Foo` type in the current workspace |
14 | - `foo#` searches for `foo` function in the current workspace | 14 | - `foo#` searches for `foo` function in the current workspace |
15 | - `Foo*` searches for `Foo` type among dependencies, including `stdlib` | 15 | - `Foo*` searches for `Foo` type among dependencies, including `stdlib` |
16 | - `foo#*` searches for `foo` function among dependencies. | 16 | - `foo#*` searches for `foo` function among dependencies |
17 | 17 | ||
18 | That is, `#` switches from "types" to all symbols, `*` switches from the current | 18 | That is, `#` switches from "types" to all symbols, `*` switches from the current |
19 | workspace to dependencies. | 19 | workspace to dependencies. |
@@ -30,7 +30,7 @@ Provides a tree of the symbols defined in the file. Can be used to | |||
30 | 30 | ||
31 | Some features trigger on typing certain characters: | 31 | Some features trigger on typing certain characters: |
32 | 32 | ||
33 | - typing `let =` tries to smartly add `;` if `=` is followed by an existing expression. | 33 | - typing `let =` tries to smartly add `;` if `=` is followed by an existing expression |
34 | - Enter inside comments automatically inserts `///` | 34 | - Enter inside comments automatically inserts `///` |
35 | - typing `.` in a chain method call auto-indents | 35 | - typing `.` in a chain method call auto-indents |
36 | 36 | ||
@@ -58,7 +58,7 @@ Navigates to the type of an identifier. | |||
58 | 58 | ||
59 | #### Run | 59 | #### Run |
60 | 60 | ||
61 | Shows popup suggesting to run a test/benchmark/binary **at the current cursor | 61 | Shows a popup suggesting to run a test/benchmark/binary **at the current cursor |
62 | location**. Super useful for repeatedly running just a single test. Do bind this | 62 | location**. Super useful for repeatedly running just a single test. Do bind this |
63 | to a shortcut! | 63 | to a shortcut! |
64 | 64 | ||
@@ -87,15 +87,15 @@ Shows the full macro expansion of the macro at current cursor. | |||
87 | 87 | ||
88 | #### Status | 88 | #### Status |
89 | 89 | ||
90 | Shows internal statistic about memory usage of rust-analyzer | 90 | Shows internal statistic about memory usage of rust-analyzer. |
91 | 91 | ||
92 | #### Show RA Version | 92 | #### Show RA Version |
93 | 93 | ||
94 | Show current rust-analyzer version | 94 | Show current rust-analyzer version. |
95 | 95 | ||
96 | #### Run garbage collection | 96 | #### Run Garbage Collection |
97 | 97 | ||
98 | Manually triggers GC | 98 | Manually triggers GC. |
99 | 99 | ||
100 | #### Start Cargo Watch | 100 | #### Start Cargo Watch |
101 | 101 | ||
@@ -103,7 +103,7 @@ Start `cargo watch` for live error highlighting. Will prompt to install if it's | |||
103 | 103 | ||
104 | #### Stop Cargo Watch | 104 | #### Stop Cargo Watch |
105 | 105 | ||
106 | Stop `cargo watch` | 106 | Stop `cargo watch`. |
107 | 107 | ||
108 | ### Assists (Code Actions) | 108 | ### Assists (Code Actions) |
109 | 109 | ||
@@ -122,11 +122,11 @@ is placed at the appropriate position. Even though `if` is easy to type, you | |||
122 | still want to complete it, to get ` { }` for free! `return` is inserted with a | 122 | still want to complete it, to get ` { }` for free! `return` is inserted with a |
123 | space or `;` depending on the return type of the function. | 123 | space or `;` depending on the return type of the function. |
124 | 124 | ||
125 | When completing a function call, `()` are automatically inserted. If function | 125 | When completing a function call, `()` are automatically inserted. If a function |
126 | takes arguments, cursor is positioned inside the parenthesis. | 126 | takes arguments, the cursor is positioned inside the parenthesis. |
127 | 127 | ||
128 | There are postifx completions, which can be triggerd by typing something like | 128 | There are postifx completions, which can be triggerd by typing something like |
129 | `foo().if`. The word after `.` determines postifx completion, possible variants are: | 129 | `foo().if`. The word after `.` determines postifx completion. Possible variants are: |
130 | 130 | ||
131 | - `expr.if` -> `if expr {}` | 131 | - `expr.if` -> `if expr {}` |
132 | - `expr.match` -> `match expr {}` | 132 | - `expr.match` -> `match expr {}` |
@@ -147,12 +147,12 @@ There also snippet completions: | |||
147 | 147 | ||
148 | - `tfn` -> `#[test] fn f(){}` | 148 | - `tfn` -> `#[test] fn f(){}` |
149 | 149 | ||
150 | ### Code highlighting | 150 | ### Code Highlighting |
151 | 151 | ||
152 | Experimental feature to let rust-analyzer highlight Rust code instead of using the | 152 | Experimental feature to let rust-analyzer highlight Rust code instead of using the |
153 | default highlighter. | 153 | default highlighter. |
154 | 154 | ||
155 | #### Rainbow highlighting | 155 | #### Rainbow Highlighting |
156 | 156 | ||
157 | Experimental feature that, given code highlighting using rust-analyzer is | 157 | Experimental feature that, given code highlighting using rust-analyzer is |
158 | active, will pick unique colors for identifiers. | 158 | active, will pick unique colors for identifiers. |
diff --git a/docs/user/readme.adoc b/docs/user/readme.adoc index 74fda0abe..f1386a8f9 100644 --- a/docs/user/readme.adoc +++ b/docs/user/readme.adoc | |||
@@ -6,10 +6,10 @@ | |||
6 | 6 | ||
7 | // Master copy of this document lives in the https://github.com/rust-analyzer/rust-analyzer repository | 7 | // Master copy of this document lives in the https://github.com/rust-analyzer/rust-analyzer repository |
8 | 8 | ||
9 | At it's core, rust-analyzer is a *library* for semantic analysis of the Rust code as it changes over time. | 9 | At its core, rust-analyzer is a *library* for semantic analysis of Rust code as it changes over time. |
10 | This manual focuses on a specific usage of the library -- the implementation of | 10 | This manual focuses on a specific usage of the library -- the implementation of |
11 | https://microsoft.github.io/language-server-protocol/[Language Server Protocol]. | 11 | https://microsoft.github.io/language-server-protocol/[Language Server Protocol]. |
12 | LSP allows various code editors, like VS Code, Emacs or Vim, to implement semantic feature like completion or goto definition by talking to an external language server process. | 12 | LSP allows various code editors, like VS Code, Emacs or Vim, to implement semantic features like completion or goto definition by talking to an external language server process. |
13 | 13 | ||
14 | To improve this document, send a pull request against | 14 | To improve this document, send a pull request against |
15 | https://github.com/rust-analyzer/rust-analyzer/blob/master/docs/user/readme.adoc[this file]. | 15 | https://github.com/rust-analyzer/rust-analyzer/blob/master/docs/user/readme.adoc[this file]. |
@@ -36,10 +36,9 @@ https://github.com/rust-analyzer/rust-analyzer/tree/master/editors/code[in tree] | |||
36 | 36 | ||
37 | You can install the latest release of the plugin from | 37 | You can install the latest release of the plugin from |
38 | https://marketplace.visualstudio.com/items?itemName=matklad.rust-analyzer[the marketplace]. | 38 | https://marketplace.visualstudio.com/items?itemName=matklad.rust-analyzer[the marketplace]. |
39 | By default, the plugin will download the matching version of the server as well. | 39 | By default, the plugin will prompt you to download the matching version of the server as well: |
40 | 40 | ||
41 | // FIXME: update the image (its text has changed) | 41 | image::https://user-images.githubusercontent.com/9021944/75067008-17502500-54ba-11ea-835a-f92aac50e866.png[] |
42 | image::https://user-images.githubusercontent.com/36276403/74103174-a40df100-4b52-11ea-81f4-372c70797924.png[] | ||
43 | 42 | ||
44 | The server binary is stored in `~/.config/Code/User/globalStorage/matklad.rust-analyzer`. | 43 | The server binary is stored in `~/.config/Code/User/globalStorage/matklad.rust-analyzer`. |
45 | 44 | ||
@@ -60,7 +59,7 @@ $ cargo xtask install | |||
60 | ---- | 59 | ---- |
61 | 60 | ||
62 | You'll need Cargo, nodejs and npm for this. | 61 | You'll need Cargo, nodejs and npm for this. |
63 | To make VS Code use the freshly build server, add this to the settings: | 62 | To make VS Code use the freshly built server, add this to the settings: |
64 | 63 | ||
65 | [source,json] | 64 | [source,json] |
66 | ---- | 65 | ---- |
@@ -72,7 +71,7 @@ Note that installing via `xtask install` does not work for VS Code Remote, inste | |||
72 | === Language Server Binary | 71 | === Language Server Binary |
73 | 72 | ||
74 | Other editors generally require `rust-analyzer` binary to be in `$PATH`. | 73 | Other editors generally require `rust-analyzer` binary to be in `$PATH`. |
75 | You can download pre-build binary from | 74 | You can download the pre-built binary from |
76 | https://github.com/rust-analyzer/rust-analyzer/releases[releases] | 75 | https://github.com/rust-analyzer/rust-analyzer/releases[releases] |
77 | page, or you can install it from source using the following command: | 76 | page, or you can install it from source using the following command: |
78 | 77 | ||
@@ -85,7 +84,7 @@ $ cargo xtask install --server | |||
85 | 84 | ||
86 | Emacs support is maintained https://github.com/emacs-lsp/lsp-mode/blob/master/lsp-rust.el[upstream]. | 85 | Emacs support is maintained https://github.com/emacs-lsp/lsp-mode/blob/master/lsp-rust.el[upstream]. |
87 | 86 | ||
88 | 1. Install recent version of `emacs-lsp` package by following the instructions https://github.com/emacs-lsp/lsp-mode[here]. | 87 | 1. Install the most recent version of `emacs-lsp` package by following the instructions https://github.com/emacs-lsp/lsp-mode[here]. |
89 | 2. Set `lsp-rust-server` to `'rust-analyzer`. | 88 | 2. Set `lsp-rust-server` to `'rust-analyzer`. |
90 | 3. Run `lsp` in a Rust buffer. | 89 | 3. Run `lsp` in a Rust buffer. |
91 | 4. (Optionally) bind commands like `lsp-rust-analyzer-join-lines`, `lsp-extend-selection` and `lsp-rust-analyzer-expand-macro` to keys. | 90 | 4. (Optionally) bind commands like `lsp-rust-analyzer-join-lines`, `lsp-extend-selection` and `lsp-rust-analyzer-expand-macro` to keys. |
@@ -112,7 +111,7 @@ The are several LSP client implementations for vim: | |||
112 | https://github.com/autozimu/LanguageClient-neovim[here] | 111 | https://github.com/autozimu/LanguageClient-neovim[here] |
113 | * The github project wiki has extra tips on configuration | 112 | * The github project wiki has extra tips on configuration |
114 | 113 | ||
115 | 2. Configure by adding this to your vim/neovim config file (replacing the existing rust specific line if it exists): | 114 | 2. Configure by adding this to your vim/neovim config file (replacing the existing Rust-specific line if it exists): |
116 | + | 115 | + |
117 | [source,vim] | 116 | [source,vim] |
118 | ---- | 117 | ---- |
@@ -123,7 +122,7 @@ let g:LanguageClient_serverCommands = { | |||
123 | 122 | ||
124 | ==== nvim-lsp | 123 | ==== nvim-lsp |
125 | 124 | ||
126 | NeoVim 0.5 (not yet released) has built in language server support. | 125 | NeoVim 0.5 (not yet released) has built-in language server support. |
127 | For a quick start configuration of rust-analyzer, use https://github.com/neovim/nvim-lsp#rust_analyzer[neovim/nvim-lsp]. | 126 | For a quick start configuration of rust-analyzer, use https://github.com/neovim/nvim-lsp#rust_analyzer[neovim/nvim-lsp]. |
128 | Once `neovim/nvim-lsp` is installed, use `lua require'nvim_lsp'.rust_analyzer.setup({})` in your `init.vim`. | 127 | Once `neovim/nvim-lsp` is installed, use `lua require'nvim_lsp'.rust_analyzer.setup({})` in your `init.vim`. |
129 | 128 | ||