aboutsummaryrefslogtreecommitdiff
path: root/docs/user
diff options
context:
space:
mode:
Diffstat (limited to 'docs/user')
-rw-r--r--docs/user/assists.md4
-rw-r--r--docs/user/readme.adoc63
2 files changed, 49 insertions, 18 deletions
diff --git a/docs/user/assists.md b/docs/user/assists.md
index 6483ba4f3..6c6943622 100644
--- a/docs/user/assists.md
+++ b/docs/user/assists.md
@@ -65,7 +65,7 @@ Adds a stub function with a signature matching the function under the cursor.
65struct Baz; 65struct Baz;
66fn baz() -> Baz { Baz } 66fn baz() -> Baz { Baz }
67fn foo() { 67fn foo() {
68 bar┃("", baz()); 68 bar┃("", baz());
69} 69}
70 70
71 71
@@ -73,7 +73,7 @@ fn foo() {
73struct Baz; 73struct Baz;
74fn baz() -> Baz { Baz } 74fn baz() -> Baz { Baz }
75fn foo() { 75fn foo() {
76 bar("", baz()); 76 bar("", baz());
77} 77}
78 78
79fn bar(arg: &str, baz: Baz) { 79fn bar(arg: &str, baz: Baz) {
diff --git a/docs/user/readme.adoc b/docs/user/readme.adoc
index abd126340..ce5704836 100644
--- a/docs/user/readme.adoc
+++ b/docs/user/readme.adoc
@@ -14,9 +14,9 @@
14// Master copy of this document lives in the https://github.com/rust-analyzer/rust-analyzer repository 14// Master copy of this document lives in the https://github.com/rust-analyzer/rust-analyzer repository
15 15
16At its core, rust-analyzer is a *library* for semantic analysis of Rust code as it changes over time. 16At its core, rust-analyzer is a *library* for semantic analysis of Rust code as it changes over time.
17This manual focuses on a specific usage of the library -- the implementation of 17This manual focuses on a specific usage of the library -- running it as part of a server that implements the
18https://microsoft.github.io/language-server-protocol/[Language Server Protocol]. 18https://microsoft.github.io/language-server-protocol/[Language Server Protocol] (LSP).
19LSP 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. 19The 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.
20 20
21To improve this document, send a pull request against 21To improve this document, send a pull request against
22https://github.com/rust-analyzer/rust-analyzer/blob/master/docs/user/readme.adoc[this file]. 22https://github.com/rust-analyzer/rust-analyzer/blob/master/docs/user/readme.adoc[this file].
@@ -26,7 +26,7 @@ https://github.com/rust-analyzer/rust-analyzer/blob/master/docs/user/readme.adoc
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 server 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 sources of the standard library. 29Additionally, rust-analyzer needs the sources of the standard library.
30If the source code is not present, rust-analyzer will attempt to install it automatically. 30If the source code is not present, rust-analyzer will attempt to install it automatically.
31 31
32To add the sources manually, run the following command: 32To add the sources manually, run the following command:
@@ -38,7 +38,7 @@ $ rustup component add rust-src
38=== VS Code 38=== VS Code
39 39
40This is the best supported editor at the moment. 40This is the best supported editor at the moment.
41rust-analyzer plugin for VS Code is maintained 41The rust-analyzer plugin for VS Code is maintained
42https://github.com/rust-analyzer/rust-analyzer/tree/master/editors/code[in tree]. 42https://github.com/rust-analyzer/rust-analyzer/tree/master/editors/code[in tree].
43 43
44You can install the latest release of the plugin from 44You can install the latest release of the plugin from
@@ -74,7 +74,7 @@ We ship nightly releases for VS Code. To help us out with testing the newest cod
74{ "rust-analyzer.updates.channel": "nightly" } 74{ "rust-analyzer.updates.channel": "nightly" }
75---- 75----
76 76
77You will be prompted to install the `nightly` extension version. Just click `Download now` and from that moment you will get automatic updates each 24 hours. 77You will be prompted to install the `nightly` extension version. Just click `Download now` and from that moment you will get automatic updates every 24 hours.
78 78
79If you don't want to be asked for `Download now` every day when the new nightly version is released add the following to your `settings.json`: 79If you don't want to be asked for `Download now` every day when the new nightly version is released add the following to your `settings.json`:
80[source,json] 80[source,json]
@@ -110,19 +110,21 @@ Here are some useful self-diagnostic commands:
110 110
111=== Language Server Binary 111=== Language Server Binary
112 112
113Other editors generally require `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 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`.
115https://github.com/rust-analyzer/rust-analyzer/releases[releases] 115
116page, or you can install it from source using the following command: 116Alternatively, you can install it from source using the following command:
117 117
118[source,bash] 118[source,bash]
119---- 119----
120$ cargo xtask install --server 120$ cargo xtask install --server
121---- 121----
122 122
123If your editor can't find the binary even though the binary is on your `$PATH`, the likely explanation is that it doesn't see the same `$PATH` as the shell, see https://github.com/rust-analyzer/rust-analyzer/issues/1811[this issue]. On Unix, running the editor from a shell or changing the `.desktop` file to set the environment should help.
124
123==== Arch Linux 125==== Arch Linux
124 126
125`rust-analyzer` binary can be installed from AUR (Arch User Repository): 127The `rust-analyzer` binary can be installed from AUR (Arch User Repository):
126 128
127- https://aur.archlinux.org/packages/rust-analyzer-bin[`rust-analyzer-bin`] (binary from GitHub releases) 129- https://aur.archlinux.org/packages/rust-analyzer-bin[`rust-analyzer-bin`] (binary from GitHub releases)
128- https://aur.archlinux.org/packages/rust-analyzer[`rust-analyzer`] (built from latest tagged source) 130- https://aur.archlinux.org/packages/rust-analyzer[`rust-analyzer`] (built from latest tagged source)
@@ -156,8 +158,8 @@ The are several LSP client implementations for vim:
1562. Run `:CocInstall coc-rust-analyzer` to install 1582. Run `:CocInstall coc-rust-analyzer` to install
157 https://github.com/fannheyward/coc-rust-analyzer[coc-rust-analyzer], 159 https://github.com/fannheyward/coc-rust-analyzer[coc-rust-analyzer],
158 this extension implements _most_ of the features supported in the VSCode extension: 160 this extension implements _most_ of the features supported in the VSCode extension:
159 * same configurations as VSCode extension, `rust-analyzer.serverPath`, `rust-analyzer.enableCargoWatchOnStartup` etc. 161 * same configurations as VSCode extension, `rust-analyzer.serverPath`, `rust-analyzer.cargo.features` etc.
160 * same commands too, `rust-analyzer.analyzerStatus`, `rust-analyzer.startCargoWatch` etc. 162 * same commands too, `rust-analyzer.analyzerStatus`, `rust-analyzer.ssr` etc.
161 * highlighting and inlay_hints are not implemented yet 163 * highlighting and inlay_hints are not implemented yet
162 164
163==== LanguageClient-neovim 165==== LanguageClient-neovim
@@ -175,6 +177,26 @@ let g:LanguageClient_serverCommands = {
175\ } 177\ }
176---- 178----
177 179
180==== YouCompleteMe
181
1821. Install YouCompleteMe by following the instructions
183 https://ycm-core.github.io/YouCompleteMe/#rust-semantic-completion[here]
184
1852. Configure by adding this to your vim/neovim config file (replacing the existing Rust-specific line if it exists):
186+
187[source,vim]
188----
189let g:ycm_language_server =
190\ [
191\ {
192\ 'name': 'rust',
193\ 'cmdline': ['rust-analyzer'],
194\ 'filetypes': ['rust'],
195\ 'project_root_files': ['Cargo.toml']
196\ }
197\ ]
198----
199
178==== nvim-lsp 200==== nvim-lsp
179 201
180NeoVim 0.5 (not yet released) has built-in language server support. 202NeoVim 0.5 (not yet released) has built-in language server support.
@@ -183,11 +205,20 @@ Once `neovim/nvim-lsp` is installed, use `+lua require'nvim_lsp'.rust_analyzer.s
183 205
184=== Sublime Text 3 206=== Sublime Text 3
185 207
186Prerequisites: 208Prerequisites: You have installed the <<language-server-binary,`rust-analyzer` binary>>.
209
210You also need the `LSP` package. To install it:
211
2121. If you've never installed a Sublime Text package, install Package Control:
213 * Open the command palette (Win/Linux: `ctrl+shift+p`, Mac: `cmd+shift+p`)
214 * 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.
216
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.
187 218
188`LSP` package. 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.
189 220
190Invoke the command palette (`ctrl+shift+p`) and type LSP enable to locally/globally enable the rust-analyzer LSP (type LSP enable, then choose either locally or globally, then select rust-analyzer) 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>>.
191 222
192== Usage 223== Usage
193 224