blob: 02854a8f7668361ce446946595cbd38110e15fe4 (
plain)
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
|
# clippy-flymake
A Flymake backend for [Clippy](https://doc.rust-lang.org/stable/clippy/index.html), the Rust linter.
## Instructions
You probably want to install [rust-mode](https://github.com/rust-lang/rust-mode) first.
With Emacs 30:
``` elisp
(use-package clippy-flymake
:vc (:url "https://git.sr.ht/~mgmarlow/clippy-flymake" :branch main)
:hook (rust-mode . clippy-flymake-setup-backend))
```
Alternatively, clone the repo and update your load path:
```
git clone https://git.sr.ht/~mgmarlow/clippy-flymake /path/to/clippy-flymake
```
```elisp
(add-to-list 'load-path "/path/to/clippy-flymake")
(require 'clippy-flymake)
```
Emacs versions prior to 30 can also install [use-package](https://github.com/jwiegley/use-package) and [vc-use-package](https://github.com/slotThe/vc-use-package) for an easier setup.
### Eglot users
Eglot users require [a little extra setup](https://github.com/joaotavora/eglot/issues/268) to enable running multiple Flymake backends simultaneously. Add the following to your Emacs config:
```elisp
;; Instruct Eglot to stop managing Flymake
(add-to-list 'eglot-stay-out-of 'flymake)
;; Manually re-enable Eglot's Flymake backend
(defun manually-activate-flymake ()
(add-hook 'flymake-diagnostic-functions #'eglot-flymake-backend nil t)
(flymake-mode 1))
(add-hook 'eglot-managed-mode-hook #'manually-activate-flymake nil t)
```
(Nb. prior to eglot 1.6, this hook was called `eglot--managed-mode-hook)
You can confirm that Flymake is running correctly by opening up a Rust buffer and examining `flymake-running-backends':
```
M-x flymake-running-backends
Running backends: clippy-flymake-backend, eglot-flymake-backend
```
### Complete eglot + rust-mode + use-package example
Emacs 30, eglot 1.6+:
```elisp
(use-package rust-mode
:ensure t)
(use-package clippy-flymake
:vc (:url "https://git.sr.ht/~mgmarlow/clippy-flymake" :branch main)
:hook (rust-mode . clippy-flymake-setup-backend))
(defun manually-activate-flymake ()
(add-hook 'flymake-diagnostic-functions #'eglot-flymake-backend nil t)
(flymake-mode 1))
(use-package eglot
:ensure t
:hook ((rust-mode . eglot-ensure)
(eglot-managed-mode . manually-activate-flymake))
:config
(add-to-list 'eglot-stay-out-of 'flymake))
```
## Contributing
Please direct bug reports or patches to the [the mailing list](https://lists.sr.ht/~mgmarlow/public-inbox).
## License
Licensed under [GPL-3.0](./LICENSE).
|