From 022cf174649a273133ca5aa868661abf8b517ef6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ville=20Skytt=C3=A4?= Date: Fri, 15 Dec 2023 04:47:50 +0200 Subject: [PATCH] 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 --- CHANGELOG.md | 3 +++ apheleia-utils.el | 8 +++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 89ea959..59d589b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/apheleia-utils.el b/apheleia-utils.el index 07a358b..7e3820f 100644 --- a/apheleia-utils.el +++ b/apheleia-utils.el @@ -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)