editor/evil: revert focus-on-split behavior (and refactor advice)
Focus-on-split is being disabled to achieve vim parity. The advice is still necessary to ensure splitting updates the window buffer list, so operations like winner-undo undoes correctly.
This commit is contained in:
parent
be08f9794e
commit
43030c789e
2 changed files with 21 additions and 29 deletions
|
@ -149,22 +149,15 @@ more information on modifiers."
|
||||||
(let ((evil-auto-indent evil-auto-indent))
|
(let ((evil-auto-indent evil-auto-indent))
|
||||||
(funcall orig-fn count)))))
|
(funcall orig-fn count)))))
|
||||||
|
|
||||||
;;;###autoload
|
|
||||||
(defun +evil--static-reindent-a (orig-fn &rest args)
|
|
||||||
"Don't move cursor on indent."
|
|
||||||
(save-excursion (apply orig-fn args)))
|
|
||||||
|
|
||||||
;;;###autoload (autoload '+evil-window-split-a "editor/evil/autoload/advice" nil t)
|
;;;###autoload (autoload '+evil-window-split-a "editor/evil/autoload/advice" nil t)
|
||||||
(evil-define-command +evil-window-split-a (&optional count file)
|
(evil-define-command +evil-window-split-a (&optional count file)
|
||||||
"Same as `evil-window-split', but focuses (and recenters) the new split."
|
"Same as `evil-window-split', but focuses (and recenters) the new split."
|
||||||
:repeat nil
|
:repeat nil
|
||||||
(interactive "P<f>")
|
(interactive "P<f>")
|
||||||
(split-window (selected-window) count
|
(let ((win (selected-window)))
|
||||||
(if evil-split-window-below 'above 'below))
|
(split-window (selected-window) count
|
||||||
(call-interactively
|
(if evil-split-window-below 'above 'below))
|
||||||
(if evil-split-window-below
|
(select-window win))
|
||||||
#'evil-window-up
|
|
||||||
#'evil-window-down))
|
|
||||||
(recenter)
|
(recenter)
|
||||||
(when (and (not count) evil-auto-balance-windows)
|
(when (and (not count) evil-auto-balance-windows)
|
||||||
(balance-windows (window-parent)))
|
(balance-windows (window-parent)))
|
||||||
|
@ -175,22 +168,15 @@ more information on modifiers."
|
||||||
"Same as `evil-window-vsplit', but focuses (and recenters) the new split."
|
"Same as `evil-window-vsplit', but focuses (and recenters) the new split."
|
||||||
:repeat nil
|
:repeat nil
|
||||||
(interactive "P<f>")
|
(interactive "P<f>")
|
||||||
(split-window (selected-window) count
|
(let ((win (selected-window)))
|
||||||
(if evil-vsplit-window-right 'left 'right))
|
(split-window (selected-window) count
|
||||||
(call-interactively
|
(if evil-vsplit-window-right 'left 'right))
|
||||||
(if evil-vsplit-window-right
|
(select-window win))
|
||||||
#'evil-window-left
|
|
||||||
#'evil-window-right))
|
|
||||||
(recenter)
|
(recenter)
|
||||||
(when (and (not count) evil-auto-balance-windows)
|
(when (and (not count) evil-auto-balance-windows)
|
||||||
(balance-windows (window-parent)))
|
(balance-windows (window-parent)))
|
||||||
(if file (evil-edit file)))
|
(if file (evil-edit file)))
|
||||||
|
|
||||||
;;;###autoload
|
|
||||||
(defun +evil--make-numbered-markers-global-a (orig-fn char)
|
|
||||||
(or (and (>= char ?2) (<= char ?9))
|
|
||||||
(funcall orig-fn char)))
|
|
||||||
|
|
||||||
;;;###autoload
|
;;;###autoload
|
||||||
(defun +evil--fix-dabbrev-in-minibuffer-h ()
|
(defun +evil--fix-dabbrev-in-minibuffer-h ()
|
||||||
"Make `try-expand-dabbrev' from `hippie-expand' work in minibuffer. See
|
"Make `try-expand-dabbrev' from `hippie-expand' work in minibuffer. See
|
||||||
|
|
|
@ -25,8 +25,6 @@ directives. By default, this only recognizes C directives.")
|
||||||
(defvar evil-want-C-w-scroll t)
|
(defvar evil-want-C-w-scroll t)
|
||||||
(defvar evil-want-Y-yank-to-eol t)
|
(defvar evil-want-Y-yank-to-eol t)
|
||||||
(defvar evil-want-abbrev-expand-on-insert-exit nil)
|
(defvar evil-want-abbrev-expand-on-insert-exit nil)
|
||||||
(defvar evil-split-window-below t)
|
|
||||||
(defvar evil-vsplit-window-right t)
|
|
||||||
|
|
||||||
(use-package! evil
|
(use-package! evil
|
||||||
:hook (doom-init-modules . evil-mode)
|
:hook (doom-init-modules . evil-mode)
|
||||||
|
@ -122,10 +120,21 @@ directives. By default, this only recognizes C directives.")
|
||||||
(buffer-name))
|
(buffer-name))
|
||||||
(count-lines (point-min) (point-max))
|
(count-lines (point-min) (point-max))
|
||||||
(buffer-size)))))
|
(buffer-size)))))
|
||||||
|
|
||||||
|
;; 'gq' moves the cursor to the beginning of selection. Disable this, since
|
||||||
|
;; it's more disruptive than helpful.
|
||||||
|
(defadvice! +evil--dont-move-cursor-a (orig-fn &rest args)
|
||||||
|
:around #'evil-indent
|
||||||
|
(save-excursion (apply orig-fn args)))
|
||||||
|
|
||||||
|
;; In evil, registers 2-9 are buffer-local. In vim, they're global, so...
|
||||||
|
(defadvice! +evil--make-numbered-markers-global-a (arg)
|
||||||
|
:after-until #'evil-global-marker-p
|
||||||
|
(and (>= char ?2) (<= char ?9)))
|
||||||
|
|
||||||
;; Make ESC (from normal mode) the universal escaper. See `doom-escape-hook'.
|
;; Make ESC (from normal mode) the universal escaper. See `doom-escape-hook'.
|
||||||
(advice-add #'evil-force-normal-state :after #'+evil-escape-a)
|
(advice-add #'evil-force-normal-state :after #'+evil-escape-a)
|
||||||
;; Don't move cursor when indenting
|
|
||||||
(advice-add #'evil-indent :around #'+evil--static-reindent-a)
|
|
||||||
;; monkey patch `evil-ex-replace-special-filenames' to improve support for
|
;; monkey patch `evil-ex-replace-special-filenames' to improve support for
|
||||||
;; file modifiers like %:p:h. This adds support for most of vim's modifiers,
|
;; file modifiers like %:p:h. This adds support for most of vim's modifiers,
|
||||||
;; and one custom one: %:P (expand to the project root).
|
;; and one custom one: %:P (expand to the project root).
|
||||||
|
@ -138,9 +147,6 @@ directives. By default, this only recognizes C directives.")
|
||||||
(advice-add #'evil-window-split :override #'+evil-window-split-a)
|
(advice-add #'evil-window-split :override #'+evil-window-split-a)
|
||||||
(advice-add #'evil-window-vsplit :override #'+evil-window-vsplit-a)
|
(advice-add #'evil-window-vsplit :override #'+evil-window-vsplit-a)
|
||||||
|
|
||||||
;; In evil, registers 2-9 are buffer-local. In vim, they're global, so...
|
|
||||||
(advice-add #'evil-global-marker-p :around #'+evil--make-numbered-markers-global-a)
|
|
||||||
|
|
||||||
;; Make o/O continue comments (see `+evil-want-o/O-to-continue-comments')
|
;; Make o/O continue comments (see `+evil-want-o/O-to-continue-comments')
|
||||||
(advice-add #'evil-open-above :around #'+evil--insert-newline-above-and-respect-comments-a)
|
(advice-add #'evil-open-above :around #'+evil--insert-newline-above-and-respect-comments-a)
|
||||||
(advice-add #'evil-open-below :around #'+evil--insert-newline-below-and-respect-comments-a)
|
(advice-add #'evil-open-below :around #'+evil--insert-newline-below-and-respect-comments-a)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue