1818 - [ Running / testing / compiling code] ( #running--testing--compiling-code )
1919 - [ Clippy] ( #clippy )
2020 - [ Easy insertion of dbg!] ( #easy-insertion-of-dbg )
21+ - [ LSP] ( #lsp )
22+ - [ eglot] ( #eglot )
23+ - [ lsp-mode] ( #lsp-mode )
24+ - [ Auto-completion] ( #auto-completion )
2125 - [ Other recommended packages] ( #other-recommended-packages )
22- - [ Auto-completion / code navigation] ( #auto-completion--code-navigation )
2326 - [ flycheck] ( #flycheck )
2427 - [ cargo.el] ( #cargoel )
2528 - [ cargo-mode] ( #cargo-mode )
26- - [ Rustic ] ( #rustic )
29+ - [ rustic ] ( #rustic )
2730 - [ For package maintainers] ( #for-package-maintainers )
2831 - [ Tests] ( #tests )
32+ - [ Contributing] ( #contributing )
2933
3034<!-- markdown-toc end -->
3135
3236## Introduction
37+
3338` rust-mode ` makes editing [ Rust] ( http://rust-lang.org ) code with Emacs
3439enjoyable. It requires Emacs 25 or later, and is included in both
3540[ Emacs Prelude] ( https://github.com/bbatsov/prelude ) and
@@ -41,17 +46,20 @@ This mode provides:
4146- Integration with Cargo, clippy and rustfmt
4247
4348This 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.
4652
4753## Known issues
4854
4955- ` 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 )
5158
5259## Installation
5360
5461### Melpa
62+
5563The package is available on MELPA. Add this to your init.el.
5664
5765``` elisp
@@ -71,6 +79,7 @@ And put this in your config to load rust-mode automatically:
7179` (require 'rust-mode) `
7280
7381### Manual installation
82+
7483Clone this repository locally, and add this to your init.el:
7584
7685``` elisp
@@ -79,7 +88,9 @@ Clone this repository locally, and add this to your init.el:
7988```
8089
8190## Feature guide
91+
8292### Indentation
93+
8394Commands like <kbd >TAB</kbd > should indent correctly.
8495
8596The Rust style guide recommends spaces rather than tabs for
@@ -107,9 +118,9 @@ on save:
107118
108119### Running / testing / compiling code
109120
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.
113124
114125These are not bound by default. To bind these to keyboard shortcuts,
115126you can use the following in your init.el:
@@ -119,48 +130,67 @@ you can use the following in your init.el:
119130```
120131
121132### Clippy
133+
122134` rust-run-clippy ` runs
123135[ Clippy] ( https://github.com/rust-lang/rust-clippy ) , a linter.
124136
125137### Easy insertion of dbg!
138+
126139` rust-dbg-wrap-or-unwrap ` either wraps or unwraps the current region
127140in ` dbg! ` . This can be useful for easily adding debug lines to your
128141program.
129142
130143This is bound to <kbd >C-c C-d</kbd > by default.
131144
145+ ## LSP
132146
133- ## Other recommended packages
147+ ### eglot
148+
149+ eglot is a lightweight lsp client.
134150
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+ ```
140154
141- Two examples are:
142- - [ LSP] ( https://github.com/emacs-lsp/lsp-mode )
143- - [ eglot] ( https://github.com/joaotavora/eglot )
155+ ### lsp-mode
144156
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
148171
149172### flycheck
173+
150174[ flycheck] ( https://github.com/flycheck/flycheck ) allows highlighting
151175compile errors and Clippy lints inline.
152176
153177### cargo.el
178+
154179[ cargo.el] ( https://github.com/kwrooijen/cargo.el ) provides a minor
155180mode for integration with Cargo, Rust's package manager.
156181
157182### cargo-mode
158183
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
160190
161- ### Rustic
162191[ 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.
164194
165195
166196## For package maintainers
@@ -172,3 +202,7 @@ Run elisp tests:
172202``` bash
173203make test
174204```
205+
206+ ## Contributing
207+
208+ Contributions are very welcome. We are also looking for additional maintainers.
0 commit comments