6
6
7
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
10
This manual focuses on a specific usage of the library -- the implementation of
11
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
14
To improve this document, send a pull request against
15
15
https://github.com/rust-analyzer/rust-analyzer/blob/master/docs/user/readme.adoc[this file].
@@ -20,7 +20,9 @@ In theory, one should be able to just install the server binary and have it auto
20
20
We are not there yet, so some editor specific setup is required.
21
21
22
22
Additionally, rust-analyzer needs sources of the standard library.
23
- This commands adds them:
23
+ If the source code is not present, rust-analyzer will attempt to install it automatically.
24
+
25
+ To add the sources manually, run the following command:
24
26
25
27
```bash
26
28
$ rustup component add rust-src
@@ -34,10 +36,9 @@ https://github.com/rust-analyzer/rust-analyzer/tree/master/editors/code[in tree]
34
36
35
37
You can install the latest release of the plugin from
36
38
https://marketplace.visualstudio.com/items?itemName=matklad.rust-analyzer[the marketplace].
37
- 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:
38
40
39
- // FIXME: update the image (its text has changed)
40
- image::https://user-images.githubusercontent.com/36276403/74103174-a40df100-4b52-11ea-81f4-372c70797924.png[]
41
+ image::https://user-images.githubusercontent.com/9021944/75067008-17502500-54ba-11ea-835a-f92aac50e866.png[]
41
42
42
43
The server binary is stored in `~/.config/Code/User/globalStorage/matklad.rust-analyzer`.
43
44
@@ -58,20 +59,20 @@ $ cargo xtask install
58
59
----
59
60
60
61
You'll need Cargo, nodejs and npm for this.
61
- 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:
62
63
63
64
[source,json]
64
65
----
65
- { "rust-analyzer.raLspServerPath ": "ra_lsp_server " }
66
+ { "rust-analyzer.serverPath ": "rust-analyzer " }
66
67
----
67
68
68
69
Note that installing via `xtask install` does not work for VS Code Remote, instead you'll need to install the `.vsix` manually.
69
70
70
71
=== Language Server Binary
71
72
72
- Other editors generally require `ra_lsp_server ` binary to be in `$PATH`.
73
- You can download pre-build binary from
74
- https://github.com/rust-analyzer/rust-analyzer/releases[relases ]
73
+ Other editors generally require `rust-analyzer ` binary to be in `$PATH`.
74
+ You can download the pre-built binary from
75
+ https://github.com/rust-analyzer/rust-analyzer/releases[releases ]
75
76
page, or you can install it from source using the following command:
76
77
77
78
[source,bash]
@@ -83,7 +84,7 @@ $ cargo xtask install --server
83
84
84
85
Emacs support is maintained https://github.com/emacs-lsp/lsp-mode/blob/master/lsp-rust.el[upstream].
85
86
86
- 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].
87
88
2. Set `lsp-rust-server` to `'rust-analyzer`.
88
89
3. Run `lsp` in a Rust buffer.
89
90
4. (Optionally) bind commands like `lsp-rust-analyzer-join-lines`, `lsp-extend-selection` and `lsp-rust-analyzer-expand-macro` to keys.
@@ -100,7 +101,7 @@ The are several LSP client implementations for vim:
100
101
2. Run `:CocInstall coc-rust-analyzer` to install
101
102
https://github.com/fannheyward/coc-rust-analyzer[coc-rust-analyzer],
102
103
this extension implements _most_ of the features supported in the VSCode extension:
103
- * same configurations as VSCode extension, `rust-analyzer.raLspServerPath `, `rust-analyzer.enableCargoWatchOnStartup` etc.
104
+ * same configurations as VSCode extension, `rust-analyzer.serverPath `, `rust-analyzer.enableCargoWatchOnStartup` etc.
104
105
* same commands too, `rust-analyzer.analyzerStatus`, `rust-analyzer.startCargoWatch` etc.
105
106
* highlighting and inlay_hints are not implemented yet
106
107
@@ -110,18 +111,18 @@ The are several LSP client implementations for vim:
110
111
https://github.com/autozimu/LanguageClient-neovim[here]
111
112
* The github project wiki has extra tips on configuration
112
113
113
- 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):
114
115
+
115
116
[source,vim]
116
117
----
117
118
let g:LanguageClient_serverCommands = {
118
- \ 'rust': ['ra_lsp_server '],
119
+ \ 'rust': ['rust-analyzer '],
119
120
\ }
120
121
----
121
122
122
123
==== nvim-lsp
123
124
124
- 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.
125
126
For a quick start configuration of rust-analyzer, use https://github.com/neovim/nvim-lsp#rust_analyzer[neovim/nvim-lsp].
126
127
Once `neovim/nvim-lsp` is installed, use `lua require'nvim_lsp'.rust_analyzer.setup({})` in your `init.vim`.
127
128
@@ -140,7 +141,7 @@ Installation:
140
141
[source,json]
141
142
----
142
143
"rust-analyzer": {
143
- "command": ["ra_lsp_server "],
144
+ "command": ["rust-analyzer "],
144
145
"languageId": "rust",
145
146
"scopes": ["source.rust"],
146
147
"syntaxes": [
0 commit comments