Add pyproject-fmt to apheleia formatters

This commit is contained in:
Adam Goldsmith 2024-11-15 01:46:34 -05:00
parent 6c55b50071
commit 40f8a94954

View File

@ -1073,6 +1073,8 @@
:config :config
(setf (alist-get 'djlint apheleia-formatters) '("djlint" "--reformat" "-")) (setf (alist-get 'djlint apheleia-formatters) '("djlint" "--reformat" "-"))
(setf (alist-get "\\.dj\\.html$" apheleia-mode-alist) '(djlint)) (setf (alist-get "\\.dj\\.html$" apheleia-mode-alist) '(djlint))
(setf (alist-get 'pyproject-fmt apheleia-formatters) '("sh" "-c" "pyproject-fmt --no-print-diff -; test $? -le 1"))
(setf (alist-get "/pyproject\\.toml$" apheleia-mode-alist) '(pyproject-fmt))
(setf (alist-get 'objc-mode apheleia-mode-alist) 'clang-format) (setf (alist-get 'objc-mode apheleia-mode-alist) 'clang-format)
(defun apheleia--pyproject-contains-section (section) (defun apheleia--pyproject-contains-section (section)
@ -1085,6 +1087,7 @@
"Disable apheleia when a formatter's configuration does not exist" "Disable apheleia when a formatter's configuration does not exist"
(let ((formatters (apheleia--get-formatters))) (let ((formatters (apheleia--get-formatters)))
(cond (cond
((member 'pyproject-fmt formatters) (not (apheleia--pyproject-contains-section "tool.pyproject-fmt")))
((member 'ruff formatters) (not (apheleia--pyproject-contains-section "tool.ruff"))) ((member 'ruff formatters) (not (apheleia--pyproject-contains-section "tool.ruff")))
((member 'black formatters) (not (apheleia--pyproject-contains-section "tool.black"))) ((member 'black formatters) (not (apheleia--pyproject-contains-section "tool.black")))
((member 'djlint formatters) (not (apheleia--pyproject-contains-section "tool.djlint"))) ((member 'djlint formatters) (not (apheleia--pyproject-contains-section "tool.djlint")))