fix: properly set evil-shift-width

This was just wrong, and I'm not sure why I thought it was the correct
thing to do here.
This commit is contained in:
Kiana Sheibani 2026-02-14 18:31:46 -05:00
parent f46b31c129
commit 5b065e68ef
Signed by: toki
GPG key ID: 6CB106C25E86A9F7

View file

@ -2113,15 +2113,15 @@ The =indent-bars= package works by overriding the face used for displaying the w
*** Evil Shift Width *** Evil Shift Width
The Vim/Evil keybinds =<= and =>= shift the target left or right by one indent respectively, where the specific offset it uses is determined by ~evil-shift-width~. Doom Emacs sets this equal to ~tab-width~, the displayed width of a hard tab, which is a little odd, as that doesn't actually have anything to do with the indentation settings of the current mode. We can fix this in a few different ways, but the simplest is to set ~tab-width~ to the offset to make everything consistent. The Vim/Evil keybinds =<= and =>= shift the target left or right by one indent respectively, where the specific offset it uses is determined by ~evil-shift-width~. Doom Emacs sets this equal to ~tab-width~, the displayed width of a hard tab, which is a little odd, as that doesn't actually have anything to do with the indentation settings of the current mode. We can fix this by overriding the hook to set the shift width to our guessed offset, falling back on the default behavior otherwise.
#+begin_src emacs-lisp #+begin_src emacs-lisp
(add-hook! 'change-major-mode-after-body-hook (defadvice! ~/evil-adjust-shift-width-h ()
(defun ~/adjust-tab-width () :override #'+evil-adjust-shift-width-h
(unless (or (derived-mode-p 'org-mode) ;; Org mode is an exception (setq-local evil-shift-width
(local-variable-p 'tab-width)) (if (derived-mode-p 'org-mode) 2
(setq-local tab-width (or (~/guess-offset-from-editorconfig) (or (~/guess-offset-from-editorconfig)
tab-width))))) tab-width))))
#+end_src #+end_src
** Marginalia ** Marginalia