You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
`rust-mode` makes editing [Rust](http://rust-lang.org) code with Emacs
28
+
enjoyable. It requires Emacs 24 or later, and is include in both
29
+
[Emacs Prelude](https://github.com/bbatsov/prelude) and
30
+
[Spacemacs](https://github.com/syl20bnr/spacemacs) by default.
31
+
32
+
This mode provides:
33
+
- Syntax highlighting (for Font Lock Mode)
34
+
- Indentation
35
+
- Integration with Cargo, clippy and rustfmt
36
+
37
+
This mode does _not_ provide autocompletion, or jumping to function /
38
+
trait definitions. See [Integration with Rust Language Server](#rust-language-server)
39
+
below for tips on how to enable this.
40
+
41
+
22
42
# Installation
23
43
24
44
## Melpa
25
-
26
-
`rust-mode` makes editing [Rust](http://rust-lang.org) code with Emacs
27
-
enjoyable. It requires Emacs 24 or later.
28
45
The package is available on MELPA. Add this to your init.el.
29
46
30
47
```elisp
@@ -43,60 +60,100 @@ And put this in your config to load rust-mode automatically:
43
60
44
61
`(require 'rust-mode)`
45
62
46
-
## straight
47
-
48
-
[straight.el](https://github.com/raxod502/straight.el#install-packages) clones each of your packages directly from its source. There are good additional [installation instructions](https://github.crookster.org/switching-to-straight.el-from-emacs-26-builtin-package.el/) for moving your package management from package.el to straight.
49
-
50
-
## Manual Installation
51
-
52
-
Add this to your init.el:
63
+
## Manual installation
64
+
Clone this repository locally, and add this to your init.el:
53
65
54
66
```elisp
55
67
(add-to-list 'load-path "/path/to/rust-mode/")
56
68
(autoload 'rust-mode "rust-mode" nil t)
57
69
```
58
70
59
-
# Indentation
71
+
# Feature guide
72
+
## Indentation
73
+
Commands like <TAB> should indent correctly.
60
74
61
-
The Rust style guide recommends spaces for indentation; to follow the
62
-
recommendation add this to your init.el:
75
+
The Rust style guide recommends spaces rather than tabs for
76
+
indentation; to follow the recommendation add this to your init.el,
77
+
which forces indentation to always use spaces.
63
78
64
79
```elisp
65
80
(add-hook 'rust-mode-hook
66
81
(lambda () (setq indent-tabs-mode nil)))
67
82
```
68
83
69
-
#rustfmt
84
+
## Code formatting
70
85
71
86
The `rust-format-buffer` function will format your code with
72
-
[rustfmt](https://github.com/rust-lang/rustfmt) if installed. By default,
73
-
this is bound to `C-c C-f`.
87
+
[rustfmt](https://github.com/rust-lang/rustfmt) if installed. By
88
+
default, this is bound to `C-c C-f`.
74
89
75
-
Placing `(setq rust-format-on-save t)` in your init.el will enable automatic
76
-
running of `rust-format-buffer` when you save a buffer.
90
+
The variable `rust-format-on-save` enables automatic formatting on
91
+
save. For example, add the following in your init.el to enable format
92
+
on save:
77
93
78
-
# Tests
94
+
```elisp
95
+
(setq rust-format-on-save t)
96
+
```
79
97
80
-
The file `rust-mode-tests.el` contains tests that can be run via
0 commit comments