diff options
Diffstat (limited to 'docs/user')
-rw-r--r-- | docs/user/README.md | 59 | ||||
-rw-r--r-- | docs/user/assists.md | 46 |
2 files changed, 74 insertions, 31 deletions
diff --git a/docs/user/README.md b/docs/user/README.md index 9d3258c06..3da30a193 100644 --- a/docs/user/README.md +++ b/docs/user/README.md | |||
@@ -5,8 +5,7 @@ install lsp server, clone the repository and then run `cargo xtask install | |||
5 | ./crates/ra_lsp_server`). This will produce a binary named `ra_lsp_server` which | 5 | ./crates/ra_lsp_server`). This will produce a binary named `ra_lsp_server` which |
6 | you should be able to use it with any LSP-compatible editor. We use custom | 6 | you should be able to use it with any LSP-compatible editor. We use custom |
7 | extensions to LSP, so special client-side support is required to take full | 7 | extensions to LSP, so special client-side support is required to take full |
8 | advantage of rust-analyzer. This repository contains support code for VS Code | 8 | advantage of rust-analyzer. This repository contains support code for VS Code. |
9 | and Emacs. | ||
10 | 9 | ||
11 | ``` | 10 | ``` |
12 | $ git clone [email protected]:rust-analyzer/rust-analyzer && cd rust-analyzer | 11 | $ git clone [email protected]:rust-analyzer/rust-analyzer && cd rust-analyzer |
@@ -32,7 +31,38 @@ a minimum version of 10 installed. Please refer to | |||
32 | You will also need the most recent version of VS Code: we don't try to | 31 | You will also need the most recent version of VS Code: we don't try to |
33 | maintain compatibility with older versions yet. | 32 | maintain compatibility with older versions yet. |
34 | 33 | ||
35 | The experimental VS Code plugin can then be built and installed by executing the | 34 | ### Installation from prebuilt binaries |
35 | |||
36 | We ship prebuilt binaries for Linux, Mac and Windows via | ||
37 | [GitHub releases](https://github.com/rust-analyzer/rust-analyzer/releases). | ||
38 | In order to use them you need to install the client VSCode extension. | ||
39 | |||
40 | Publishing to VSCode marketplace is currently WIP. Thus, you need to clone the repository and install **only** the client extension via | ||
41 | ``` | ||
42 | $ git clone https://github.com/rust-analyzer/rust-analyzer.git --depth 1 | ||
43 | $ cd rust-analyzer | ||
44 | $ cargo xtask install --client-code | ||
45 | ``` | ||
46 | Then open VSCode (or reload the window if it was already running), open some Rust project and you should | ||
47 | see an info message pop-up. | ||
48 | |||
49 | |||
50 | <img height="140px" src="https://user-images.githubusercontent.com/36276403/74103174-a40df100-4b52-11ea-81f4-372c70797924.png" alt="Download now message"/> | ||
51 | |||
52 | |||
53 | Click `Download now`, wait until the progress is 100% and you are ready to go. | ||
54 | |||
55 | For updates you need to remove installed binary | ||
56 | ``` | ||
57 | rm -rf ${HOME}/.config/Code/User/globalStorage/matklad.rust-analyzer | ||
58 | ``` | ||
59 | |||
60 | `"Donwload latest language server"` command for VSCode and automatic updates detection is currently WIP. | ||
61 | |||
62 | |||
63 | ### Installation from sources | ||
64 | |||
65 | The experimental VS Code plugin can be built and installed by executing the | ||
36 | following commands: | 66 | following commands: |
37 | 67 | ||
38 | ``` | 68 | ``` |
@@ -47,6 +77,7 @@ doesn't, report bugs! | |||
47 | **Note** [#1831](https://github.com/rust-analyzer/rust-analyzer/issues/1831): If you are using the popular | 77 | **Note** [#1831](https://github.com/rust-analyzer/rust-analyzer/issues/1831): If you are using the popular |
48 | [Vim emulation plugin](https://github.com/VSCodeVim/Vim), you will likely | 78 | [Vim emulation plugin](https://github.com/VSCodeVim/Vim), you will likely |
49 | need to turn off the `rust-analyzer.enableEnhancedTyping` setting. | 79 | need to turn off the `rust-analyzer.enableEnhancedTyping` setting. |
80 | (// TODO: This configuration is no longer available, enhanced typing shoud be disabled via removing Enter key binding, [see this issue](https://github.com/rust-analyzer/rust-analyzer/issues/3051)) | ||
50 | 81 | ||
51 | If you have an unusual setup (for example, `code` is not in the `PATH`), you | 82 | If you have an unusual setup (for example, `code` is not in the `PATH`), you |
52 | should adapt these manual installation instructions: | 83 | should adapt these manual installation instructions: |
@@ -57,7 +88,7 @@ $ cd rust-analyzer | |||
57 | $ cargo install --path ./crates/ra_lsp_server/ --force --locked | 88 | $ cargo install --path ./crates/ra_lsp_server/ --force --locked |
58 | $ cd ./editors/code | 89 | $ cd ./editors/code |
59 | $ npm install | 90 | $ npm install |
60 | $ ./node_modules/vsce/out/vsce package | 91 | $ npm run package |
61 | $ code --install-extension ./rust-analyzer-0.1.0.vsix | 92 | $ code --install-extension ./rust-analyzer-0.1.0.vsix |
62 | ``` | 93 | ``` |
63 | 94 | ||
@@ -94,7 +125,7 @@ host. | |||
94 | * `rust-analyzer.highlightingOn`: enables experimental syntax highlighting. | 125 | * `rust-analyzer.highlightingOn`: enables experimental syntax highlighting. |
95 | Colors can be configured via `editor.tokenColorCustomizations`. | 126 | Colors can be configured via `editor.tokenColorCustomizations`. |
96 | As an example, [Pale Fire](https://github.com/matklad/pale-fire/) color scheme tweaks rust colors. | 127 | As an example, [Pale Fire](https://github.com/matklad/pale-fire/) color scheme tweaks rust colors. |
97 | * `rust-analyzer.enableEnhancedTyping`: by default, rust-analyzer intercepts. | 128 | * `rust-analyzer.enableEnhancedTyping`: by default, rust-analyzer intercepts the |
98 | `Enter` key to make it easier to continue comments. Note that it may conflict with VIM emulation plugin. | 129 | `Enter` key to make it easier to continue comments. Note that it may conflict with VIM emulation plugin. |
99 | * `rust-analyzer.raLspServerPath`: path to `ra_lsp_server` executable | 130 | * `rust-analyzer.raLspServerPath`: path to `ra_lsp_server` executable |
100 | * `rust-analyzer.enableCargoWatchOnStartup`: prompt to install & enable `cargo | 131 | * `rust-analyzer.enableCargoWatchOnStartup`: prompt to install & enable `cargo |
@@ -130,17 +161,12 @@ host. | |||
130 | 161 | ||
131 | ## Emacs | 162 | ## Emacs |
132 | 163 | ||
133 | Prerequisites: | 164 | * install recent version of `emacs-lsp` package by following the instructions [here][emacs-lsp] |
134 | 165 | * set `lsp-rust-server` to `'rust-analyzer` | |
135 | `emacs-lsp`, `dash` and `ht` packages. | 166 | * run `lsp` in a Rust buffer |
136 | 167 | * (Optionally) bind commands like `lsp-rust-analyzer-join-lines`, `lsp-extend-selection` and `lsp-rust-analyzer-expand-macro` to keys | |
137 | Installation: | ||
138 | 168 | ||
139 | * add | 169 | [emacs-lsp]: https://github.com/emacs-lsp/lsp-mode |
140 | [rust-analyzer.el](../../editors/emacs/rust-analyzer.el) | ||
141 | to load path and require it in `init.el` | ||
142 | * run `lsp` in a rust buffer | ||
143 | * (Optionally) bind commands like `rust-analyzer-join-lines`, `rust-analyzer-extend-selection` and `rust-analyzer-expand-macro` to keys, and enable `rust-analyzer-inlay-hints-mode` to get inline type hints | ||
144 | 170 | ||
145 | 171 | ||
146 | ## Vim and NeoVim (coc-rust-analyzer) | 172 | ## Vim and NeoVim (coc-rust-analyzer) |
@@ -173,8 +199,7 @@ let g:LanguageClient_serverCommands = { | |||
173 | 199 | ||
174 | NeoVim 0.5 (not yet released) has built in language server support. For a quick start configuration | 200 | NeoVim 0.5 (not yet released) has built in language server support. For a quick start configuration |
175 | of rust-analyzer, use [neovim/nvim-lsp](https://github.com/neovim/nvim-lsp#rust_analyzer). | 201 | of rust-analyzer, use [neovim/nvim-lsp](https://github.com/neovim/nvim-lsp#rust_analyzer). |
176 | Once `neovim/nvim-lsp` is installed, you can use `call nvim_lsp#setup("rust_analyzer", {})` | 202 | Once `neovim/nvim-lsp` is installed, use `lua require'nvim_lsp'.rust_analyzer.setup({})` in your `init.vim`. |
177 | or `lua require'nvim_lsp'.rust_analyzer.setup({})` to quickly get set up. | ||
178 | 203 | ||
179 | 204 | ||
180 | ## Sublime Text 3 | 205 | ## Sublime Text 3 |
diff --git a/docs/user/assists.md b/docs/user/assists.md index ecf206f71..f737a2fa4 100644 --- a/docs/user/assists.md +++ b/docs/user/assists.md | |||
@@ -154,20 +154,6 @@ impl Trait<u32> for () { | |||
154 | } | 154 | } |
155 | ``` | 155 | ``` |
156 | 156 | ||
157 | ## `add_import` | ||
158 | |||
159 | Adds a use statement for a given fully-qualified path. | ||
160 | |||
161 | ```rust | ||
162 | // BEFORE | ||
163 | fn process(map: std::collections::┃HashMap<String, String>) {} | ||
164 | |||
165 | // AFTER | ||
166 | use std::collections::HashMap; | ||
167 | |||
168 | fn process(map: HashMap<String, String>) {} | ||
169 | ``` | ||
170 | |||
171 | ## `add_new` | 157 | ## `add_new` |
172 | 158 | ||
173 | Adds a new inherent impl for a type. | 159 | Adds a new inherent impl for a type. |
@@ -209,6 +195,24 @@ fn main() { | |||
209 | } | 195 | } |
210 | ``` | 196 | ``` |
211 | 197 | ||
198 | ## `auto_import` | ||
199 | |||
200 | If the name is unresolved, provides all possible imports for it. | ||
201 | |||
202 | ```rust | ||
203 | // BEFORE | ||
204 | fn main() { | ||
205 | let map = HashMap┃::new(); | ||
206 | } | ||
207 | |||
208 | // AFTER | ||
209 | use std::collections::HashMap; | ||
210 | |||
211 | fn main() { | ||
212 | let map = HashMap::new(); | ||
213 | } | ||
214 | ``` | ||
215 | |||
212 | ## `change_visibility` | 216 | ## `change_visibility` |
213 | 217 | ||
214 | Adds or changes existing visibility specifier. | 218 | Adds or changes existing visibility specifier. |
@@ -550,6 +554,20 @@ fn handle(action: Action) { | |||
550 | } | 554 | } |
551 | ``` | 555 | ``` |
552 | 556 | ||
557 | ## `replace_qualified_name_with_use` | ||
558 | |||
559 | Adds a use statement for a given fully-qualified name. | ||
560 | |||
561 | ```rust | ||
562 | // BEFORE | ||
563 | fn process(map: std::collections::┃HashMap<String, String>) {} | ||
564 | |||
565 | // AFTER | ||
566 | use std::collections::HashMap; | ||
567 | |||
568 | fn process(map: HashMap<String, String>) {} | ||
569 | ``` | ||
570 | |||
553 | ## `split_import` | 571 | ## `split_import` |
554 | 572 | ||
555 | Wraps the tail of import into braces. | 573 | Wraps the tail of import into braces. |