From ac4cd5a3f07b8f725f7e063fe6c70ea6c423b845 Mon Sep 17 00:00:00 2001 From: Adam Goldsmith Date: Thu, 4 May 2023 20:12:56 -0400 Subject: [PATCH] Check if file is ignored by prettier in apheleia --- .emacs.d/init.el | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.emacs.d/init.el b/.emacs.d/init.el index 286bd2b..94726bb 100644 --- a/.emacs.d/init.el +++ b/.emacs.d/init.el @@ -1076,7 +1076,12 @@ ((member 'black formatters) (apheleia--pyproject-contains-section "tool.black")) ((member 'djlint formatters) (apheleia--pyproject-contains-section "tool.djlint")) ((member 'prettier formatters) - (= 0 (call-process "prettier" nil nil nil "--find-config-path" (buffer-file-name)))))))) + (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)))))))) (add-to-list 'apheleia-inhibit-functions 'apheleia--check-formatter-configured)