lang/rust: update readme
This commit is contained in:
parent
6444662131
commit
00e9d8335c
1 changed files with 38 additions and 30 deletions
|
@ -10,9 +10,11 @@
|
||||||
- [[#hacks][Hacks]]
|
- [[#hacks][Hacks]]
|
||||||
- [[#prerequisites][Prerequisites]]
|
- [[#prerequisites][Prerequisites]]
|
||||||
- [[#features][Features]]
|
- [[#features][Features]]
|
||||||
|
- [[#lsp-support-rls-or-rust-analyzer][LSP support (rls or rust-analyzer)]]
|
||||||
|
- [[#format-on-save][Format on save]]
|
||||||
- [[#keybinds][Keybinds]]
|
- [[#keybinds][Keybinds]]
|
||||||
- [[#configuration][Configuration]]
|
- [[#configuration][Configuration]]
|
||||||
- [[#enable-rust-analyzer][Enable rust-analyzer]]
|
- [[#enable-rls-by-default][Enable RLS by default]]
|
||||||
- [[#enabling-elgot-support-for-rust][Enabling elgot support for Rust]]
|
- [[#enabling-elgot-support-for-rust][Enabling elgot support for Rust]]
|
||||||
- [[#troubleshooting][Troubleshooting]]
|
- [[#troubleshooting][Troubleshooting]]
|
||||||
|
|
||||||
|
@ -20,13 +22,14 @@
|
||||||
This module adds support for the Rust language and integration for its tools,
|
This module adds support for the Rust language and integration for its tools,
|
||||||
e.g. ~cargo~.
|
e.g. ~cargo~.
|
||||||
|
|
||||||
+ Code completion (~racer~)
|
+ Code completion (=racer= or an LSP server)
|
||||||
+ Syntax checking (~flycheck~)
|
+ Syntax checking (=flycheck=)
|
||||||
+ LSP support (for rls and rust-analyzer) (~rustic~)
|
+ LSP support (for rust-analyzer and rls) (=rustic=)
|
||||||
+ Snippets
|
+ Snippets
|
||||||
|
|
||||||
** Module Flags
|
** Module Flags
|
||||||
+ ~+lsp~ to add support Language server protocol.
|
+ ~+lsp~ to add support Language server protocol. Will use the first of
|
||||||
|
=rust-analyzer= or =rls= (in that order).
|
||||||
|
|
||||||
** Plugins
|
** Plugins
|
||||||
+ [[https://github.com/brotzeit/rustic][rustic]]
|
+ [[https://github.com/brotzeit/rustic][rustic]]
|
||||||
|
@ -34,28 +37,38 @@ e.g. ~cargo~.
|
||||||
|
|
||||||
** Hacks
|
** Hacks
|
||||||
+ rustic has been modified /not/ to automatically install lsp-mode or elgot if
|
+ rustic has been modified /not/ to automatically install lsp-mode or elgot if
|
||||||
they're missing. Doom expects you to enable the =:tools lsp= module yourself.
|
they're missing. Doom expects you to have enabled the =:tools lsp= module
|
||||||
+ rustic's LSP integration has been disabled in favor of the rls/rust-analyzer
|
yourself.
|
||||||
support provider by the lsp-mode package.
|
|
||||||
|
|
||||||
* Prerequisites
|
* Prerequisites
|
||||||
This module only requires ~rust~, which can be acquired through =rustup=:
|
This module requires ~rust~, which can be acquired through =rustup=:
|
||||||
|
|
||||||
~curl https://sh.rustup.rs -sSf | sh~
|
~curl https://sh.rustup.rs -sSf | sh~
|
||||||
|
|
||||||
Optionally, this module also uses the following programs:
|
Additional requirements depend on the module's configuration:
|
||||||
|
|
||||||
+ =racer= (if not using LSP): ~cargo +nightly install racer~ (requires rust nightly)
|
+ If =:editor format= is enabled, you'll need =rustfmt=: ~rustup component add
|
||||||
+ =RLS= or =rust-analyzer= (for LSP users)
|
rustfmt-preview~.
|
||||||
+ =rustfmt= for ~:editor format~: ~rustup component add rustfmt-preview~
|
+ Users without =+lsp= enabled will need =racer=: ~cargo +nightly install racer~
|
||||||
+ The following commands require:
|
(with requires rust nightly edition).
|
||||||
|
+ Users with =+lsp= enabled will need:
|
||||||
|
+ =rust-analyzer= or =rls=
|
||||||
|
+ To use The following commands require:
|
||||||
+ ~cargo-process-check~: ~cargo install cargo-check~
|
+ ~cargo-process-check~: ~cargo install cargo-check~
|
||||||
+ ~cargo-process-clippy~: ~rustup component add clippy-preview~
|
+ ~cargo-process-clippy~: ~rustup component add clippy-preview~
|
||||||
|
|
||||||
* Features
|
* Features
|
||||||
This module also supports LSP, if you have [[https://github.com/rust-lang/rls][the Rust Language Server]] or
|
** LSP support (rls or rust-analyzer)
|
||||||
[[https://github.com/rust-analyzer/rust-analyzer][rust-analyzer]] installed. To enable it, you must enable the =:tools lsp= module
|
This module supports LSP integration. For it to work you'll need:
|
||||||
and the ~+lsp~ flag on this module.
|
|
||||||
|
1. Either [[https://github.com/rust-analyzer/rust-analyzer][rust-analyzer]] or [[https://github.com/rust-lang/rls][the Rust Language Server]] installed (e.g. through your
|
||||||
|
OS package manager).
|
||||||
|
2. The =:tools lsp= module enabled.
|
||||||
|
3. The ~+lsp~ flag on this module enabled.
|
||||||
|
|
||||||
|
** Format on save
|
||||||
|
Enable the [[file:../../../modules/editor/format/README.org][:editor format]] module's =+onsave= flag to get formatting on save with
|
||||||
|
rustfmt. No additional configuration is necessary.
|
||||||
|
|
||||||
** Keybinds
|
** Keybinds
|
||||||
| Binding | Description |
|
| Binding | Description |
|
||||||
|
@ -73,23 +86,18 @@ and the ~+lsp~ flag on this module.
|
||||||
| ~<localleader> t t~ | ~run current test~ |
|
| ~<localleader> t t~ | ~run current test~ |
|
||||||
|
|
||||||
* TODO Configuration
|
* TODO Configuration
|
||||||
** Enable rust-analyzer
|
** Enable RLS by default
|
||||||
You'll need [[https://github.com/rust-analyzer/rust-analyzer][rust-analyzer]] installed on your system, then use the following:
|
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:
|
||||||
#+BEGIN_SRC elisp
|
|
||||||
;; in $DOOMDIR/config.el
|
|
||||||
(setq rustic-lsp-server 'rust-analyzer)
|
|
||||||
#+END_SRC
|
|
||||||
|
|
||||||
** Enabling elgot support for Rust
|
|
||||||
Doom doesn't have eglot support (yet), but if you've installed it yourself and
|
|
||||||
want rust to use eglot instead of LSP, use the following:
|
|
||||||
|
|
||||||
#+BEGIN_SRC elisp
|
#+BEGIN_SRC elisp
|
||||||
;; in $DOOMDIR/config.el
|
;; in $DOOMDIR/config.el
|
||||||
(after! rustic
|
(after! rustic
|
||||||
(setq rustic-lsp-server 'rust-analyzer ; optional
|
(setq rustic-lsp-server 'rls))
|
||||||
rustic-lsp-client 'eglot))
|
|
||||||
#+END_SRC
|
#+END_SRC
|
||||||
|
|
||||||
|
** Enabling elgot support for Rust
|
||||||
|
Doom's =:tools lsp= module has an =+eglot= flag. Enable it and this module will
|
||||||
|
use eglot instead.
|
||||||
|
|
||||||
* TODO Troubleshooting
|
* TODO Troubleshooting
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue