module!: add :editor whitespace

BREAKING CHANGE: Moves ws-butler, dtrt-indent, and whitespace defaults
out of Doom's core and into a new module. ws-butler is gated behind
+trim and dtrt-indent behind +guess. Users who depend on/like these
packages will need to enable the new module and their respective
flags (which is the default going forward).

This change is motivated by an ongoing effort to slim down Doom's
core (by (re)moving non-essentials from it).

This also addresses an issue where dtrt-indent would vastly increase
load times for some major-modes (e.g. elixir-mode & elm-mode, see #7537)
by restricting it to non-project files and non-read-only buffers AND
excludign those two major modes from indent guessing.

Fix: #8516
Fix: #7537
This commit is contained in:
Henrik Lissner
2025-09-24 01:29:09 -04:00
parent 22f86d25e9
commit fbdde6b5f4
16 changed files with 215 additions and 143 deletions

View File

@@ -20,9 +20,6 @@ with or without the native editorconfig binary.
- [[doom-package:editorconfig-emacs]]
** Hacks
- *Special integration for =dtrt-indent=:* If the local editorconfig file
specifies ~indent_style~ or ~indent_size~, the [[doom-package:dtrt-indent]] (which tries to
guess your indent settings by analyzing your text file) will bow out.
- *Special integration for =ws-butler=:* this module will use [[doom-package:ws-butler]] to
enforce ~trim_trailing_whitespace~.

View File

@@ -13,7 +13,7 @@
;; expecting it to be used.
(setq editorconfig-get-properties-function #'editorconfig-get-properties)
(when (require 'ws-butler nil t)
(when (modulep! :editor whitespace +trim)
(setq editorconfig-trim-whitespaces-mode 'ws-butler-mode))
;; Fix #5057 archives don't need editorconfig settings, and they may otherwise
@@ -26,10 +26,11 @@
(defun +editorconfig-disable-indent-detection-h (props)
"Inhibit `dtrt-indent' if an explicit indent_style and indent_size is
specified by editorconfig."
(when (and (not doom-inhibit-indent-detection)
(when (and (modulep! :editor whitespace +guess)
(not +whitespace-guess-inhibit)
(or (gethash 'indent_style props)
(gethash 'indent_size props)))
(setq doom-inhibit-indent-detection 'editorconfig)))
(setq +whitespace-guess-inhibit 'editorconfig)))
;; I use a hook over `editorconfig-exclude-modes' because the option
;; inhibits all settings, and I only want to inhibit indent_size. Plus modes
;; in that option won't apply to derived modes, so we'd have to add *all*