1
+ # rust-mode
2
+
1
3
[ ![ MELPA] ( https://melpa.org/packages/rust-mode-badge.svg )] ( https://melpa.org/#/rust-mode )
4
+ [ ![ ] ( https://github.com/rust-lang/rust-mode/workflows/CI/badge.svg )] ( https://github.com/rust-lang/rust-mode/actions?query=workflow%3ACI )
2
5
3
6
<!-- markdown-toc start - Don't edit this section. Run M-x markdown-toc-refresh-toc -->
4
7
** Table of Contents**
23
26
24
27
<!-- markdown-toc end -->
25
28
26
- # Introduction
29
+ ## Introduction
27
30
` rust-mode ` makes editing [ Rust] ( http://rust-lang.org ) code with Emacs
28
31
enjoyable. It requires Emacs 25 or later, and is included in both
29
32
[ Emacs Prelude] ( https://github.com/bbatsov/prelude ) and
@@ -39,9 +42,9 @@ trait definitions. See [Auto-completion / code navigation](#auto-completion--cod
39
42
below for tips on how to enable this.
40
43
41
44
42
- # Installation
45
+ ## Installation
43
46
44
- ## Melpa
47
+ ### Melpa
45
48
The package is available on MELPA. Add this to your init.el.
46
49
47
50
``` elisp
@@ -60,16 +63,16 @@ And put this in your config to load rust-mode automatically:
60
63
61
64
` (require 'rust-mode) `
62
65
63
- ## Manual installation
66
+ ### Manual installation
64
67
Clone this repository locally, and add this to your init.el:
65
68
66
69
``` elisp
67
70
(add-to-list 'load-path "/path/to/rust-mode/")
68
71
(autoload 'rust-mode "rust-mode" nil t)
69
72
```
70
73
71
- # Feature guide
72
- ## Indentation
74
+ ## Feature guide
75
+ ### Indentation
73
76
Commands like <kbd >TAB</kbd > should indent correctly.
74
77
75
78
The Rust style guide recommends spaces rather than tabs for
@@ -81,7 +84,7 @@ which forces indentation to always use spaces.
81
84
(lambda () (setq indent-tabs-mode nil)))
82
85
```
83
86
84
- ## Code formatting
87
+ ### Code formatting
85
88
86
89
The ` rust-format-buffer ` function will format your code with
87
90
[ rustfmt] ( https://github.com/rust-lang/rustfmt ) if installed. By
@@ -95,7 +98,7 @@ on save:
95
98
(setq rust-format-on-save t)
96
99
```
97
100
98
- ## Running / testing / compiling code
101
+ ### Running / testing / compiling code
99
102
100
103
The ` rust-run ` , ` rust-test ` , ` rust-compile ` and ` rust-check ` functions shell out to
101
104
Cargo to run, test, build and check your code. Under the hood, these use the
@@ -108,21 +111,21 @@ you can use the following in your init.el:
108
111
(define-key rust-mode-map (kbd "C-c C-c") 'rust-run)
109
112
```
110
113
111
- ## Clippy
114
+ ### Clippy
112
115
` rust-run-clippy ` runs
113
116
[ Clippy] ( https://github.com/rust-lang/rust-clippy ) , a linter.
114
117
115
- ## Easy insertion of !dbg
118
+ ### Easy insertion of !dbg
116
119
` rust-dbg-wrap-or-unwrap ` either wraps or unwraps the current region
117
120
in ` dbg! ` . This can be useful for easily adding debug lines to your
118
121
program.
119
122
120
123
This is bound to <kbd >C-c C-d</kbd > by default.
121
124
122
125
123
- # Other recommended packages
126
+ ## Other recommended packages
124
127
125
- ## Auto-completion / code navigation
128
+ ### Auto-completion / code navigation
126
129
This package does not provide integration with
127
130
[ RLS] ( https://github.com/rust-lang/rls ) , which provides
128
131
auto-completion and code navigation. To use this you need an Emacs
@@ -136,26 +139,26 @@ A lighter package that uses
136
139
[ racer] ( https://github.com/racer-rust/racer ) is
137
140
[ emacs-racer] ( https://github.com/racer-rust/emacs-racer ) .
138
141
139
- ## flycheck
142
+ ### flycheck
140
143
[ flycheck] ( https://github.com/flycheck/flycheck ) allows highlighting
141
144
compile errors and Clippy lints inline.
142
145
143
- ## cargo.el
146
+ ### cargo.el
144
147
[ cargo.el] ( https://github.com/kwrooijen/cargo.el ) provides a minor
145
148
mode for integration with Cargo, Rust's package manager.
146
149
147
- ## cargo-mode
150
+ ### cargo-mode
148
151
149
152
[ 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/ ) .
150
153
151
- ## Rustic
154
+ ### Rustic
152
155
[ rustic] ( https://github.com/brotzeit/rustic ) is based on rust-mode,
153
156
extending it with other features such as integration with LSP and with flycheck.
154
157
155
158
156
- # For package maintainers
159
+ ## For package maintainers
157
160
158
- ## Tests
161
+ ### Tests
159
162
160
163
Run elisp tests:
161
164
0 commit comments