fix(format): prettier: don't override prettier indent config
Apheleia's default config for prettier adds --use-tabs/--tab-width to force prettier to match Emacs' indent settings, which is fine until a prettier config file tries to overwrite it and is ignored. As a compromise (and stopgap solution), I omit these flags if any prettier settings are set in the current project. Fix: #7998
This commit is contained in:
parent
e82dab3257
commit
c0a1b9efc9
1 changed files with 27 additions and 1 deletions
|
@ -76,4 +76,30 @@ This is controlled by `+format-on-save-disabled-modes'."
|
|||
;; `lsp-mode' or `eglot') that is capable of formatting. Without +lsp, users
|
||||
;; must manually set `+format-with' to `lsp' to use it, or activate
|
||||
;; `+format-with-lsp-mode' in the appropriate modes.
|
||||
(add-to-list 'apheleia-formatters '(lsp . +format-lsp-buffer)))
|
||||
(add-to-list 'apheleia-formatters '(lsp . +format-lsp-buffer))
|
||||
|
||||
;; Apheleia's default config for prettier passes an explicit --tab-width N to
|
||||
;; all prettier formatters, respecting your indent settings in Emacs, but
|
||||
;; overriding any indent settings in your prettier config files. This changes
|
||||
;; it to omit indent switches if any configuration for prettier is present in
|
||||
;; the current project.
|
||||
(dolist (formatter '(prettier prettier-css prettier-html prettier-javascript
|
||||
prettier-json prettier-scss prettier-svelte
|
||||
prettier-typescript prettier-yaml))
|
||||
(setf (alist-get formatter apheleia-formatters)
|
||||
(append (delete '(apheleia-formatters-js-indent "--use-tabs" "--tab-width")
|
||||
(alist-get formatter apheleia-formatters))
|
||||
'(unless (or (cl-loop for file
|
||||
in '(".prettierrc"
|
||||
".prettierrc.json"
|
||||
".prettierrc.yml"
|
||||
".prettierrc.yaml"
|
||||
".prettierrc.json5"
|
||||
".prettierrc.js" "prettier.config.js"
|
||||
".prettierrc.mjs" "prettier.config.mjs"
|
||||
".prettierrc.cjs" "prettier.config.cjs"
|
||||
".prettierrc.toml")
|
||||
if (locate-dominating-file default-directory file)
|
||||
return t)
|
||||
(assq 'prettier (+javascript-npm-conf)))
|
||||
(apheleia-formatters-indent "--use-tabs" "--tab-width"))))))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue