mirror of
https://github.com/vale981/apheleia
synced 2025-03-04 09:01:42 -05:00
For https://github.com/radian-software/apheleia/discussions/208#discussioncomment-7086819
This commit is contained in:
parent
4ebc10b623
commit
f57d21ef1f
3 changed files with 25 additions and 7 deletions
|
@ -15,6 +15,12 @@ The format is based on [Keep a Changelog].
|
|||
* Disable formatting of go module files with gofmt. This was never supported
|
||||
([#214]).
|
||||
|
||||
### Features
|
||||
* New user option `apheleia-formatters-respect-indent-level`,
|
||||
defaulting to `t`. You can set this to `nil` to disable Apheleia
|
||||
configuring formatters to use the same indent settings as the Emacs
|
||||
major mode is using ([#208]).
|
||||
|
||||
### Enhancements
|
||||
* Use the `prettier-json` formatter for `js-json-mode` ([#209]).
|
||||
* Prettier is now enabled in `svelte-mode`.
|
||||
|
@ -68,6 +74,7 @@ The format is based on [Keep a Changelog].
|
|||
[#182]: https://github.com/radian-software/apheleia/pull/182
|
||||
[#187]: https://github.com/radian-software/apheleia/pull/187
|
||||
[#196]: https://github.com/radian-software/apheleia/pull/196
|
||||
[#208]: https://github.com/radian-software/apheleia/discussions/208
|
||||
[#209]: https://github.com/radian-software/apheleia/pull/209
|
||||
[#213]: https://github.com/radian-software/apheleia/pull/213
|
||||
[#214]: https://github.com/radian-software/apheleia/pull/214
|
||||
|
|
|
@ -9,14 +9,23 @@
|
|||
(require 'cl-lib)
|
||||
(require 'subr-x)
|
||||
|
||||
(defcustom apheleia-formatters-respect-indent-level t
|
||||
"Whether formatters should respect Emacs' indent configuration."
|
||||
:type 'boolean
|
||||
:group 'apheleia)
|
||||
|
||||
(defun apheleia-formatters-indent (tab-flag indent-flag indent-var)
|
||||
"Set flag for indentation.
|
||||
Helper function for `apheleia-formatters' which allows you to supply
|
||||
alternating flags based on the current buffers indent configuration. If the
|
||||
buffer is indented with tabs then returns TAB-FLAG. Otherwise if INDENT-VAR
|
||||
is set in the buffer return INDENT-FLAG and the value of INDENT-VAR. Use this
|
||||
to easily configure the indentation level of a formatter."
|
||||
to easily configure the indentation level of a formatter.
|
||||
|
||||
If `apheleia-formatters-respect-indent-level' is nil then this
|
||||
always returns nil to defer to the formatter."
|
||||
(cond
|
||||
((not apheleia-formatters-respect-indent-level) nil)
|
||||
(indent-tabs-mode tab-flag)
|
||||
(indent-var
|
||||
(when-let ((indent (and (boundp indent-var)
|
||||
|
|
14
apheleia.el
14
apheleia.el
|
@ -138,12 +138,14 @@
|
|||
"-ln" (cl-case (bound-and-true-p sh-shell)
|
||||
(sh "posix")
|
||||
(t "bash"))
|
||||
"-i" (number-to-string
|
||||
(cond
|
||||
(indent-tabs-mode 0)
|
||||
((boundp 'sh-basic-offset)
|
||||
sh-basic-offset)
|
||||
(t 4)))
|
||||
(when apheleia-formatters-respect-indent-level
|
||||
(list
|
||||
"-i" (number-to-string
|
||||
(cond
|
||||
(indent-tabs-mode 0)
|
||||
((boundp 'sh-basic-offset)
|
||||
sh-basic-offset)
|
||||
(t 4)))))
|
||||
"-"))
|
||||
(rufo . ("rufo" "--filename" filepath "--simple-exit"))
|
||||
(stylua . ("stylua" "-"))
|
||||
|
|
Loading…
Add table
Reference in a new issue