summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorAlan Pearce2023-07-09 08:13:09 +0200
committerAlan Pearce2023-07-13 19:43:14 +0200
commit92e147362d3724e0a98c1580f9630d06ca928947 (patch)
tree7449926b4a1f2da6fb80bd5099480ad0e9fc694c
parent2350d3ee98995de0d68f82224cbee2333091a385 (diff)
downloadnixfiles-92e147362d3724e0a98c1580f9630d06ca928947.tar.lz
nixfiles-92e147362d3724e0a98c1580f9630d06ca928947.tar.zst
nixfiles-92e147362d3724e0a98c1580f9630d06ca928947.zip
Emacs: avoid double auto-formatting
Remove format-all from mode hooks where apheleia is already supported.

Automatically disable format-all-mode when apheleia is enabled, in
case apheleia gains support for modes that format-all also supports
-rw-r--r--user/emacs/init.el17
1 files changed, 7 insertions, 10 deletions
diff --git a/user/emacs/init.el b/user/emacs/init.el
index 65cfdc0c..1c70fb53 100644
--- a/user/emacs/init.el
+++ b/user/emacs/init.el
@@ -1082,23 +1082,19 @@ _p_rev       _u_pper              _=_: upper/lower       _r_esolve
 
 (use-package format-all
   :defer 10
-  :ghook ('(css-mode-hook
-            clojure-mode-hook
+  :ghook ('(clojure-mode-hook
             dockerfile-mode-hook
             emacs-lisp-mode-hook
-            javascript-mode-hook
             json-mode-hook
             markdown-mode-hook
-            scss-mode-hook
-            sgml-mode-hook
-            sh-mode-hook
             sql-mode-hook
-            toml-mode-hook
-            typescript-mode-hook))
+            toml-mode-hook))
   :gfhook #'format-all-ensure-formatter
   :init (progn
           (advice-add 'format-all-ensure-formatter
-                      :around #'quiet))
+                      :around #'quiet)
+          (defun turn-off-format-all-mode ()
+            (format-all-mode -1)))
   :config (progn
             (setq format-all-show-errors 'never)))
 
@@ -1108,7 +1104,8 @@ _p_rev       _u_pper              _=_: upper/lower       _r_esolve
             (setf (alist-get 'shfmt apheleia-formatters)
                   '("shfmt"))
             (setf (alist-get 'nixfmt apheleia-formatters)
-                  '("nixpkgs-fmt")))
+                  '("nixpkgs-fmt"))
+            (add-hook 'apheleia-mode-hook #'turn-off-format-all-mode))
   :init (progn
           (apheleia-global-mode +1)))