aboutsummaryrefslogtreecommitdiff
path: root/docs/user
diff options
context:
space:
mode:
Diffstat (limited to 'docs/user')
-rw-r--r--docs/user/assists.md22
-rw-r--r--docs/user/features.md4
-rw-r--r--docs/user/readme.adoc77
3 files changed, 84 insertions, 19 deletions
diff --git a/docs/user/assists.md b/docs/user/assists.md
index 6c6943622..ee515949e 100644
--- a/docs/user/assists.md
+++ b/docs/user/assists.md
@@ -175,7 +175,9 @@ trait Trait<T> {
175} 175}
176 176
177impl Trait<u32> for () { 177impl Trait<u32> for () {
178 fn foo(&self) -> u32 { todo!() } 178 fn foo(&self) -> u32 {
179 todo!()
180 }
179 181
180} 182}
181``` 183```
@@ -695,3 +697,21 @@ use std::┃collections::HashMap;
695// AFTER 697// AFTER
696use std::{collections::HashMap}; 698use std::{collections::HashMap};
697``` 699```
700
701## `unwrap_block`
702
703This assist removes if...else, for, while and loop control statements to just keep the body.
704
705```rust
706// BEFORE
707fn foo() {
708 if true {┃
709 println!("foo");
710 }
711}
712
713// AFTER
714fn foo() {
715 println!("foo");
716}
717```
diff --git a/docs/user/features.md b/docs/user/features.md
index 56d2969fd..b9a365fc1 100644
--- a/docs/user/features.md
+++ b/docs/user/features.md
@@ -140,8 +140,8 @@ space or `;` depending on the return type of the function.
140When completing a function call, `()` are automatically inserted. If a function 140When completing a function call, `()` are automatically inserted. If a function
141takes arguments, the cursor is positioned inside the parenthesis. 141takes arguments, the cursor is positioned inside the parenthesis.
142 142
143There are postifx completions, which can be triggerd by typing something like 143There are postfix completions, which can be triggered by typing something like
144`foo().if`. The word after `.` determines postifx completion. Possible variants are: 144`foo().if`. The word after `.` determines postfix completion. Possible variants are:
145 145
146- `expr.if` -> `if expr {}` 146- `expr.if` -> `if expr {}`
147- `expr.match` -> `match expr {}` 147- `expr.match` -> `match expr {}`
diff --git a/docs/user/readme.adoc b/docs/user/readme.adoc
index ce5704836..69f5b13d6 100644
--- a/docs/user/readme.adoc
+++ b/docs/user/readme.adoc
@@ -23,7 +23,7 @@ https://github.com/rust-analyzer/rust-analyzer/blob/master/docs/user/readme.adoc
23 23
24== Installation 24== Installation
25 25
26In theory, one should be able to just install the server binary and have it automatically work with any editor. 26In theory, one should be able to just install the <<rust-analyzer-language-server-binary,`rust-analyzer` binary>> and have it automatically work with any editor.
27We are not there yet, so some editor specific setup is required. 27We are not there yet, so some editor specific setup is required.
28 28
29Additionally, rust-analyzer needs the sources of the standard library. 29Additionally, rust-analyzer needs the sources of the standard library.
@@ -57,7 +57,11 @@ To disable this notification put the following to `settings.json`
57---- 57----
58==== 58====
59 59
60The server binary is stored in `~/.config/Code/User/globalStorage/matklad.rust-analyzer` (Linux) or in `~/.Library/Application Support/Code/User/globalStorage/matklad.rust-analyzer` (macOS) or in `%APPDATA%\Code\User\globalStorage` (Windows). 60The server binary is stored in:
61
62* Linux: `~/.config/Code/User/globalStorage/matklad.rust-analyzer`
63* macOS: `~/Library/Application Support/Code/User/globalStorage/matklad.rust-analyzer`
64* Windows: `%APPDATA%\Code\User\globalStorage`
61 65
62Note that we only support the latest version of VS Code. 66Note that we only support the latest version of VS Code.
63 67
@@ -108,15 +112,26 @@ Here are some useful self-diagnostic commands:
108* To log all LSP requests, add `"rust-analyzer.trace.server": "verbose"` to the settings and look for `Server Trace` in the panel. 112* To log all LSP requests, add `"rust-analyzer.trace.server": "verbose"` to the settings and look for `Server Trace` in the panel.
109* To enable client-side logging, add `"rust-analyzer.trace.extension": true` to the settings and open the `Console` tab of VS Code developer tools. 113* To enable client-side logging, add `"rust-analyzer.trace.extension": true` to the settings and open the `Console` tab of VS Code developer tools.
110 114
111=== Language Server Binary 115=== rust-analyzer Language Server Binary
112 116
113Other editors generally require the `rust-analyzer` binary to be in `$PATH`. 117Other editors generally require the `rust-analyzer` binary to be in `$PATH`.
114You can download the pre-built binary from the https://github.com/rust-analyzer/rust-analyzer/releases[releases] page. Typically, you then need to rename the binary for your platform, e.g. `rust-analyzer-mac` if you're on Mac OS, to `rust-analzyer` and make it executable in addition to moving it into a directory in your `$PATH`. 118You can download the pre-built binary from the https://github.com/rust-analyzer/rust-analyzer/releases[releases] page. Typically, you then need to rename the binary for your platform, e.g. `rust-analyzer-mac` if you're on Mac OS, to `rust-analyzer` and make it executable in addition to moving it into a directory in your `$PATH`.
119
120On Linux to install the `rust-analyzer` binary into `~/.local/bin`, this commands could be used
121
122[source,bash]
123----
124$ curl -L https://github.com/rust-analyzer/rust-analyzer/releases/latest/download/rust-analyzer-linux -o ~/.local/bin/rust-analyzer
125$ chmod +x ~/.local/bin/rust-analyzer
126----
127
128Ensure `~/.local/bin` is listed in the `$PATH` variable.
115 129
116Alternatively, you can install it from source using the following command: 130Alternatively, you can install it from source using the following command:
117 131
118[source,bash] 132[source,bash]
119---- 133----
134$ git clone https://github.com/rust-analyzer/rust-analyzer.git && cd rust-analyzer
120$ cargo xtask install --server 135$ cargo xtask install --server
121---- 136----
122 137
@@ -139,28 +154,34 @@ $ yay -S rust-analyzer-bin
139 154
140=== Emacs 155=== Emacs
141 156
142Emacs support is maintained https://github.com/emacs-lsp/lsp-mode/blob/master/lsp-rust.el[upstream]. 157Prerequisites: You have installed the <<rust-analyzer-language-server-binary,`rust-analyzer` binary>>.
158
159Emacs support is maintained as part of the https://github.com/emacs-lsp/lsp-mode[Emacs-LSP] package in https://github.com/emacs-lsp/lsp-mode/blob/master/lsp-rust.el[lsp-rust.el].
143 160
1441. Install the most recent version of `emacs-lsp` package by following the instructions https://github.com/emacs-lsp/lsp-mode[here]. 1611. Install the most recent version of `emacs-lsp` package by following the https://github.com/emacs-lsp/lsp-mode[Emacs-LSP instructions].
1452. Set `lsp-rust-server` to `'rust-analyzer`. 1622. Set `lsp-rust-server` to `'rust-analyzer`.
1463. Run `lsp` in a Rust buffer. 1633. Run `lsp` in a Rust buffer.
1474. (Optionally) bind commands like `lsp-rust-analyzer-join-lines`, `lsp-extend-selection` and `lsp-rust-analyzer-expand-macro` to keys. 1644. (Optionally) bind commands like `lsp-rust-analyzer-join-lines`, `lsp-extend-selection` and `lsp-rust-analyzer-expand-macro` to keys.
148 165
149=== Vim 166=== Vim/NeoVim
150 167
151The are several LSP client implementations for vim: 168Prerequisites: You have installed the <<rust-analyzer-language-server-binary,`rust-analyzer` binary>>. Not needed if the extension can install/update it on its own, coc-rust-analyzer is one example.
169
170The are several LSP client implementations for vim or neovim:
152 171
153==== coc-rust-analyzer 172==== coc-rust-analyzer
154 173
1551. Install coc.nvim by following the instructions at 1741. Install coc.nvim by following the instructions at
156 https://github.com/neoclide/coc.nvim[coc.nvim] 175 https://github.com/neoclide/coc.nvim[coc.nvim]
157 (nodejs required) 176 (Node.js required)
1582. Run `:CocInstall coc-rust-analyzer` to install 1772. Run `:CocInstall coc-rust-analyzer` to install
159 https://github.com/fannheyward/coc-rust-analyzer[coc-rust-analyzer], 178 https://github.com/fannheyward/coc-rust-analyzer[coc-rust-analyzer],
160 this extension implements _most_ of the features supported in the VSCode extension: 179 this extension implements _most_ of the features supported in the VSCode extension:
180 * automatically install and upgrade stable/nightly releases
161 * same configurations as VSCode extension, `rust-analyzer.serverPath`, `rust-analyzer.cargo.features` etc. 181 * same configurations as VSCode extension, `rust-analyzer.serverPath`, `rust-analyzer.cargo.features` etc.
162 * same commands too, `rust-analyzer.analyzerStatus`, `rust-analyzer.ssr` etc. 182 * same commands too, `rust-analyzer.analyzerStatus`, `rust-analyzer.ssr` etc.
163 * highlighting and inlay_hints are not implemented yet 183 * inlay hints for method chaining support, _Neovim Only_
184 * semantic highlighting is not implemented yet
164 185
165==== LanguageClient-neovim 186==== LanguageClient-neovim
166 187
@@ -180,11 +201,11 @@ let g:LanguageClient_serverCommands = {
180==== YouCompleteMe 201==== YouCompleteMe
181 202
1821. Install YouCompleteMe by following the instructions 2031. Install YouCompleteMe by following the instructions
183 https://ycm-core.github.io/YouCompleteMe/#rust-semantic-completion[here] 204 https://github.com/ycm-core/lsp-examples#rust-rust-analyzer[here]
184 205
1852. Configure by adding this to your vim/neovim config file (replacing the existing Rust-specific line if it exists): 2062. Configure by adding this to your vim/neovim config file (replacing the existing Rust-specific line if it exists):
186+ 207+
187[source,vim] 208[source,vim]
188---- 209----
189let g:ycm_language_server = 210let g:ycm_language_server =
190\ [ 211\ [
@@ -197,6 +218,21 @@ let g:ycm_language_server =
197\ ] 218\ ]
198---- 219----
199 220
221==== ALE
222
223To add the LSP server to https://github.com/dense-analysis/ale[ale]:
224
225[source,vim]
226----
227call ale#linter#Define('rust', {
228\ 'name': 'rust-analyzer',
229\ 'lsp': 'stdio',
230\ 'executable': 'rust-analyzer',
231\ 'command': '%e',
232\ 'project_root': '.',
233\})
234----
235
200==== nvim-lsp 236==== nvim-lsp
201 237
202NeoVim 0.5 (not yet released) has built-in language server support. 238NeoVim 0.5 (not yet released) has built-in language server support.
@@ -205,7 +241,7 @@ Once `neovim/nvim-lsp` is installed, use `+lua require'nvim_lsp'.rust_analyzer.s
205 241
206=== Sublime Text 3 242=== Sublime Text 3
207 243
208Prerequisites: You have installed the <<language-server-binary,`rust-analyzer` binary>>. 244Prerequisites: You have installed the <<rust-analyzer-language-server-binary,`rust-analyzer` binary>>.
209 245
210You also need the `LSP` package. To install it: 246You also need the `LSP` package. To install it:
211 247
@@ -214,11 +250,20 @@ You also need the `LSP` package. To install it:
214 * Type `Install Package Control`, press enter 250 * Type `Install Package Control`, press enter
2152. In the command palette, run `Package control: Install package`, and in the list that pops up, type `LSP` and press enter. 2512. In the command palette, run `Package control: Install package`, and in the list that pops up, type `LSP` and press enter.
216 252
217Finally, with your Rust project open, in the command palette, run `LSP: Enable Language Server In Project` or `LSP: Enable Language Server Globally`, then select `rust-analyzer` in the list that pops up to enable the rust-analyzer LSP. The latter means that rust-analzyer is enabled by default in Rust projects. 253Finally, with your Rust project open, in the command palette, run `LSP: Enable Language Server In Project` or `LSP: Enable Language Server Globally`, then select `rust-analyzer` in the list that pops up to enable the rust-analyzer LSP. The latter means that rust-analyzer is enabled by default in Rust projects.
254
255If it worked, you should see "rust-analyzer, Line X, Column Y" on the left side of the bottom bar, and after waiting a bit, functionality like tooltips on hovering over variables should become available.
256
257If you get an error saying `No such file or directory: 'rust-analyzer'`, see the <<rust-analyzer-language-server-binary,`rust-analyzer` binary>> section on installing the language server binary.
258
259=== Gnome Builder
260
261Prerequisites: You have installed the <<rust-analyzer-language-server-binary,`rust-analyzer` binary>>.
218 262
219If it worked, you should see "rust-analzyer, Line X, Column Y" on the left side of the bottom bar, and after waiting a bit, functionality like tooltips on hovering over variables should become available. 263Gnome Builder currently has support for RLS, and there's no way to configure the language server executable. A future version might support `rust-analyzer` out of the box.
220 264
221If you get an error saying `No such file or directory: 'rust-analyzer'`, see the <<language-server-binary,section on installing the language server binary>>. 2651. Rename, symlink or copy the `rust-analyzer` binary to `rls` and place it somewhere Builder can find (in `PATH`, or under `~/.cargo/bin`).
2662. Enable the Rust Builder plugin.
222 267
223== Usage 268== Usage
224 269