all repos — nixfiles @ 6234918b624931b70cda57d015a534794d0ec8d1

System and user configuration, managed by nix and home-manager

emacs: disable other formatter modes when using eglot
Alan Pearce alan@alanpearce.eu
Sun, 16 Mar 2025 15:54:51 +0100
commit

6234918b624931b70cda57d015a534794d0ec8d1

parent

a7d2453e018469dd67c6eeabe033a1919b212078

1 files changed, 6 insertions(+), 1 deletions(-)

jump to
M user/emacs/init.eluser/emacs/init.el
@@ -1226,7 +1226,12 @@ (define-minor-mode eglot-format-before-save-mode   "Whether to ask the LSP to format the buffer before saving"
   :init-val nil
   (if eglot-format-before-save-mode
-      (add-hook 'before-save-hook #'eglot-format-buffer nil 'local)
+      (progn
+        (add-hook 'before-save-hook #'eglot-format-buffer nil 'local)
+        (when (bound-and-true-p apheleia-mode)
+          (apheleia-mode -1))
+        (when (bound-and-true-p format-all-mode)
+          (format-all-mode -1)))
     (remove-hook 'before-save-hook #'eglot-format-buffer 'local)))
 
 (use-package eglot