- Description
- Prerequisites
- Features
- Configuration
- Troubleshooting
- [[#errore0670-async-fn-is-not-permitted-in-the-2015-edition][error[E0670]: `async fn` is not permitted in the 2015 edition]]
This module adds support for the Rust language and integration for its tools,
e.g. cargo.
- Code completion (
raceror an LSP server) - Syntax checking (
flycheck) - LSP support (for rust-analyzer and rls) (
rustic) - Snippets
+lspto add support Language server protocol. Will use the first ofrust-analyzerorrls(in that order).
- rustic has been modified not to automatically install lsp-mode or elgot if
they’re missing. Doom expects you to have enabled the
:tools lspmodule yourself.
This module requires rust, which can be acquired through rustup:
curl https://sh.rustup.rs -sSf | sh
Additional requirements depend on the module’s configuration:
- If
:editor formatis enabled, you’ll needrustfmt:rustup component add rustfmt-preview. - Users without
+lspenabled will needracer:cargo +nightly install racer(with requires rust nightly edition). - Users with
+lspenabled will need:rust-analyzerorrls
- To use The following commands require:
cargo-process-check:cargo install cargo-checkcargo-process-clippy:rustup component add clippy-preview
This module supports LSP integration. For it to work you’ll need:
- Either rust-analyzer or the Rust Language Server installed (e.g. through your OS package manager).
- The
:tools lspmodule enabled. - The
+lspflag on this module enabled.
Enable the :editor format module’s +onsave flag to get formatting on save with
rustfmt. No additional configuration is necessary.
| Binding | Description |
|---|---|
<localleader> b a | cargo audit |
<localleader> b b | cargo build |
<localleader> b B | cargo bench |
<localleader> b c | cargo check |
<localleader> b C | cargo clippy |
<localleader> b d | cargo doc |
<localleader> b n | cargo update |
<localleader> b o | cargo outdated |
<localleader> b r | cargo run |
<localleader> t a | cargo test |
<localleader> t t | run current test |
If both rls and rust-analyzer are present on your system, rust-analyzer is
selected by default. Modify rustic-lsp-server to change the default:
;; in $DOOMDIR/config.el
(after! rustic
(setq rustic-lsp-server 'rls))Doom’s :tools lsp module has an +eglot flag. Enable it and this module will
use eglot instead.
You may be seeing this error, despite having edition = "2018" in your
Cargo.toml. This error actually originates from rustfmt, which the LSP
server tries to invoke on save (if you have rustic-format-on-save or :editor
format enabled).
To fix this your project needs a rustfmt.toml with edition = "2018" in it.