Add automatic indentation-detection (experimental)
Editorconfig is given precedence. If it successfully sets an indent_style or indent_size for the current buffer, automatic indentation detection will be disabled.
This commit is contained in:
parent
b1dce548ad
commit
3d0745c3ec
|
@ -10,6 +10,11 @@ modes are active and the buffer is read-only.")
|
|||
doc-view-mode doc-view-mode-maybe ebrowse-tree-mode pdf-view-mode)
|
||||
"Major modes that `doom|check-large-file' will ignore.")
|
||||
|
||||
(defvar-local doom-inhibit-indent-detection nil
|
||||
"A buffer-local flag that indicates whether `dtrt-indent' should try to detect
|
||||
indentation settings or not. This should be set by editorconfig if it
|
||||
successfully sets indent_style/indent_size.")
|
||||
|
||||
(setq-default
|
||||
vc-follow-symlinks t
|
||||
;; Save clipboard contents into kill-ring before replacing them
|
||||
|
@ -170,6 +175,15 @@ fundamental-mode) for performance sake."
|
|||
(setq command-log-mode-auto-show t
|
||||
command-log-mode-open-log-turns-on-mode t))
|
||||
|
||||
(def-package! dtrt-indent
|
||||
:config
|
||||
(setq dtrt-indent-verbosity (if doom-debug-mode 2 0))
|
||||
|
||||
(defun doom|detect-indentation ()
|
||||
(unless (or doom-inhibit-indent-detection (eq major-mode 'fundamental-mode))
|
||||
(dtrt-indent-mode +1)))
|
||||
(add-hook 'after-change-major-mode-hook #'doom|detect-indentation))
|
||||
|
||||
(def-package! expand-region
|
||||
:commands (er/expand-region er/contract-region er/mark-symbol er/mark-word)
|
||||
:config
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
(package! ace-window)
|
||||
(package! avy)
|
||||
(package! command-log-mode)
|
||||
(package! dtrt-indent)
|
||||
(package! expand-region)
|
||||
(package! helpful)
|
||||
(package! pcre2el)
|
||||
|
|
|
@ -39,6 +39,12 @@ extension, try to guess one."
|
|||
(apply orig-fn args)))
|
||||
(advice-add #'editorconfig-call-editorconfig-exec :around #'doom*editorconfig-smart-detection)
|
||||
|
||||
(defun +editorconfig|disable-indent-detection (props)
|
||||
(when (or (gethash 'indent_style props)
|
||||
(gethash 'indent_size props))
|
||||
(setq doom-inhibit-indent-detection t)))
|
||||
(add-hook 'editorconfig-custom-hooks #'+editorconfig|disable-indent-detection)
|
||||
|
||||
;; Editorconfig makes indentation too rigid in Lisp modes, so tell
|
||||
;; editorconfig to ignore indentation there. I prefer dynamic indentation
|
||||
;; support built into Emacs.
|
||||
|
|
Loading…
Reference in New Issue
Block a user