Determine indent level from more modes (#258)

Pass CSS, GraphQL, HTML, Ruby, Svelte, and YAML mode indent setting to
formatters that make use of it through `apheleia-formatters-js-indent`.

`prettier-markdown` and `prettier-scss` attempt to make use of this too,
but `markdown-mode` and `scss-mode` don't have such a setting that I can
tell. Left the uses in place for `indent-tabs-mode` support anyway.

BTW the `apheleia-formatters-js-indent` name and its description does
not seem quite spot on, as it was already being (partially
unsuccessfully) (ab?)used by some modes for which "JavaScript like"ness
is a bit of a stretch :)

Co-authored-by: Radon Rosborough <radon@intuitiveexplanations.com>
This commit is contained in:
Ville Skyttä 2023-12-15 04:47:50 +02:00 committed by GitHub
parent 4a87523f80
commit 022cf17464
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 1 deletions

View file

@ -8,6 +8,8 @@ The format is based on [Keep a Changelog].
* Use `perltidy` as default formatter for `cperl-mode` ([#260]).
* The `perltidy` formatter now supports Emacs indentation and line length
settings ([#261]).
* Indent level is now determined for `graphql-mode`, `html-mode`, `ruby-mode`,
`ruby-ts-mode`, `svelte-mode`, and `yaml-mode` ([#258]).
### Formatters
* [`dprint`](https://dprint.dev) for various (depending on
@ -31,6 +33,7 @@ The format is based on [Keep a Changelog].
[#209]: https://github.com/radian-software/apheleia/pull/209
[#229]: https://github.com/radian-software/apheleia/pull/229
[#257]: https://github.com/radian-software/apheleia/pull/257
[#258]: https://github.com/radian-software/apheleia/pull/258
[#260]: https://github.com/radian-software/apheleia/pull/260
[#261]: https://github.com/radian-software/apheleia/pull/261
[#263]: https://github.com/radian-software/apheleia/pull/263

View file

@ -38,6 +38,8 @@ always returns nil to defer to the formatter."
(cperl-mode 'cperl-indent-level)
(css-mode 'css-indent-offset)
(css-ts-mode 'css-indent-offset)
(graphql-mode 'graphql-indent-level)
(html-mode 'sgml-basic-offset)
(js-jsx-mode 'js-indent-level)
(js-ts-mode 'js-indent-level)
(js-mode 'js-indent-level)
@ -50,11 +52,15 @@ always returns nil to defer to the formatter."
(robot-mode 'robot-mode-basic-offset)
(perl-mode 'perl-indent-level)
(python-mode 'python-indent-offset)
(ruby-mode 'ruby-indent-level)
(ruby-ts-mode 'ruby-indent-level)
(scss-mode 'css-indent-offset)
(svelte-mode 'svelte-basic-offset)
(web-mode 'web-mode-indent-style)
(tsx-ts-mode 'typescript-ts-mode-indent-offset)
(typescript-mode 'typescript-indent-level)
(typescript-ts-mode 'typescript-ts-mode-indent-offset))))
(typescript-ts-mode 'typescript-ts-mode-indent-offset)
(yaml-mode 'yaml-indent-offset))))
(when-let ((indent (and indent-var
(boundp indent-var)