aboutsummaryrefslogtreecommitdiff
path: root/docs/user
diff options
context:
space:
mode:
Diffstat (limited to 'docs/user')
-rw-r--r--docs/user/README.md63
-rw-r--r--docs/user/assists.md18
2 files changed, 57 insertions, 24 deletions
diff --git a/docs/user/README.md b/docs/user/README.md
index 1b2d98608..968d2e34c 100644
--- a/docs/user/README.md
+++ b/docs/user/README.md
@@ -1,14 +1,19 @@
1The main interface to rust-analyzer is the 1The main interface to rust-analyzer is the
2[LSP](https://microsoft.github.io/language-server-protocol/) implementation. To 2[LSP](https://microsoft.github.io/language-server-protocol/) implementation. To
3install lsp server, use `cargo xtask install --server`, which is a shorthand for `cargo 3install lsp server, clone the repository and then run `cargo xtask install
4install --package ra_lsp_server`. The binary is named `ra_lsp_server`, you 4--server` (which is shorthand for `cargo install --path
5should be able to use it with any LSP-compatible editor. We use custom 5./crates/ra_lsp_server`). This will produce a binary named `ra_lsp_server` which
6you should be able to use it with any LSP-compatible editor. We use custom
6extensions to LSP, so special client-side support is required to take full 7extensions to LSP, so special client-side support is required to take full
7advantage of rust-analyzer. This repository contains support code for VS Code 8advantage of rust-analyzer. This repository contains support code for VS Code
8and Emacs. 9and Emacs.
9 10
10Rust Analyzer needs sources of rust standard library to work, so you might need 11```
11to execute 12$ git clone [email protected]:rust-analyzer/rust-analyzer && cd rust-analyzer
13$ cargo xtask install --server
14```
15Rust Analyzer needs sources of rust standard library to work, so
16you might also need to execute
12 17
13``` 18```
14$ rustup component add rust-src 19$ rustup component add rust-src
@@ -133,43 +138,31 @@ Prerequisites:
133Installation: 138Installation:
134 139
135* add 140* add
136[ra-emacs-lsp.el](https://github.com/rust-analyzer/rust-analyzer/blob/69ee5c9c5ef212f7911028c9ddf581559e6565c3/editors/emacs/ra-emacs-lsp.el) 141[ra-emacs-lsp.el](../../editors/emacs/ra-emacs-lsp.el)
137to load path and require it in `init.el` 142to load path and require it in `init.el`
138* run `lsp` in a rust buffer 143* run `lsp` in a rust buffer
139* (Optionally) bind commands like `rust-analyzer-join-lines`, `rust-analyzer-extend-selection` and `rust-analyzer-expand-macro` to keys, and enable `rust-analyzer-inlay-hints-mode` to get inline type hints 144* (Optionally) bind commands like `rust-analyzer-join-lines`, `rust-analyzer-extend-selection` and `rust-analyzer-expand-macro` to keys, and enable `rust-analyzer-inlay-hints-mode` to get inline type hints
140 145
141 146
142## Vim and NeoVim 147## Vim and NeoVim (coc-rust-analyzer)
143 148
144Neovim 0.5 has a built in language server. For a quick start configuration of 149* Install coc.nvim by following the instructions at [coc.nvim][] (nodejs required)
145rust-analyzer, use [neovim/nvim-lsp](https://github.com/neovim/nvim-lsp#rust_analyzer). 150* Run `:CocInstall coc-rust-analyzer` to install [coc-rust-analyzer], this extension implements _most_ of the features supported in the VSCode extension:
146Once `neovim/nvim-lsp` is installed, you can use `call nvim_lsp#setup("rust_analyzer", {})`
147or `lua require'nvim_lsp'.rust_analyzer.setup({})` to quickly get set up.
148
149* Install coc.nvim by following the instructions at [coc.nvim]
150 - You will need nodejs installed.
151 - You may want to include some of the sample vim configurations [from here][coc-vim-conf]
152 - Note that if you use a plugin manager other than `vim-plug`, you may need to manually
153 checkout the `release` branch wherever your plugin manager cloned it. Otherwise you will
154 get errors about a missing javascript file.
155* Run `:CocInstall coc-rust-analyzer` to install [coc-rust-analyzer], this extension implemented _most_ of the features supported in the VSCode extension:
156 - same configurations as VSCode extension, `rust-analyzer.raLspServerPath`, `rust-analyzer.enableCargoWatchOnStartup` etc. 151 - same configurations as VSCode extension, `rust-analyzer.raLspServerPath`, `rust-analyzer.enableCargoWatchOnStartup` etc.
157 - same commands too, `rust-analyzer.analyzerStatus`, `rust-analyzer.startCargoWatch` etc. 152 - same commands too, `rust-analyzer.analyzerStatus`, `rust-analyzer.startCargoWatch` etc.
158 - highlighting and inlay_hints are not implemented yet 153 - highlighting and inlay_hints are not implemented yet
159 154
160[coc.nvim]: https://github.com/neoclide/coc.nvim 155[coc.nvim]: https://github.com/neoclide/coc.nvim
161[coc-vim-conf]: https://github.com/neoclide/coc.nvim/#example-vim-configuration
162[coc-rust-analyzer]: https://github.com/fannheyward/coc-rust-analyzer 156[coc-rust-analyzer]: https://github.com/fannheyward/coc-rust-analyzer
163 157
164## Vim and NeoVim Alternative 158## Vim and NeoVim (LanguageClient-neovim)
165 159
166* Install LanguageClient-neovim by following the instructions [here][lang-client-neovim] 160* Install LanguageClient-neovim by following the instructions [here][lang-client-neovim]
167 - No extra run-time is required as this server is written in Rust
168 - The github project wiki has extra tips on configuration 161 - The github project wiki has extra tips on configuration
169 162
170* Configure by adding this to your vim/neovim config file (replacing the existing rust specific line if it exists): 163* Configure by adding this to your vim/neovim config file (replacing the existing rust specific line if it exists):
171 164
172``` 165```vim
173let g:LanguageClient_serverCommands = { 166let g:LanguageClient_serverCommands = {
174\ 'rust': ['ra_lsp_server'], 167\ 'rust': ['ra_lsp_server'],
175\ } 168\ }
@@ -177,6 +170,13 @@ let g:LanguageClient_serverCommands = {
177 170
178[lang-client-neovim]: https://github.com/autozimu/LanguageClient-neovim 171[lang-client-neovim]: https://github.com/autozimu/LanguageClient-neovim
179 172
173## NeoVim (nvim-lsp)
174
175NeoVim 0.5 (not yet released) has built in language server support. For a quick start configuration
176of rust-analyzer, use [neovim/nvim-lsp](https://github.com/neovim/nvim-lsp#rust_analyzer).
177Once `neovim/nvim-lsp` is installed, you can use `call nvim_lsp#setup("rust_analyzer", {})`
178or `lua require'nvim_lsp'.rust_analyzer.setup({})` to quickly get set up.
179
180 180
181## Sublime Text 3 181## Sublime Text 3
182 182
@@ -208,4 +208,19 @@ Installation:
208 208
209* You can now invoke the command palette 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) 209* You can now invoke the command palette 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)
210 210
211* Note that `ra_lsp_server` binary must be in `$PATH` for this to work. If it's not the case, you can specify full path to the binary, which is typically `.cargo/bin/ra_lsp_server`. 211### Setting up the `PATH` variable
212
213On Unix systems, `rustup` adds `~/.cargo/bin` to `PATH` by modifying the shell's
214startup file. Depending on your configuration, your Desktop Environment might not
215actually load it. If you find that `rust-analyzer` only runs when starting the
216editor from the terminal, you will have to set up your `PATH` variable manually.
217
218There are a couple of ways to do that:
219
220- for Code, set `rust-analyzer.raLspServerPath` to `~/.cargo/bin` (the `~` is
221 automatically resolved by the extension)
222- copy the binary to a location that is already in `PATH`, e.g. `/usr/local/bin`
223- on Linux, use PAM to configure the `PATH` variable, by e.g. putting
224 `PATH DEFAULT=/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin:@{HOME}/.cargo/bin:@{HOME}/.local/bin`
225 in your `~/.pam_environment` file; note that this might interfere with other
226 defaults set by the system administrator via `/etc/environment`.
diff --git a/docs/user/assists.md b/docs/user/assists.md
index 6f4c30bee..334ba450f 100644
--- a/docs/user/assists.md
+++ b/docs/user/assists.md
@@ -3,6 +3,24 @@
3Cursor position or selection is signified by `┃` character. 3Cursor position or selection is signified by `┃` character.
4 4
5 5
6## `add_custom_impl`
7
8Adds impl block for derived trait.
9
10```rust
11// BEFORE
12#[derive(Deb┃ug, Display)]
13struct S;
14
15// AFTER
16#[derive(Display)]
17struct S;
18
19impl Debug for S {
20
21}
22```
23
6## `add_derive` 24## `add_derive`
7 25
8Adds a new `#[derive()]` clause to a struct or enum. 26Adds a new `#[derive()]` clause to a struct or enum.