diff options
Diffstat (limited to 'docs')
-rw-r--r-- | docs/dev/README.md | 11 | ||||
-rw-r--r-- | docs/user/README.md | 96 | ||||
-rw-r--r-- | docs/user/assists.md | 28 |
3 files changed, 102 insertions, 33 deletions
diff --git a/docs/dev/README.md b/docs/dev/README.md index 732e4bdd3..991deaf90 100644 --- a/docs/dev/README.md +++ b/docs/dev/README.md | |||
@@ -74,7 +74,7 @@ relevant test and execute it (VS Code includes an action for running a single | |||
74 | test). | 74 | test). |
75 | 75 | ||
76 | However, launching a VS Code instance with locally build language server is | 76 | However, launching a VS Code instance with locally build language server is |
77 | possible. There's "Run Extension (Dev Server)" launch configuration for this. | 77 | possible. There's **"Run Extension (Dev Server)"** launch configuration for this. |
78 | 78 | ||
79 | In general, I use one of the following workflows for fixing bugs and | 79 | In general, I use one of the following workflows for fixing bugs and |
80 | implementing features. | 80 | implementing features. |
@@ -88,7 +88,14 @@ Code to sanity check that the thing works as I expect. | |||
88 | 88 | ||
89 | If the problem concerns only the VS Code extension, I use **Run Extension** | 89 | If the problem concerns only the VS Code extension, I use **Run Extension** |
90 | launch configuration from `launch.json`. Notably, this uses the usual | 90 | launch configuration from `launch.json`. Notably, this uses the usual |
91 | `ra_lsp_server` binary from `PATH`. After I am done with the fix, I use `cargo | 91 | `ra_lsp_server` binary from `PATH`. For this it is important to have the following |
92 | in `setting.json` file: | ||
93 | ```json | ||
94 | { | ||
95 | "rust-analyzer.raLspServerPath": "ra_lsp_server" | ||
96 | } | ||
97 | ``` | ||
98 | After I am done with the fix, I use `cargo | ||
92 | xtask install --client-code` to try the new extension for real. | 99 | xtask install --client-code` to try the new extension for real. |
93 | 100 | ||
94 | If I need to fix something in the `ra_lsp_server` crate, I feel sad because it's | 101 | If I need to fix something in the `ra_lsp_server` crate, I feel sad because it's |
diff --git a/docs/user/README.md b/docs/user/README.md index da99a063c..14ca6fd64 100644 --- a/docs/user/README.md +++ b/docs/user/README.md | |||
@@ -1,16 +1,26 @@ | |||
1 | [github-releases]: https://github.com/rust-analyzer/rust-analyzer/releases | ||
2 | |||
1 | The main interface to rust-analyzer is the | 3 | The main interface to rust-analyzer is the |
2 | [LSP](https://microsoft.github.io/language-server-protocol/) implementation. To | 4 | [LSP](https://microsoft.github.io/language-server-protocol/) implementation. To |
3 | install lsp server, clone the repository and then run `cargo xtask install | 5 | install lsp server, you have three options: |
4 | --server` (which is shorthand for `cargo install --path | 6 | |
5 | ./crates/ra_lsp_server`). This will produce a binary named `ra_lsp_server` which | 7 | * **Preferred and default:** install the plugin/extension for your IDE and it will ask your permission to automatically download the latest lsp server for you from [GitHub releases][github-releases]. (See docs to find out whether this is implemented for your editor below). |
6 | you should be able to use it with any LSP-compatible editor. We use custom | 8 | * Manually download prebuilt binaries from [GitHub releases][github-releases] |
7 | extensions to LSP, so special client-side support is required to take full | 9 | * `ra_lsp_server-linux` for Linux |
8 | advantage of rust-analyzer. This repository contains support code for VS Code. | 10 | * `ra_lsp_server-mac` for Mac |
9 | 11 | * `ra_lsp_server-windows.exe` for Windows | |
10 | ``` | 12 | * Clone the repository and build from sources |
13 | ```bash | ||
11 | $ git clone [email protected]:rust-analyzer/rust-analyzer && cd rust-analyzer | 14 | $ git clone [email protected]:rust-analyzer/rust-analyzer && cd rust-analyzer |
12 | $ cargo xtask install --server | 15 | $ cargo xtask install --server # or cargo install --path ./crates/ra_lsp_server |
13 | ``` | 16 | ``` |
17 | |||
18 | This way you will get a binary named `ra_lsp_server` (with os suffix for prebuilt binaries) | ||
19 | which you should be able to use with any LSP-compatible editor. | ||
20 | |||
21 | We make use of custom extensions to LSP, so special client-side support is required to take full | ||
22 | advantage of rust-analyzer. This repository contains support code for VS Code. | ||
23 | |||
14 | Rust Analyzer needs sources of rust standard library to work, so | 24 | Rust Analyzer needs sources of rust standard library to work, so |
15 | you might also need to execute | 25 | you might also need to execute |
16 | 26 | ||
@@ -22,16 +32,55 @@ See [./features.md](./features.md) document for a list of features that are avai | |||
22 | 32 | ||
23 | ## VS Code | 33 | ## VS Code |
24 | 34 | ||
25 | Prerequisites: | 35 | ### Prerequisites |
26 | |||
27 | In order to build the VS Code plugin, you need to have node.js and npm with | ||
28 | a minimum version of 10 installed. Please refer to | ||
29 | [node.js and npm documentation](https://nodejs.org) for installation instructions. | ||
30 | 36 | ||
31 | You will also need the most recent version of VS Code: we don't try to | 37 | You will need the most recent version of VS Code: we don't try to |
32 | maintain compatibility with older versions yet. | 38 | maintain compatibility with older versions yet. |
33 | 39 | ||
34 | The experimental VS Code plugin can then be built and installed by executing the | 40 | ### Installation from prebuilt binaries |
41 | |||
42 | We ship prebuilt binaries for Linux, Mac and Windows via | ||
43 | [GitHub releases][github-releases]. | ||
44 | In order to use them you need to install the client VSCode extension. | ||
45 | |||
46 | Publishing to VS Code marketplace is currently WIP. Thus, you need to manually download | ||
47 | `rust-analyzer-0.1.0.vsix` file from latest [GitHub release][github-releases]. | ||
48 | |||
49 | After you downloaded the `.vsix` file you can install it from the terminal | ||
50 | |||
51 | ``` | ||
52 | $ code --install-extension rust-analyzer-0.1.0.vsix | ||
53 | ``` | ||
54 | |||
55 | Or open VS Code, press <kbd>Ctrl+Shift+P</kbd>, and search for the following command: | ||
56 | |||
57 | <img width="500px" alt="Install from VSIX command" src="https://user-images.githubusercontent.com/36276403/74108225-c0c11d80-4b80-11ea-9b2a-0a43f09e29af.png"> | ||
58 | |||
59 | Press <kbd>Enter</kbd> and go to `rust-analyzer-0.1.0.vsix` file through the file explorer. | ||
60 | |||
61 | Then open some Rust project and you should | ||
62 | see an info message pop-up. | ||
63 | |||
64 | <img height="140px" src="https://user-images.githubusercontent.com/36276403/74103174-a40df100-4b52-11ea-81f4-372c70797924.png" alt="Download now message"/> | ||
65 | |||
66 | |||
67 | Click `Download now`, wait until the progress is 100% and you are ready to go. | ||
68 | |||
69 | For updates you need to remove installed binary | ||
70 | ``` | ||
71 | rm -rf ${HOME}/.config/Code/User/globalStorage/matklad.rust-analyzer | ||
72 | ``` | ||
73 | |||
74 | `"Download latest language server"` command for VSCode and automatic updates detection is currently WIP. | ||
75 | |||
76 | |||
77 | ### Installation from sources | ||
78 | |||
79 | In order to build the VS Code plugin from sources, you need to have node.js and npm with | ||
80 | a minimum version of 12 installed. Please refer to | ||
81 | [node.js and npm documentation](https://nodejs.org) for installation instructions. | ||
82 | |||
83 | The experimental VS Code plugin can be built and installed by executing the | ||
35 | following commands: | 84 | following commands: |
36 | 85 | ||
37 | ``` | 86 | ``` |
@@ -40,12 +89,23 @@ $ cd rust-analyzer | |||
40 | $ cargo xtask install | 89 | $ cargo xtask install |
41 | ``` | 90 | ``` |
42 | 91 | ||
92 | After that you need to amend your `settings.json` file to explicitly specify the | ||
93 | path to `ra_lsp_server` that you've just built. | ||
94 | ```json | ||
95 | { | ||
96 | "rust-analyzer.raLspServerPath": "ra_lsp_server" | ||
97 | } | ||
98 | ``` | ||
99 | This should work on all platforms, otherwise if installed `ra_lsp_server` is not available through your `$PATH` then see how to configure it [here](#setting-up-the-PATH-variable). | ||
100 | |||
101 | |||
43 | The automatic installation is expected to *just work* for common cases, if it | 102 | The automatic installation is expected to *just work* for common cases, if it |
44 | doesn't, report bugs! | 103 | doesn't, report bugs! |
45 | 104 | ||
46 | **Note** [#1831](https://github.com/rust-analyzer/rust-analyzer/issues/1831): If you are using the popular | 105 | **Note** [#1831](https://github.com/rust-analyzer/rust-analyzer/issues/1831): If you are using the popular |
47 | [Vim emulation plugin](https://github.com/VSCodeVim/Vim), you will likely | 106 | [Vim emulation plugin](https://github.com/VSCodeVim/Vim), you will likely |
48 | need to turn off the `rust-analyzer.enableEnhancedTyping` setting. | 107 | need to turn off the `rust-analyzer.enableEnhancedTyping` setting. |
108 | (// TODO: This configuration is no longer available, enhanced typing shoud be disabled via removing Enter key binding, [see this issue](https://github.com/rust-analyzer/rust-analyzer/issues/3051)) | ||
49 | 109 | ||
50 | If you have an unusual setup (for example, `code` is not in the `PATH`), you | 110 | If you have an unusual setup (for example, `code` is not in the `PATH`), you |
51 | should adapt these manual installation instructions: | 111 | should adapt these manual installation instructions: |
@@ -95,7 +155,7 @@ host. | |||
95 | As an example, [Pale Fire](https://github.com/matklad/pale-fire/) color scheme tweaks rust colors. | 155 | As an example, [Pale Fire](https://github.com/matklad/pale-fire/) color scheme tweaks rust colors. |
96 | * `rust-analyzer.enableEnhancedTyping`: by default, rust-analyzer intercepts the | 156 | * `rust-analyzer.enableEnhancedTyping`: by default, rust-analyzer intercepts the |
97 | `Enter` key to make it easier to continue comments. Note that it may conflict with VIM emulation plugin. | 157 | `Enter` key to make it easier to continue comments. Note that it may conflict with VIM emulation plugin. |
98 | * `rust-analyzer.raLspServerPath`: path to `ra_lsp_server` executable | 158 | * `rust-analyzer.raLspServerPath`: path to `ra_lsp_server` executable, when absent or `null` defaults to prebuilt binary path |
99 | * `rust-analyzer.enableCargoWatchOnStartup`: prompt to install & enable `cargo | 159 | * `rust-analyzer.enableCargoWatchOnStartup`: prompt to install & enable `cargo |
100 | watch` for live error highlighting (note, this **does not** use rust-analyzer) | 160 | watch` for live error highlighting (note, this **does not** use rust-analyzer) |
101 | * `rust-analyzer.excludeGlobs`: a list of glob-patterns for exclusion (see globset [docs](https://docs.rs/globset) for syntax). | 161 | * `rust-analyzer.excludeGlobs`: a list of glob-patterns for exclusion (see globset [docs](https://docs.rs/globset) for syntax). |
@@ -200,6 +260,8 @@ Installation: | |||
200 | 260 | ||
201 | * 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) | 261 | * 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) |
202 | 262 | ||
263 | |||
264 | <!-- Update links to this header when changing it! --> | ||
203 | ### Setting up the `PATH` variable | 265 | ### Setting up the `PATH` variable |
204 | 266 | ||
205 | On Unix systems, `rustup` adds `~/.cargo/bin` to `PATH` by modifying the shell's | 267 | On Unix systems, `rustup` adds `~/.cargo/bin` to `PATH` by modifying the shell's |
diff --git a/docs/user/assists.md b/docs/user/assists.md index 1e2dd7485..f737a2fa4 100644 --- a/docs/user/assists.md +++ b/docs/user/assists.md | |||
@@ -154,20 +154,6 @@ impl Trait<u32> for () { | |||
154 | } | 154 | } |
155 | ``` | 155 | ``` |
156 | 156 | ||
157 | ## `add_import` | ||
158 | |||
159 | Adds a use statement for a given fully-qualified path. | ||
160 | |||
161 | ```rust | ||
162 | // BEFORE | ||
163 | fn process(map: std::collections::┃HashMap<String, String>) {} | ||
164 | |||
165 | // AFTER | ||
166 | use std::collections::HashMap; | ||
167 | |||
168 | fn process(map: HashMap<String, String>) {} | ||
169 | ``` | ||
170 | |||
171 | ## `add_new` | 157 | ## `add_new` |
172 | 158 | ||
173 | Adds a new inherent impl for a type. | 159 | Adds a new inherent impl for a type. |
@@ -568,6 +554,20 @@ fn handle(action: Action) { | |||
568 | } | 554 | } |
569 | ``` | 555 | ``` |
570 | 556 | ||
557 | ## `replace_qualified_name_with_use` | ||
558 | |||
559 | Adds a use statement for a given fully-qualified name. | ||
560 | |||
561 | ```rust | ||
562 | // BEFORE | ||
563 | fn process(map: std::collections::┃HashMap<String, String>) {} | ||
564 | |||
565 | // AFTER | ||
566 | use std::collections::HashMap; | ||
567 | |||
568 | fn process(map: HashMap<String, String>) {} | ||
569 | ``` | ||
570 | |||
571 | ## `split_import` | 571 | ## `split_import` |
572 | 572 | ||
573 | Wraps the tail of import into braces. | 573 | Wraps the tail of import into braces. |