aboutsummaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
Diffstat (limited to 'docs')
-rw-r--r--docs/dev/architecture.md4
-rw-r--r--docs/dev/guide.md8
-rw-r--r--docs/dev/syntax.md2
-rw-r--r--docs/user/assists.md22
-rw-r--r--docs/user/features.md4
-rw-r--r--docs/user/readme.adoc40
6 files changed, 63 insertions, 17 deletions
diff --git a/docs/dev/architecture.md b/docs/dev/architecture.md
index 3a337c574..cee916c09 100644
--- a/docs/dev/architecture.md
+++ b/docs/dev/architecture.md
@@ -46,7 +46,7 @@ can be quickly updated for small modifications.
46 46
47Some of the components of this repository are generated through automatic 47Some of the components of this repository are generated through automatic
48processes. `cargo xtask codegen` runs all generation tasks. Generated code is 48processes. `cargo xtask codegen` runs all generation tasks. Generated code is
49commited to the git repository. 49committed to the git repository.
50 50
51In particular, `cargo xtask codegen` generates: 51In particular, `cargo xtask codegen` generates:
52 52
@@ -114,7 +114,7 @@ is responsible for guessing a HIR for a particular source position.
114Underneath, HIR works on top of salsa, using a `HirDatabase` trait. 114Underneath, HIR works on top of salsa, using a `HirDatabase` trait.
115 115
116`ra_hir_xxx` crates have a strong ECS flavor, in that they work with raw ids and 116`ra_hir_xxx` crates have a strong ECS flavor, in that they work with raw ids and
117directly query the databse. 117directly query the database.
118 118
119The top-level `ra_hir` façade crate wraps ids into a more OO-flavored API. 119The top-level `ra_hir` façade crate wraps ids into a more OO-flavored API.
120 120
diff --git a/docs/dev/guide.md b/docs/dev/guide.md
index abbe4c154..c3252f1f6 100644
--- a/docs/dev/guide.md
+++ b/docs/dev/guide.md
@@ -26,7 +26,7 @@ properties hold:
26 26
27## IDE API 27## IDE API
28 28
29To see the bigger picture of how the IDE features works, let's take a look at the [`AnalysisHost`] and 29To see the bigger picture of how the IDE features work, let's take a look at the [`AnalysisHost`] and
30[`Analysis`] pair of types. `AnalysisHost` has three methods: 30[`Analysis`] pair of types. `AnalysisHost` has three methods:
31 31
32* `default()` for creating an empty analysis instance 32* `default()` for creating an empty analysis instance
@@ -131,7 +131,7 @@ mapping between `SourceRoot` IDs (which are assigned by the client) and actual
131analyzer. 131analyzer.
132 132
133Note that `mod`, `#[path]` and `include!()` can only reference files from the 133Note that `mod`, `#[path]` and `include!()` can only reference files from the
134same source root. It is of course is possible to explicitly add extra files to 134same source root. It is of course possible to explicitly add extra files to
135the source root, even `/dev/random`. 135the source root, even `/dev/random`.
136 136
137## Language Server Protocol 137## Language Server Protocol
@@ -192,7 +192,7 @@ task will be canceled as soon as the main loop calls `apply_change` on the
192[`schedule`]: https://github.com/rust-analyzer/rust-analyzer/blob/guide-2019-01/crates/ra_lsp_server/src/main_loop.rs#L426-L455 192[`schedule`]: https://github.com/rust-analyzer/rust-analyzer/blob/guide-2019-01/crates/ra_lsp_server/src/main_loop.rs#L426-L455
193[The task]: https://github.com/rust-analyzer/rust-analyzer/blob/guide-2019-01/crates/ra_lsp_server/src/main_loop/handlers.rs#L205-L223 193[The task]: https://github.com/rust-analyzer/rust-analyzer/blob/guide-2019-01/crates/ra_lsp_server/src/main_loop/handlers.rs#L205-L223
194 194
195This concludes the overview of the analyzer's programing *interface*. Next, lets 195This concludes the overview of the analyzer's programing *interface*. Next, let's
196dig into the implementation! 196dig into the implementation!
197 197
198## Salsa 198## Salsa
@@ -480,7 +480,7 @@ throughout the analyzer:
480## Source Map pattern 480## Source Map pattern
481 481
482Due to an obscure edge case in completion, IDE needs to know the syntax node of 482Due to an obscure edge case in completion, IDE needs to know the syntax node of
483an use statement which imported the given completion candidate. We can't just 483a use statement which imported the given completion candidate. We can't just
484store the syntax node as a part of name resolution: this will break 484store the syntax node as a part of name resolution: this will break
485incrementality, due to the fact that syntax changes after every file 485incrementality, due to the fact that syntax changes after every file
486modification. 486modification.
diff --git a/docs/dev/syntax.md b/docs/dev/syntax.md
index 4dd1de659..33973ffec 100644
--- a/docs/dev/syntax.md
+++ b/docs/dev/syntax.md
@@ -35,7 +35,7 @@ The syntax tree consists of three layers:
35* AST 35* AST
36 36
37Of these, only GreenNodes store the actual data, the other two layers are (non-trivial) views into green tree. 37Of these, only GreenNodes store the actual data, the other two layers are (non-trivial) views into green tree.
38Red-green terminology comes from Roslyn ([link](https://docs.microsoft.com/en-ie/archive/blogs/ericlippert/persistence-facades-and-roslyns-red-green-trees)) and gives the name to the `rowan` library. Green and syntax nodes are defined in rowan, ast is defined in rust-analyzer. 38Red-green terminology comes from Roslyn ([link](https://ericlippert.com/2012/06/08/red-green-trees/)) and gives the name to the `rowan` library. Green and syntax nodes are defined in rowan, ast is defined in rust-analyzer.
39 39
40Syntax trees are a semi-transient data structure. 40Syntax trees are a semi-transient data structure.
41In general, frontend does not keep syntax trees for all files in memory. 41In general, frontend does not keep syntax trees for all files in memory.
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 76d065d35..b1af72ce6 100644
--- a/docs/user/readme.adoc
+++ b/docs/user/readme.adoc
@@ -111,7 +111,7 @@ Here are some useful self-diagnostic commands:
111=== rust-analyzer Language Server Binary 111=== rust-analyzer Language Server Binary
112 112
113Other editors generally require the `rust-analyzer` binary to be in `$PATH`. 113Other 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`. 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-analyzer` and make it executable in addition to moving it into a directory in your `$PATH`.
115 115
116On Linux to install the `rust-analyzer` binary into `~/.local/bin`, this commands could be used 116On Linux to install the `rust-analyzer` binary into `~/.local/bin`, this commands could be used
117 117
@@ -169,13 +169,15 @@ The are several LSP client implementations for vim:
169 169
1701. Install coc.nvim by following the instructions at 1701. Install coc.nvim by following the instructions at
171 https://github.com/neoclide/coc.nvim[coc.nvim] 171 https://github.com/neoclide/coc.nvim[coc.nvim]
172 (nodejs required) 172 (Node.js required)
1732. Run `:CocInstall coc-rust-analyzer` to install 1732. Run `:CocInstall coc-rust-analyzer` to install
174 https://github.com/fannheyward/coc-rust-analyzer[coc-rust-analyzer], 174 https://github.com/fannheyward/coc-rust-analyzer[coc-rust-analyzer],
175 this extension implements _most_ of the features supported in the VSCode extension: 175 this extension implements _most_ of the features supported in the VSCode extension:
176 * automatically install and upgrade stable/nightly releases
176 * same configurations as VSCode extension, `rust-analyzer.serverPath`, `rust-analyzer.cargo.features` etc. 177 * same configurations as VSCode extension, `rust-analyzer.serverPath`, `rust-analyzer.cargo.features` etc.
177 * same commands too, `rust-analyzer.analyzerStatus`, `rust-analyzer.ssr` etc. 178 * same commands too, `rust-analyzer.analyzerStatus`, `rust-analyzer.ssr` etc.
178 * highlighting and inlay_hints are not implemented yet 179 * inlay hints for method chaining support, _Neovim Only_
180 * semantic highlighting is not implemented yet
179 181
180==== LanguageClient-neovim 182==== LanguageClient-neovim
181 183
@@ -195,11 +197,11 @@ let g:LanguageClient_serverCommands = {
195==== YouCompleteMe 197==== YouCompleteMe
196 198
1971. Install YouCompleteMe by following the instructions 1991. Install YouCompleteMe by following the instructions
198 https://ycm-core.github.io/YouCompleteMe/#rust-semantic-completion[here] 200 https://github.com/ycm-core/lsp-examples#rust-rust-analyzer[here]
199 201
2002. Configure by adding this to your vim/neovim config file (replacing the existing Rust-specific line if it exists): 2022. Configure by adding this to your vim/neovim config file (replacing the existing Rust-specific line if it exists):
201+ 203+
202[source,vim] 204[source,vim]
203---- 205----
204let g:ycm_language_server = 206let g:ycm_language_server =
205\ [ 207\ [
@@ -212,6 +214,21 @@ let g:ycm_language_server =
212\ ] 214\ ]
213---- 215----
214 216
217==== ALE
218
219To add the LSP server to https://github.com/dense-analysis/ale[ale]:
220
221[source,vim]
222----
223call ale#linter#Define('rust', {
224\ 'name': 'rust-analyzer',
225\ 'lsp': 'stdio',
226\ 'executable': 'rust-analyzer',
227\ 'command': '%e',
228\ 'project_root': '.',
229\})
230----
231
215==== nvim-lsp 232==== nvim-lsp
216 233
217NeoVim 0.5 (not yet released) has built-in language server support. 234NeoVim 0.5 (not yet released) has built-in language server support.
@@ -229,12 +246,21 @@ You also need the `LSP` package. To install it:
229 * Type `Install Package Control`, press enter 246 * Type `Install Package Control`, press enter
2302. In the command palette, run `Package control: Install package`, and in the list that pops up, type `LSP` and press enter. 2472. In the command palette, run `Package control: Install package`, and in the list that pops up, type `LSP` and press enter.
231 248
232Finally, 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. 249Finally, 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.
233 250
234If 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. 251If 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.
235 252
236If 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. 253If 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.
237 254
255=== Gnome Builder
256
257Prerequisites: You have installed the <<rust-analyzer-language-server-binary,`rust-analyzer` binary>>.
258
259Gnome 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.
260
2611. Rename, symlink or copy the `rust-analyzer` binary to `rls` and place it somewhere Builder can find (in `PATH`, or under `~/.cargo/bin`).
2622. Enable the Rust Builder plugin.
263
238== Usage 264== Usage
239 265
240See https://github.com/rust-analyzer/rust-analyzer/blob/master/docs/user/features.md[features.md]. 266See https://github.com/rust-analyzer/rust-analyzer/blob/master/docs/user/features.md[features.md].