rust/docs/user/README.md

78 lines
2.9 KiB
Markdown
Raw Normal View History

2019-03-20 04:17:12 -05:00
The main interface to rust-analyzer is the
[LSP](https://microsoft.github.io/language-server-protocol/) implementation. To
install lsp server, use `cargo install-lsp`, which is a shorthand for `cargo
install --package ra_lsp_server`. The binary is named `ra_lsp_server`, you
should be able to use it with any LSP-compatible editor. We use custom
extensions to LSP, so special client-side support is required to take full
advantage of rust-analyzer. This repository contains support code for VS Code
and Emacs.
Rust Analyzer needs sources of rust standard library to work, so you might need
to execute
```
$ rustup component add rust-src
```
2019-03-20 04:21:55 -05:00
See [./features.md](./features.md) document for a list of features that are available.
2019-03-20 04:17:12 -05:00
## VS Code
2019-02-10 15:09:33 -06:00
2019-03-13 09:23:22 -05:00
Prerequisites:
2019-02-10 15:09:33 -06:00
In order to build the VS Code plugin, you need to have node.js and npm with
a minimum version of 10 installed. Please refer to
[node.js and npm documentation](https://nodejs.org) for installation instructions.
2019-02-12 09:28:39 -06:00
You will also need the most recent version of VS Code: we don't try to
maintain compatibility with older versions yet.
2019-02-10 15:09:33 -06:00
The experimental VS Code plugin can then be built and installed by executing the
following commands:
2018-09-16 07:36:09 -05:00
```
$ git clone https://github.com/rust-analyzer/rust-analyzer.git --depth 1
2018-12-27 08:56:07 -06:00
$ cd rust-analyzer
2018-09-16 07:36:09 -05:00
$ cargo install-code
```
2019-01-13 08:13:54 -06:00
This will run `cargo install --package ra_lsp_server` to install the server
2019-01-13 06:04:05 -06:00
binary into `~/.cargo/bin`, and then will build and install plugin from
`editors/code`. See
2019-03-20 04:17:12 -05:00
[this](https://github.com/rust-analyzer/rust-analyzer/blob/69ee5c9c5ef212f7911028c9ddf581559e6565c3/crates/tools/src/main.rs#L37-L56)
2019-01-13 06:04:05 -06:00
for details. The installation is expected to *just work*, if it doesn't, report
bugs!
2018-09-16 07:36:09 -05:00
It's better to remove existing Rust plugins to avoid interference.
2019-03-20 04:17:12 -05:00
Beyond basic LSP features, there are some extension commands which you can
2019-03-20 04:21:55 -05:00
invoke via <kbd>Ctrl+Shift+P</kbd> or bind to a shortcut. See [./features.md](./features.md)
2019-03-20 04:17:12 -05:00
for details.
2019-01-13 06:04:05 -06:00
2019-03-20 04:17:12 -05:00
### Settings
2019-01-13 06:04:05 -06:00
2019-03-20 04:17:12 -05:00
* `rust-analyzer.highlightingOn`: enables experimental syntax highlighting
* `rust-analyzer.showWorkspaceLoadedNotification`: to ease troubleshooting, a
notification is shown by default when a workspace is loaded
* `rust-analyzer.enableEnhancedTyping`: by default, rust-analyzer intercepts
`Enter` key to make it easier to continue comments
* `rust-analyzer.raLspServerPath`: path to `ra_lsp_server` executable
* `rust-analyzer.enableCargoWatchOnStartup`: prompt to install & enable `cargo
watch` for live error highlighting (note, this **does not** use rust-analyzer)
* `rust-analyzer.trace.server`: enables internal logging
2019-01-13 06:04:05 -06:00
2019-03-20 04:17:12 -05:00
## Emacs
2018-09-16 07:36:09 -05:00
2019-03-20 04:17:12 -05:00
Prerequisites:
2019-01-13 08:13:54 -06:00
2019-03-20 04:17:12 -05:00
`emacs-lsp`, `dash` and `ht` packages.
2019-01-13 08:13:54 -06:00
2019-03-20 04:17:12 -05:00
Installation:
2019-01-13 08:13:54 -06:00
2019-03-20 04:17:12 -05:00
* add
[ra-emacs-lsp.el](https://github.com/rust-analyzer/rust-analyzer/blob/69ee5c9c5ef212f7911028c9ddf581559e6565c3/editors/emacs/ra-emacs-lsp.el)
to load path and require it in `init.el`
* run `lsp` in a rust buffer
2019-03-20 07:25:05 -05:00
* (Optionally) bind commands like `rust-analyzer-join-lines` or `rust-analyzer-extend-selection` to keys