18
18
- [ Running / testing / compiling code] ( #running--testing--compiling-code )
19
19
- [ Clippy] ( #clippy )
20
20
- [ Easy insertion of dbg!] ( #easy-insertion-of-dbg )
21
+ - [ LSP] ( #lsp )
22
+ - [ eglot] ( #eglot )
23
+ - [ lsp-mode] ( #lsp-mode )
24
+ - [ Auto-completion] ( #auto-completion )
21
25
- [ Other recommended packages] ( #other-recommended-packages )
22
- - [ Auto-completion / code navigation] ( #auto-completion--code-navigation )
23
26
- [ flycheck] ( #flycheck )
24
27
- [ cargo.el] ( #cargoel )
25
28
- [ cargo-mode] ( #cargo-mode )
26
- - [ Rustic ] ( #rustic )
29
+ - [ rustic ] ( #rustic )
27
30
- [ For package maintainers] ( #for-package-maintainers )
28
31
- [ Tests] ( #tests )
32
+ - [ Contributing] ( #contributing )
29
33
30
34
<!-- markdown-toc end -->
31
35
32
36
## Introduction
37
+
33
38
` rust-mode ` makes editing [ Rust] ( http://rust-lang.org ) code with Emacs
34
39
enjoyable. It requires Emacs 25 or later, and is included in both
35
40
[ Emacs Prelude] ( https://github.com/bbatsov/prelude ) and
@@ -41,17 +46,20 @@ This mode provides:
41
46
- Integration with Cargo, clippy and rustfmt
42
47
43
48
This mode does _ not_ provide autocompletion, or jumping to function /
44
- trait definitions. See [ Auto-completion / code navigation] ( #auto-completion--code-navigation )
45
- below for tips on how to enable this.
49
+ trait definitions. See [ Auto-completion / code
50
+ navigation] ( #auto-completion--code-navigation ) below for tips on how
51
+ to enable this.
46
52
47
53
## Known issues
48
54
49
55
- ` rust-syntax-propertize ` and ` adaptive-wrap-prefix-mode ` can lead to
50
- severe lag when editing larger files (https://github.com/brotzeit/rustic/issues/107 )
56
+ severe lag when editing larger files
57
+ (https://github.com/brotzeit/rustic/issues/107 )
51
58
52
59
## Installation
53
60
54
61
### Melpa
62
+
55
63
The package is available on MELPA. Add this to your init.el.
56
64
57
65
``` elisp
@@ -71,6 +79,7 @@ And put this in your config to load rust-mode automatically:
71
79
` (require 'rust-mode) `
72
80
73
81
### Manual installation
82
+
74
83
Clone this repository locally, and add this to your init.el:
75
84
76
85
``` elisp
@@ -79,7 +88,9 @@ Clone this repository locally, and add this to your init.el:
79
88
```
80
89
81
90
## Feature guide
91
+
82
92
### Indentation
93
+
83
94
Commands like <kbd >TAB</kbd > should indent correctly.
84
95
85
96
The Rust style guide recommends spaces rather than tabs for
@@ -107,9 +118,9 @@ on save:
107
118
108
119
### Running / testing / compiling code
109
120
110
- The ` rust-run ` , ` rust-test ` , ` rust-compile ` and ` rust-check ` functions shell out to
111
- Cargo to run, test, build and check your code. Under the hood, these use the
112
- standard Emacs ` compile ` function.
121
+ The ` rust-run ` , ` rust-test ` , ` rust-compile ` and ` rust-check ` functions
122
+ shell out to Cargo to run, test, build and check your code. Under the
123
+ hood, these use the standard Emacs ` compile ` function.
113
124
114
125
These are not bound by default. To bind these to keyboard shortcuts,
115
126
you can use the following in your init.el:
@@ -119,48 +130,67 @@ you can use the following in your init.el:
119
130
```
120
131
121
132
### Clippy
133
+
122
134
` rust-run-clippy ` runs
123
135
[ Clippy] ( https://github.com/rust-lang/rust-clippy ) , a linter.
124
136
125
137
### Easy insertion of dbg!
138
+
126
139
` rust-dbg-wrap-or-unwrap ` either wraps or unwraps the current region
127
140
in ` dbg! ` . This can be useful for easily adding debug lines to your
128
141
program.
129
142
130
143
This is bound to <kbd >C-c C-d</kbd > by default.
131
144
145
+ ## LSP
132
146
133
- ## Other recommended packages
147
+ ### eglot
148
+
149
+ eglot is a lightweight lsp client.
134
150
135
- ### Auto-completion / code navigation
136
- This package does not provide integration with
137
- [ RLS] ( https://github.com/rust-lang/rls ) , which provides
138
- auto-completion and code navigation. To use this you need an Emacs
139
- package that supports LSP.
151
+ ``` elisp
152
+ (add-hook 'rust-mode-hook 'eglot-ensure)
153
+ ```
140
154
141
- Two examples are:
142
- - [ LSP] ( https://github.com/emacs-lsp/lsp-mode )
143
- - [ eglot] ( https://github.com/joaotavora/eglot )
155
+ ### lsp-mode
144
156
145
- A lighter package that uses
146
- [ racer] ( https://github.com/racer-rust/racer ) is
147
- [ emacs-racer] ( https://github.com/racer-rust/emacs-racer ) .
157
+ lsp-mode provides more features and you can enhance the functionality
158
+ by using additional packages. You can find more information in the
159
+ [ lsp-mode wiki] ( https://emacs-lsp.github.io/lsp-mode/page/installation/#vanilla-emacs ) .
160
+
161
+ ``` elisp
162
+ (add-hook 'rust-mode-hook #'lsp)
163
+ ```
164
+
165
+ ## Auto-completion
166
+
167
+ You can either use a lsp client or [ racer] ( https://github.com/racer-rust/racer )
168
+ with [ emacs-racer] ( https://github.com/racer-rust/emacs-racer#installation ) .
169
+
170
+ ## Other recommended packages
148
171
149
172
### flycheck
173
+
150
174
[ flycheck] ( https://github.com/flycheck/flycheck ) allows highlighting
151
175
compile errors and Clippy lints inline.
152
176
153
177
### cargo.el
178
+
154
179
[ cargo.el] ( https://github.com/kwrooijen/cargo.el ) provides a minor
155
180
mode for integration with Cargo, Rust's package manager.
156
181
157
182
### cargo-mode
158
183
159
- [ cargo-mode] ( https://github.com/ayrat555/cargo-mode ) is an Emacs minor mode which allows to dynamically select a Cargo command. The reasons behind this package can be found in [ the post] ( https://www.badykov.com/emacs/2021/05/29/emacs-cargo-mode/ ) .
184
+ [ cargo-mode] ( https://github.com/ayrat555/cargo-mode ) is an Emacs minor
185
+ mode which allows to dynamically select a Cargo command. The reasons
186
+ behind this package can be found in [ the
187
+ post] ( https://www.badykov.com/emacs/2021/05/29/emacs-cargo-mode/ ) .
188
+
189
+ ### rustic
160
190
161
- ### Rustic
162
191
[ rustic] ( https://github.com/brotzeit/rustic ) is based on rust-mode,
163
- extending it with other features such as integration with LSP and with flycheck.
192
+ extending it with other features such as integration with LSP and with
193
+ flycheck.
164
194
165
195
166
196
## For package maintainers
@@ -172,3 +202,7 @@ Run elisp tests:
172
202
``` bash
173
203
make test
174
204
```
205
+
206
+ ## Contributing
207
+
208
+ Contributions are very welcome. We are also looking for additional maintainers.
0 commit comments