forked from doomemacs/core
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathREADME.org
More file actions
138 lines (109 loc) · 5.45 KB
/
Copy pathREADME.org
File metadata and controls
138 lines (109 loc) · 5.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
#+title: :lang rust
#+subtitle: Fe2O3.unwrap().unwrap().unwrap().unwrap()
#+created: September 30, 2015
#+since: 0.7
* Description :unfold:
This module adds support for the Rust language and integration for its tools,
e.g. ~cargo~.
- Code completion ([[doom-package:racer]] or an LSP server)
- Syntax checking ([[doom-package:flycheck]])
- LSP support (for rust-analyzer and rls) ([[doom-package:rustic]])
- Snippets
** Maintainers
- @hlissner
[[doom-contrib-maintainer:][Become a maintainer?]]
** Module flags
- +lsp ::
Enable LSP support for ~rustic-mode~. Requires [[doom-module::tools lsp]] and a langserver
(supports [[https://rust-analyzer.github.io/][rust-analyzer]] and rls).
- +tree-sitter ::
Leverages tree-sitter for better syntax highlighting and structural text
editing. Requires [[doom-module::tools tree-sitter]].
** Packages
- [[doom-package:rustic]]
** Hacks
- rustic has been modified /not/ to automatically install lsp-mode or eglot if
they're missing. Doom expects you to have enabled the [[doom-module::tools lsp]] module
yourself.
** TODO Changelog
# This section will be machine generated. Don't edit it by hand.
/This module does not have a changelog yet./
* Installation
[[id:01cffea4-3329-45e2-a892-95a384ab2338][Enable this module in your ~doom!~ block.]]
This module requires a working installation of [[https://www.rust-lang.org/][Rust]] for its more advanced
features, and offer only syntax highlighting otherwise. The simplest way to
install it is through [[https://rustup.rs][rustup]]:
#+begin_src sh
$ curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
# And can be updated later with:
$ rustup update --no-self-update
#+end_src
To install and manage Rust on Windows, consult [[https://forge.rust-lang.org/infra/other-installation-methods.html][Rust's official documentation]].
#+begin_quote
Once installed, I recommended that you add Cargo's executable to your
~$PATH~, so that the Emacs utilities that depend on it -- or any tools
installed through it -- can easily locate them (without any added
configuration on your part).
Also, if you have used ~$ doom env~ in the past, changes to your ~$PATH~
won't be visible to Doom until you run it (or ~$ doom sync~) again.
#+end_quote
** Other Requirements
- If [[doom-module::editor format]] is enabled, you'll need =rustfmt=: ~$ rustup component add
rustfmt~.
- Users with [[doom-module:+lsp]] enabled will need [[github:rust-analyzer/rust-analyzer][rust-analyzer]] (rls is supported,
but [[https://blog.rust-lang.org/2022/07/01/RLS-deprecation.html][deprecated]]).
- Using the following commands requires:
- ~cargo-process-check~: ~$ cargo install cargo-check~
- ~cargo-process-clippy~: ~$ rustup component add clippy-preview~
* TODO Usage
#+begin_quote
/This module's usage documentation is incomplete./ [[doom-contrib-module:][Complete it?]]
#+end_quote
** LSP support (rust-analyzer)
This module supports [[https://github.com/rust-lang/rust-analyzer][rust-analyzer]] ([[https://github.com/rust-lang/rls][RLS]] too, but it is [[https://blog.rust-lang.org/2022/07/01/RLS-deprecation.html][deprecated]]), which must be installed outside of Emacs, typically with rustup or your OS package manager.
Installation through rustup is simplest:
#+begin_src sh
$ rustup component add rust-analyzer rust-src
#+end_src
If your needs are more complex, consult [[https://rust-analyzer.github.io/manual.html#installation][rust-analyzer's documentation]].
Finally, enable Doom's [[doom-module::tools lsp]] module, and this module's
[[doom-module:+lsp]] flag ([[id:01cffea4-3329-45e2-a892-95a384ab2338][how to enable modules and their flags]]), and you're good
to go!
** Format on save
Enable [[doom-module::editor format +onsave]] to get formatting on save with
=rustfmt=. No additional configuration is necessary.
** Keybinds
| 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~ |
* TODO Configuration
#+begin_quote
/This module's configuration documentation is incomplete./ [[doom-contrib-module:][Complete it?]]
#+end_quote
** Enabling eglot support for Rust
Doom's [[doom-module::tools lsp]] module has an [[doom-module:+eglot]] flag. Enable it and this module will use
eglot instead.
* Troubleshooting
[[doom-report:][Report an issue?]]
** error[E0670]: `async fn` is not permitted in the 2015 edition
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-trigger~ or [[doom-module::editor
format]] enabled).
To fix this your project needs a =rustfmt.toml= with ~edition = "2018"~ in it.
* Frequently asked questions
/This module has no FAQs yet./ [[doom-suggest-faq:][Ask one?]]
* TODO Appendix
#+begin_quote
This module has no appendix yet. [[doom-contrib-module:][Write one?]]
#+end_quote