fix(format): LSP formatters before Apheleia is loaded

This commit is contained in:
Henrik Lissner 2024-07-07 14:21:29 -04:00
parent c45c8cee35
commit deb59ca4ad
No known key found for this signature in database
GPG key ID: B60957CA074D39A3

View file

@ -45,19 +45,20 @@ This is controlled by `+format-on-save-disabled-modes'."
(eq +format-on-save-disabled-modes t)
(not (null (memq major-mode +format-on-save-disabled-modes)))))))
:config
(add-to-list 'doom-debug-variables '(apheleia-log-only-errors . nil))
;; Use the formatter provided by lsp-mode and eglot, if they are available and
;; `+format-with-lsp' is non-nil.
(cond ((modulep! :tools lsp +eglot)
(add-to-list 'apheleia-formatters '(eglot . +format-eglot-buffer))
(add-hook 'eglot-managed-mode-hook #'+format-toggle-eglot-formatter-h))
((modulep! :tools lsp)
(add-to-list 'apheleia-formatters '(lsp . +format-lsp-buffer))
(add-hook 'lsp-configure-hook #'+format-enable-lsp-formatter-h)
(add-hook 'lsp-unconfigure-hook #'+format-disable-lsp-formatter-h)))
:config
(add-to-list 'doom-debug-variables '(apheleia-log-only-errors . nil))
(add-to-list 'apheleia-formatters '(eglot . +format-eglot-buffer))
(add-to-list 'apheleia-formatters '(lsp . +format-lsp-buffer))
(defadvice! +format--inhibit-reformat-on-prefix-arg-a (orig-fn &optional arg)
"Make it so \\[save-buffer] with prefix arg inhibits reformatting."
:around #'save-buffer