2019-06-05 09:49:02 +03:00
|
|
|
#+TITLE: lang/rust
|
|
|
|
#+DATE: June 5, 2019
|
2019-11-23 16:12:06 -05:00
|
|
|
#+SINCE: v3.0.0
|
2019-06-05 09:49:02 +03:00
|
|
|
#+STARTUP: inlineimages
|
|
|
|
|
|
|
|
* Table of Contents :TOC_3:noexport:
|
|
|
|
- [[#description][Description]]
|
|
|
|
- [[#module-flags][Module Flags]]
|
|
|
|
- [[#plugins][Plugins]]
|
2019-06-05 09:59:44 +03:00
|
|
|
- [[#hacks][Hacks]]
|
2019-06-05 09:49:02 +03:00
|
|
|
- [[#prerequisites][Prerequisites]]
|
|
|
|
- [[#features][Features]]
|
2019-11-23 16:12:06 -05:00
|
|
|
- [[#keybinds][Keybinds]]
|
2019-06-05 09:49:02 +03:00
|
|
|
- [[#configuration][Configuration]]
|
2019-11-23 16:12:06 -05:00
|
|
|
- [[#enable-rust-analyzer][Enable rust-analyzer]]
|
2019-06-05 09:49:02 +03:00
|
|
|
- [[#troubleshooting][Troubleshooting]]
|
|
|
|
|
|
|
|
* Description
|
2019-11-23 16:12:06 -05:00
|
|
|
This module adds support for the Rust language and integration for its tools,
|
|
|
|
e.g. ~cargo~.
|
2019-06-05 09:59:44 +03:00
|
|
|
|
|
|
|
+ Code completion (~racer~)
|
|
|
|
+ Syntax checking (~flycheck~)
|
2019-11-23 16:12:06 -05:00
|
|
|
+ LSP support (for rls and rust-analyzer) (~rustic~)
|
2019-06-05 09:59:44 +03:00
|
|
|
+ Snippets
|
2019-06-05 09:49:02 +03:00
|
|
|
|
|
|
|
** Module Flags
|
|
|
|
+ ~+lsp~ to add support Language server protocol.
|
|
|
|
|
|
|
|
** Plugins
|
2019-11-23 16:00:14 -05:00
|
|
|
+ [[https://github.com/brotzeit/rustic][rustic]]
|
|
|
|
+ [[https://github.com/racer-rust/emacs-racer][racer]]* (unless =+lsp=)
|
2019-06-05 09:59:44 +03:00
|
|
|
|
|
|
|
** Hacks
|
2019-11-23 16:12:06 -05:00
|
|
|
+ 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.
|
2017-11-02 20:00:43 +01:00
|
|
|
|
2019-06-05 09:49:02 +03:00
|
|
|
* Prerequisites
|
2019-11-23 16:12:06 -05:00
|
|
|
This module only requires ~rust~, which can be acquired through =rustup=:
|
2017-11-02 20:00:43 +01:00
|
|
|
|
|
|
|
~curl https://sh.rustup.rs -sSf | sh~
|
|
|
|
|
2019-11-23 16:12:06 -05:00
|
|
|
Optionally, this module also uses the following programs:
|
2017-11-02 20:00:43 +01:00
|
|
|
|
2019-11-23 16:12:06 -05:00
|
|
|
+ =racer= (if not using LSP): ~cargo +nightly install racer~ (requires rust nightly)
|
|
|
|
+ =RLS= or =rust-analyzer= (for LSP users)
|
|
|
|
+ =rustfmt= for ~:editor format~: ~rustup component add rustfmt-preview~
|
2019-09-26 13:41:05 -04:00
|
|
|
+ The following commands require:
|
|
|
|
+ ~cargo-process-check~: ~cargo install cargo-check~
|
2019-09-27 14:39:17 -04:00
|
|
|
+ ~cargo-process-clippy~: ~rustup component add clippy-preview~
|
2019-07-04 21:13:21 +02:00
|
|
|
|
2019-06-05 09:49:02 +03:00
|
|
|
* Features
|
2019-11-23 16:12:06 -05:00
|
|
|
This module also supports LSP, if you have [[https://github.com/rust-lang/rls][the Rust Language Server]] or
|
|
|
|
[[https://github.com/rust-analyzer/rust-analyzer][rust-analyzer]] installed. To enable it, you must enable the =:tools lsp= module
|
|
|
|
and the ~+lsp~ flag on this module.
|
2017-11-02 20:00:43 +01:00
|
|
|
|
2019-11-23 16:12:06 -05:00
|
|
|
** Keybinds
|
2019-07-04 21:33:13 +02:00
|
|
|
| Binding | Description |
|
|
|
|
|---------------------+-----------------------------|
|
2019-11-23 16:12:06 -05:00
|
|
|
| ~<localleader> b a~ | ~cargo audit~ |
|
2019-07-05 16:15:05 +02:00
|
|
|
| ~<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~ |
|
2019-11-23 16:12:06 -05:00
|
|
|
| ~<localleader> b n~ | ~cargo update~ |
|
|
|
|
| ~<localleader> b o~ | ~cargo outdated~ |
|
2019-07-05 16:15:05 +02:00
|
|
|
| ~<localleader> b r~ | ~cargo run~ |
|
2019-07-04 21:33:13 +02:00
|
|
|
| ~<localleader> t a~ | ~cargo test~ |
|
|
|
|
| ~<localleader> t t~ | ~run current test~ |
|
2017-11-02 20:00:43 +01:00
|
|
|
|
2019-06-05 09:49:02 +03:00
|
|
|
* TODO Configuration
|
2019-11-23 16:12:06 -05:00
|
|
|
** Enable rust-analyzer
|
|
|
|
You'll need [[https://github.com/rust-analyzer/rust-analyzer][rust-analyzer]] installed on your system, then:
|
2017-11-02 20:00:43 +01:00
|
|
|
|
2019-11-23 16:12:06 -05:00
|
|
|
#+BEGIN_SRC elisp
|
|
|
|
(after! rustic
|
|
|
|
(setq rustic-lsp-server 'rust-analyzer))
|
2019-06-05 09:49:02 +03:00
|
|
|
#+END_SRC
|
2019-11-23 16:12:06 -05:00
|
|
|
|
|
|
|
* TODO Troubleshooting
|