From 40f8a94954a8f8f73d138fa670de3b57b927f3ad Mon Sep 17 00:00:00 2001 From: Adam Goldsmith Date: Fri, 15 Nov 2024 01:46:34 -0500 Subject: [PATCH] Add pyproject-fmt to apheleia formatters --- .emacs.d/init.el | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.emacs.d/init.el b/.emacs.d/init.el index 25eade7..5b4e491 100644 --- a/.emacs.d/init.el +++ b/.emacs.d/init.el @@ -1073,6 +1073,8 @@ :config (setf (alist-get 'djlint apheleia-formatters) '("djlint" "--reformat" "-")) (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) (defun apheleia--pyproject-contains-section (section) @@ -1085,6 +1087,7 @@ "Disable apheleia when a formatter's configuration does not exist" (let ((formatters (apheleia--get-formatters))) (cond + ((member 'pyproject-fmt formatters) (not (apheleia--pyproject-contains-section "tool.pyproject-fmt"))) ((member 'ruff formatters) (not (apheleia--pyproject-contains-section "tool.ruff"))) ((member 'black formatters) (not (apheleia--pyproject-contains-section "tool.black"))) ((member 'djlint formatters) (not (apheleia--pyproject-contains-section "tool.djlint")))