From 96d9fe19012223c0f1f473b62bb7990f64e65400 Mon Sep 17 00:00:00 2001 From: Graham Marlow Date: Tue, 13 Jun 2023 08:39:15 -0700 Subject: Extra docs for eglot users --- README.md | 34 ++++++++++++++++++++++++++++++---- 1 file changed, 30 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 54076d4..8e02c03 100644 --- a/README.md +++ b/README.md @@ -8,9 +8,8 @@ Use with [rust-mode](https://elpa.nongnu.org/nongnu/rust-mode.html): ```elisp (use-package clippy-flymake - :vc (:fetcher sourcehut :repo mgmarlow/clippy-flymake)) - -(add-hook 'rust-mode-hook #'clippy-flymake-setup-backend) + :vc (:fetcher sourcehut :repo mgmarlow/clippy-flymake) + :hook (rust-mode . clippy-flymake-setup-backend)) ``` ## Eglot users @@ -18,9 +17,36 @@ Use with [rust-mode](https://elpa.nongnu.org/nongnu/rust-mode.html): Eglot [fully manages Flymake](https://github.com/joaotavora/eglot/issues/268) so you'll need some extra code to make it cooperate: ```elisp +;; Instruct Eglot to stop managing Flymake (add-to-list 'eglot-stay-out-of 'flymake) +;; Add the Eglot hook to Flymake diagnostic functions so we don't lose Eglot +;; functionality (add-hook 'eglot--managed-mode-hook (lambda () - (add-hook 'flymake-diagnostic-functions #'eglot-flymake-backend nil t))) + (add-hook 'flymake-diagnostic-functions #'eglot-flymake-backend nil t) + (flymake-mode 1))) +``` + +### Complete use-package example + +```elisp +(use-package clippy-flymake + :vc (:fetcher sourcehut :repo mgmarlow/clippy-flymake) + :hook (rust-mode . clippy-flymake-setup-backend)) + +(use-package eglot + :ensure t + :hook ((rust-mode . eglot-ensure) + (eglot--managed-mode . (lambda () + (add-hook 'flymake-diagnostic-functions #'eglot-flymake-backend nil t) + (flymake-mode 1)))) + :config + (add-to-list 'eglot-stay-out-of 'flymake)) +``` + +You can confirm that Flymake is running correctly by opening up a Rust buffer and examining `flymake-running-backends': + +``` +Running backends: clippy-flymake, eglot-flymake-backend ``` -- cgit v1.2.3