From 49d494c03307cff75057a856eadc5ebb5ff1ea9d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=BCnter=20Z=C3=B6chbauer?= Date: Sun, 26 Apr 2020 15:44:05 +0200 Subject: Clarify rust-analyzer binary install --- docs/user/readme.adoc | 30 +++++++++++++++++++++++------- 1 file changed, 23 insertions(+), 7 deletions(-) diff --git a/docs/user/readme.adoc b/docs/user/readme.adoc index ce5704836..5e4ce3055 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 == Installation -In theory, one should be able to just install the server binary and have it automatically work with any editor. +In theory, one should be able to just install the <> and have it automatically work with any editor. We are not there yet, so some editor specific setup is required. Additionally, rust-analyzer needs the sources of the standard library. @@ -94,7 +94,8 @@ $ git clone https://github.com/rust-analyzer/rust-analyzer.git && cd rust-analyz $ cargo xtask install ---- -You'll need Cargo, nodejs and npm for this. +You'll need Cargo, xtask, nodejs and npm for this. +Cargo-xtask can be found at https://github.com/matklad/cargo-xtask Note that installing via `xtask install` does not work for VS Code Remote, instead you'll need to install the `.vsix` manually. @@ -108,18 +109,29 @@ Here are some useful self-diagnostic commands: * To log all LSP requests, add `"rust-analyzer.trace.server": "verbose"` to the settings and look for `Server Trace` in the panel. * To enable client-side logging, add `"rust-analyzer.trace.extension": true` to the settings and open the `Console` tab of VS Code developer tools. -=== Language Server Binary +=== rust-analyzer Language Server Binary Other editors generally require the `rust-analyzer` binary to be in `$PATH`. 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`. +On Linux to install the `rust-analyzer` binary into `~/.cargo/bin` which usually is already added to `$PATH`, this commands could be used + +[source,bash] +---- +$ curl -L https://github.com/rust-analyzer/rust-analyzer/releases/latest/download/rust-analyzer-linux -o ~/.cargo/bin/rust-analyzer +$ chmod +x ~/.cargo/bin/rust-analyzer +---- + Alternatively, you can install it from source using the following command: [source,bash] ---- +$ git clone https://github.com/rust-analyzer/rust-analyzer.git && cd rust-analyzer $ cargo xtask install --server ---- +Cargo-xtask can be found at https://github.com/matklad/cargo-xtask + If 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. ==== Arch Linux @@ -139,15 +151,19 @@ $ yay -S rust-analyzer-bin === Emacs -Emacs support is maintained https://github.com/emacs-lsp/lsp-mode/blob/master/lsp-rust.el[upstream]. +Prerequisites: You have installed the <>. -1. Install the most recent version of `emacs-lsp` package by following the instructions https://github.com/emacs-lsp/lsp-mode[here]. +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]. + +1. Install the most recent version of `emacs-lsp` package by following the https://github.com/emacs-lsp/lsp-mode[Emacs-LSP instructions]. 2. Set `lsp-rust-server` to `'rust-analyzer`. 3. Run `lsp` in a Rust buffer. 4. (Optionally) bind commands like `lsp-rust-analyzer-join-lines`, `lsp-extend-selection` and `lsp-rust-analyzer-expand-macro` to keys. === Vim +Prerequisites: You have installed the <>. + The are several LSP client implementations for vim: ==== coc-rust-analyzer @@ -205,7 +221,7 @@ Once `neovim/nvim-lsp` is installed, use `+lua require'nvim_lsp'.rust_analyzer.s === Sublime Text 3 -Prerequisites: You have installed the <>. +Prerequisites: You have installed the <>. You also need the `LSP` package. To install it: @@ -218,7 +234,7 @@ Finally, with your Rust project open, in the command palette, run `LSP: Enable L 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. -If you get an error saying `No such file or directory: 'rust-analyzer'`, see the <>. +If you get an error saying `No such file or directory: 'rust-analyzer'`, see the <> section on installing the language server binary. == Usage -- cgit v1.2.3 From 482e912fa0b1df03c6ad99c1d92a894889811e00 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=BCnter=20Z=C3=B6chbauer?= Date: Sun, 26 Apr 2020 17:08:15 +0200 Subject: xtask does not need to be installed because it's contained in the dart-analyzer repo. --- docs/user/readme.adoc | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/docs/user/readme.adoc b/docs/user/readme.adoc index 5e4ce3055..c6c0f3ed8 100644 --- a/docs/user/readme.adoc +++ b/docs/user/readme.adoc @@ -94,8 +94,7 @@ $ git clone https://github.com/rust-analyzer/rust-analyzer.git && cd rust-analyz $ cargo xtask install ---- -You'll need Cargo, xtask, nodejs and npm for this. -Cargo-xtask can be found at https://github.com/matklad/cargo-xtask +You'll need Cargo, nodejs and npm for this. Note that installing via `xtask install` does not work for VS Code Remote, instead you'll need to install the `.vsix` manually. @@ -130,8 +129,6 @@ $ git clone https://github.com/rust-analyzer/rust-analyzer.git && cd rust-analyz $ cargo xtask install --server ---- -Cargo-xtask can be found at https://github.com/matklad/cargo-xtask - If 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. ==== Arch Linux -- cgit v1.2.3 From 5df4a79951cde6eb84873ee239598993d0b6858f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=BCnter=20Z=C3=B6chbauer?= Date: Sun, 26 Apr 2020 17:11:44 +0200 Subject: Change install directory suggestion to `~/.local/bin` instead of `~/.cargo/bin` --- docs/user/readme.adoc | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/docs/user/readme.adoc b/docs/user/readme.adoc index c6c0f3ed8..60113e1e0 100644 --- a/docs/user/readme.adoc +++ b/docs/user/readme.adoc @@ -113,14 +113,16 @@ Here are some useful self-diagnostic commands: Other editors generally require the `rust-analyzer` binary to be in `$PATH`. 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`. -On Linux to install the `rust-analyzer` binary into `~/.cargo/bin` which usually is already added to `$PATH`, this commands could be used +On Linux to install the `rust-analyzer` binary into `~/.local/bin`, this commands could be used [source,bash] ---- -$ curl -L https://github.com/rust-analyzer/rust-analyzer/releases/latest/download/rust-analyzer-linux -o ~/.cargo/bin/rust-analyzer -$ chmod +x ~/.cargo/bin/rust-analyzer +$ curl -L https://github.com/rust-analyzer/rust-analyzer/releases/latest/download/rust-analyzer-linux -o ~/.local/bin/rust-analyzer +$ chmod +x ~/.local/bin/rust-analyzer ---- +Ensure `~/cargo/bin` is listed in the `$PATH` variable. + Alternatively, you can install it from source using the following command: [source,bash] -- cgit v1.2.3 From 999e3312e08de144c1f23bccd20a9f35f1680a38 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=BCnter=20Z=C3=B6chbauer?= Date: Sun, 26 Apr 2020 19:40:13 +0200 Subject: Add missing . --- docs/user/readme.adoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/user/readme.adoc b/docs/user/readme.adoc index 60113e1e0..76d065d35 100644 --- a/docs/user/readme.adoc +++ b/docs/user/readme.adoc @@ -121,7 +121,7 @@ $ curl -L https://github.com/rust-analyzer/rust-analyzer/releases/latest/downloa $ chmod +x ~/.local/bin/rust-analyzer ---- -Ensure `~/cargo/bin` is listed in the `$PATH` variable. +Ensure `~/.local/bin` is listed in the `$PATH` variable. Alternatively, you can install it from source using the following command: -- cgit v1.2.3