lang/rust: update README #2108

This commit is contained in:
Henrik Lissner 2019-11-23 16:12:06 -05:00
parent c86d400518
commit 2769a1e24f
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395

View file

@ -1,6 +1,6 @@
#+TITLE: lang/rust #+TITLE: lang/rust
#+DATE: June 5, 2019 #+DATE: June 5, 2019
#+SINCE: {replace with next tagged release version} #+SINCE: v3.0.0
#+STARTUP: inlineimages #+STARTUP: inlineimages
* Table of Contents :TOC_3:noexport: * Table of Contents :TOC_3:noexport:
@ -10,15 +10,18 @@
- [[#hacks][Hacks]] - [[#hacks][Hacks]]
- [[#prerequisites][Prerequisites]] - [[#prerequisites][Prerequisites]]
- [[#features][Features]] - [[#features][Features]]
- [[#keybinds][Keybinds]]
- [[#configuration][Configuration]] - [[#configuration][Configuration]]
- [[#enable-rust-analyzer][Enable rust-analyzer]]
- [[#troubleshooting][Troubleshooting]] - [[#troubleshooting][Troubleshooting]]
- [[#racer-installation-problems][Racer installation problems]]
* Description * Description
Add support to Rust language and cargo commands inside emacs. This module adds support for the Rust language and integration for its tools,
e.g. ~cargo~.
+ Code completion (~racer~) + Code completion (~racer~)
+ Syntax checking (~flycheck~) + Syntax checking (~flycheck~)
+ LSP support (for rls and rust-analyzer) (~rustic~)
+ Snippets + Snippets
** Module Flags ** Module Flags
@ -29,56 +32,50 @@ Add support to Rust language and cargo commands inside emacs.
+ [[https://github.com/racer-rust/emacs-racer][racer]]* (unless =+lsp=) + [[https://github.com/racer-rust/emacs-racer][racer]]* (unless =+lsp=)
** Hacks ** Hacks
{A list of internal modifications to included packages} + 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.
* Prerequisites * Prerequisites
To get started with Rust, you can either use =rustup= and install rust with: This module only requires ~rust~, which can be acquired through =rustup=:
~curl https://sh.rustup.rs -sSf | sh~ ~curl https://sh.rustup.rs -sSf | sh~
Package manager is not recommended to install Nightly version of Rust what is Optionally, this module also uses the following programs:
required for ~racer~ from [[https://github.com/racer-rust/racer#installation][version 2.1]] (more info in [[#Troubleshooting][Troubleshooting]])
Some features have additional dependencies: + =racer= (if not using LSP): ~cargo +nightly install racer~ (requires rust nightly)
+ =RLS= or =rust-analyzer= (for LSP users)
+ The ~:editor format~ module uses ~rustfmt~ for rust files: ~rustup component + =rustfmt= for ~:editor format~: ~rustup component add rustfmt-preview~
add rustfmt-preview~
+ The following commands require: + 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~
+ ~cargo-process-{add,rm,upgrade}~: ~cargo install cargo-edit~
* Features * Features
This module also supports LSP, it requires installation of Rust Language Server This module also supports LSP, if you have [[https://github.com/rust-lang/rls][the Rust Language Server]] or
[[https://github.com/rust-lang/rls][~RLS~]]. To enable this you need to enable ~lsp~ in ~:tools~ section in ~init.el~ file. [[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.
Keybindings
** Keybinds
| Binding | Description | | Binding | Description |
|---------------------+-----------------------------| |---------------------+-----------------------------|
| ~<localleader> b a~ | ~cargo add~ | | ~<localleader> b a~ | ~cargo audit~ |
| ~<localleader> b b~ | ~cargo build~ | | ~<localleader> b b~ | ~cargo build~ |
| ~<localleader> b B~ | ~cargo bench~ | | ~<localleader> b B~ | ~cargo bench~ |
| ~<localleader> b c~ | ~cargo check~ | | ~<localleader> b c~ | ~cargo check~ |
| ~<localleader> b C~ | ~cargo clippy~ | | ~<localleader> b C~ | ~cargo clippy~ |
| ~<localleader> b d~ | ~cargo doc~ | | ~<localleader> b d~ | ~cargo doc~ |
| ~<localleader> b n~ | ~cargo update~ |
| ~<localleader> b o~ | ~cargo outdated~ |
| ~<localleader> b r~ | ~cargo run~ | | ~<localleader> b r~ | ~cargo run~ |
| ~<localleader> b s~ | ~cargo search~ |
| ~<localleader> b u~ | ~cargo update~ |
| ~<localleader> t a~ | ~cargo test~ | | ~<localleader> t a~ | ~cargo test~ |
| ~<localleader> t f~ | ~run tests in current file~ |
| ~<localleader> t t~ | ~run current test~ | | ~<localleader> t t~ | ~run current test~ |
* TODO Configuration * TODO Configuration
How to configure this module, including common problems and how to address them. ** Enable rust-analyzer
You'll need [[https://github.com/rust-analyzer/rust-analyzer][rust-analyzer]] installed on your system, then:
* Troubleshooting #+BEGIN_SRC elisp
** Racer installation problems (after! rustic
Racer need now ([[https://github.com/racer-rust/racer#installation][From 2.1 version]]) nightly version of Rust (setq rustic-lsp-server 'rust-analyzer))
If you installed trough rustup
#+BEGIN_SRC sh
rustup toolchain add nightly
cargo +nightly install racer
#+END_SRC #+END_SRC
* TODO Troubleshooting