diff options
Diffstat (limited to 'docs/user/readme.adoc')
-rw-r--r-- | docs/user/readme.adoc | 44 |
1 files changed, 37 insertions, 7 deletions
diff --git a/docs/user/readme.adoc b/docs/user/readme.adoc index ce5704836..8b80a7df7 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 | ||
26 | In theory, one should be able to just install the server binary and have it automatically work with any editor. | 26 | In 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. |
27 | We are not there yet, so some editor specific setup is required. | 27 | We are not there yet, so some editor specific setup is required. |
28 | 28 | ||
29 | Additionally, rust-analyzer needs the sources of the standard library. | 29 | Additionally, rust-analyzer needs the sources of the standard library. |
@@ -108,15 +108,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. | 108 | * 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. | 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. |
110 | 110 | ||
111 | === Language Server Binary | 111 | === rust-analyzer Language Server Binary |
112 | 112 | ||
113 | Other editors generally require the `rust-analyzer` binary to be in `$PATH`. | 113 | Other editors generally require the `rust-analyzer` binary to be in `$PATH`. |
114 | You 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`. | 114 | You 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`. |
115 | 115 | ||
116 | On Linux to install the `rust-analyzer` binary into `~/.local/bin`, this commands could be used | ||
117 | |||
118 | [source,bash] | ||
119 | ---- | ||
120 | $ curl -L https://github.com/rust-analyzer/rust-analyzer/releases/latest/download/rust-analyzer-linux -o ~/.local/bin/rust-analyzer | ||
121 | $ chmod +x ~/.local/bin/rust-analyzer | ||
122 | ---- | ||
123 | |||
124 | Ensure `~/.local/bin` is listed in the `$PATH` variable. | ||
125 | |||
116 | Alternatively, you can install it from source using the following command: | 126 | Alternatively, you can install it from source using the following command: |
117 | 127 | ||
118 | [source,bash] | 128 | [source,bash] |
119 | ---- | 129 | ---- |
130 | $ git clone https://github.com/rust-analyzer/rust-analyzer.git && cd rust-analyzer | ||
120 | $ cargo xtask install --server | 131 | $ cargo xtask install --server |
121 | ---- | 132 | ---- |
122 | 133 | ||
@@ -139,15 +150,19 @@ $ yay -S rust-analyzer-bin | |||
139 | 150 | ||
140 | === Emacs | 151 | === Emacs |
141 | 152 | ||
142 | Emacs support is maintained https://github.com/emacs-lsp/lsp-mode/blob/master/lsp-rust.el[upstream]. | 153 | Prerequisites: You have installed the <<rust-analyzer-language-server-binary,`rust-analyzer` binary>>. |
154 | |||
155 | Emacs 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 | 156 | ||
144 | 1. Install the most recent version of `emacs-lsp` package by following the instructions https://github.com/emacs-lsp/lsp-mode[here]. | 157 | 1. Install the most recent version of `emacs-lsp` package by following the https://github.com/emacs-lsp/lsp-mode[Emacs-LSP instructions]. |
145 | 2. Set `lsp-rust-server` to `'rust-analyzer`. | 158 | 2. Set `lsp-rust-server` to `'rust-analyzer`. |
146 | 3. Run `lsp` in a Rust buffer. | 159 | 3. Run `lsp` in a Rust buffer. |
147 | 4. (Optionally) bind commands like `lsp-rust-analyzer-join-lines`, `lsp-extend-selection` and `lsp-rust-analyzer-expand-macro` to keys. | 160 | 4. (Optionally) bind commands like `lsp-rust-analyzer-join-lines`, `lsp-extend-selection` and `lsp-rust-analyzer-expand-macro` to keys. |
148 | 161 | ||
149 | === Vim | 162 | === Vim |
150 | 163 | ||
164 | Prerequisites: You have installed the <<rust-analyzer-language-server-binary,`rust-analyzer` binary>>. | ||
165 | |||
151 | The are several LSP client implementations for vim: | 166 | The are several LSP client implementations for vim: |
152 | 167 | ||
153 | ==== coc-rust-analyzer | 168 | ==== coc-rust-analyzer |
@@ -180,7 +195,7 @@ let g:LanguageClient_serverCommands = { | |||
180 | ==== YouCompleteMe | 195 | ==== YouCompleteMe |
181 | 196 | ||
182 | 1. Install YouCompleteMe by following the instructions | 197 | 1. Install YouCompleteMe by following the instructions |
183 | https://ycm-core.github.io/YouCompleteMe/#rust-semantic-completion[here] | 198 | https://github.com/ycm-core/lsp-examples#rust-rust-analyzer[here] |
184 | 199 | ||
185 | 2. Configure by adding this to your vim/neovim config file (replacing the existing Rust-specific line if it exists): | 200 | 2. Configure by adding this to your vim/neovim config file (replacing the existing Rust-specific line if it exists): |
186 | + | 201 | + |
@@ -197,6 +212,21 @@ let g:ycm_language_server = | |||
197 | \ ] | 212 | \ ] |
198 | ---- | 213 | ---- |
199 | 214 | ||
215 | ==== ALE | ||
216 | |||
217 | To add the LSP server to https://github.com/dense-analysis/ale[ale]: | ||
218 | |||
219 | [source,vim] | ||
220 | ---- | ||
221 | call ale#linter#Define('rust', { | ||
222 | \ 'name': 'rust-analyzer', | ||
223 | \ 'lsp': 'stdio', | ||
224 | \ 'executable': 'rust-analyzer', | ||
225 | \ 'command': '%e', | ||
226 | \ 'project_root': '.', | ||
227 | \}) | ||
228 | ---- | ||
229 | |||
200 | ==== nvim-lsp | 230 | ==== nvim-lsp |
201 | 231 | ||
202 | NeoVim 0.5 (not yet released) has built-in language server support. | 232 | NeoVim 0.5 (not yet released) has built-in language server support. |
@@ -205,7 +235,7 @@ Once `neovim/nvim-lsp` is installed, use `+lua require'nvim_lsp'.rust_analyzer.s | |||
205 | 235 | ||
206 | === Sublime Text 3 | 236 | === Sublime Text 3 |
207 | 237 | ||
208 | Prerequisites: You have installed the <<language-server-binary,`rust-analyzer` binary>>. | 238 | Prerequisites: You have installed the <<rust-analyzer-language-server-binary,`rust-analyzer` binary>>. |
209 | 239 | ||
210 | You also need the `LSP` package. To install it: | 240 | You also need the `LSP` package. To install it: |
211 | 241 | ||
@@ -218,7 +248,7 @@ Finally, with your Rust project open, in the command palette, run `LSP: Enable L | |||
218 | 248 | ||
219 | If 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. | 249 | If 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. |
220 | 250 | ||
221 | If you get an error saying `No such file or directory: 'rust-analyzer'`, see the <<language-server-binary,section on installing the language server binary>>. | 251 | If 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. |
222 | 252 | ||
223 | == Usage | 253 | == Usage |
224 | 254 | ||