Compare commits

...

2 Commits

View File

@ -1085,6 +1085,7 @@
:config
(setf (alist-get 'djlint apheleia-formatters) '("djlint" "--reformat" "-"))
(setf (alist-get "\\.dj\\.html$" apheleia-mode-alist) '(djlint))
(setf (alist-get 'objc-mode apheleia-mode-alist) 'clang-format)
(defun apheleia--pyproject-contains-section (section)
(when-let (parent (locate-dominating-file default-directory "pyproject.toml"))
@ -1094,18 +1095,18 @@
(defun apheleia--check-formatter-configured ()
"Disable apheleia when a formatter's configuration does not exist"
(not (let ((formatters (apheleia--get-formatters)))
(let ((formatters (apheleia--get-formatters)))
(cond
((member 'ruff formatters) (apheleia--pyproject-contains-section "tool.ruff"))
((member 'black formatters) (apheleia--pyproject-contains-section "tool.black"))
((member 'djlint formatters) (apheleia--pyproject-contains-section "tool.djlint"))
((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")))
((seq-some (lambda (f) (string-prefix-p "prettier" (symbol-name f))) formatters)
(when (= 0 (call-process "prettier" nil nil nil "--find-config-path" (buffer-file-name)))
(not (when (= 0 (call-process "prettier" nil nil nil "--find-config-path" (buffer-file-name)))
(let* ((config-file (shell-command-to-string (concat "prettier --find-config-path " (buffer-file-name))))
(default-directory (file-name-directory (expand-file-name config-file)))
(file-info (shell-command-to-string (concat "prettier --file-info " (buffer-file-name))))
(file-ignored (gethash "ignored" (json-parse-string file-info))))
(eq file-ignored :false))))))))
(eq file-ignored :false)))))))))
(add-to-list 'apheleia-inhibit-functions 'apheleia--check-formatter-configured)