feature/evil: move custom keybinds to private module

This commit is contained in:
Henrik Lissner 2017-05-15 13:52:01 +02:00
parent bba02e7b38
commit 04c270d76b
2 changed files with 38 additions and 39 deletions

View file

@ -281,6 +281,7 @@ across windows."
(add-hook 'evil-replace-state-entry-hook #'+evil|escape-enable) (add-hook 'evil-replace-state-entry-hook #'+evil|escape-enable)
(add-hook 'evil-replace-state-exit-hook #'+evil|escape-disable) (add-hook 'evil-replace-state-exit-hook #'+evil|escape-disable)
:config :config
(map! :irvo "C-g" #'evil-escape)
(setq evil-escape-key-sequence "jk" (setq evil-escape-key-sequence "jk"
evil-escape-delay 0.25)) evil-escape-delay 0.25))
@ -310,19 +311,19 @@ across windows."
:commands (evilmi-jump-items evilmi-text-object global-evil-matchit-mode) :commands (evilmi-jump-items evilmi-text-object global-evil-matchit-mode)
:config (global-evil-matchit-mode 1) :config (global-evil-matchit-mode 1)
:init :init
(map! :m "%" #'evilmi-jump-items)
(+evil--textobj "%" #'evilmi-text-object) (+evil--textobj "%" #'evilmi-text-object)
:config
(defun +evil|simple-matchit () (defun +evil|simple-matchit ()
"Force evil-matchit to favor simple bracket jumping. Helpful where the new "A hook to force evil-matchit to favor simple bracket jumping. Helpful when
algorithm is just confusing, like in python or ruby." the new algorithm is confusing, like in python or ruby."
(setq-local evilmi-always-simple-jump t))) (setq-local evilmi-always-simple-jump t))
(add-hook 'python-mode-hook #'+evil|simple-matchit))
(def-package! evil-mc (def-package! evil-mc
:commands evil-mc-make-cursor-here :commands evil-mc-make-cursor-here
:init :init (defvar evil-mc-key-map (make-sparse-keymap))
(defvar evil-mc-key-map (make-sparse-keymap))
(map! :n "M-d" #'evil-mc-make-cursor-here)
:config :config
;; Start evil-mc in paused mode. ;; Start evil-mc in paused mode.
(add-hook 'evil-mc-mode-hook #'evil-mc-pause-cursors) (add-hook 'evil-mc-mode-hook #'evil-mc-pause-cursors)
@ -332,21 +333,16 @@ algorithm is just confusing, like in python or ruby."
(setq evil-mc-custom-known-commands (setq evil-mc-custom-known-commands
'((doom/deflate-space-maybe . ((:default . evil-mc-execute-default-call))))) '((doom/deflate-space-maybe . ((:default . evil-mc-execute-default-call)))))
;; My workflow is to place the cursors, get into position, then enable evil-mc
;; by invoking `+evil/mc-toggle-cursors'
(defun +evil/mc-toggle-cursors () (defun +evil/mc-toggle-cursors ()
"Toggle frozen state of evil-mc cursors." "Toggle frozen state of evil-mc cursors."
(interactive) (interactive)
(setq evil-mc-frozen (not (and (evil-mc-has-cursors-p) (setq evil-mc-frozen (not (and (evil-mc-has-cursors-p)
evil-mc-frozen)))) evil-mc-frozen))))
;; ...or going into insert mode
;; My workflow is to place the cursors, get into position, then enable evil-mc
;; (either by going into insert mode, or pressing M-d).
(map! :map evil-mc-key-map
:n "M-D" #'+evil/mc-toggle-cursors)
;; If I switch to insert mode, chances are I want to begin editing.
(add-hook 'evil-insert-state-entry-hook #'evil-mc-resume-cursors) (add-hook 'evil-insert-state-entry-hook #'evil-mc-resume-cursors)
;; Undo cursors on ESC (from normal mode)
(defun +evil|escape-multiple-cursors () (defun +evil|escape-multiple-cursors ()
"Undo cursors and freeze them again (for next time)." "Undo cursors and freeze them again (for next time)."
(when (evil-mc-has-cursors-p) (when (evil-mc-has-cursors-p)
@ -364,22 +360,7 @@ algorithm is just confusing, like in python or ruby."
evil-multiedit-next evil-multiedit-next
evil-multiedit-prev evil-multiedit-prev
evil-multiedit-abort evil-multiedit-abort
evil-multiedit-ex-match) evil-multiedit-ex-match))
:init
(map! :v "M-d" #'evil-multiedit-match-and-next
:v "M-D" #'evil-multiedit-match-and-prev
:v "C-M-d" #'evil-multiedit-restore
:v "R" #'evil-multiedit-match-all)
:config
(evil-ex-define-cmd "ie[dit]" 'evil-multiedit-ex-match)
(map! (:map evil-multiedit-state-map
"M-d" #'evil-multiedit-match-and-next
"M-D" #'evil-multiedit-match-and-prev
"RET" #'evil-multiedit-toggle-or-restrict-region)
(:map (evil-multiedit-state-map evil-multiedit-insert-state-map)
"C-n" #'evil-multiedit-next
"C-p" #'evil-multiedit-prev)))
(def-package! evil-textobj-anyblock (def-package! evil-textobj-anyblock
@ -418,12 +399,19 @@ algorithm is just confusing, like in python or ruby."
:config (global-evil-surround-mode 1)) :config (global-evil-surround-mode 1))
;; Without `evil-visualstar', * and # grab the word at point and search, no
;; matter what mode you're in. I want to be able to visually select a region and
;; search for other occurrences of it.
(def-package! evil-visualstar (def-package! evil-visualstar
:commands (global-evil-visualstar-mode :commands (global-evil-visualstar-mode
evil-visualstar/begin-search evil-visualstar/begin-search
evil-visualstar/begin-search-forward evil-visualstar/begin-search-forward
evil-visualstar/begin-search-backward) evil-visualstar/begin-search-backward)
:config (global-evil-visualstar-mode 1)) :init
(map! :v "*" #'evil-visualstar/begin-search-forward
:v "#" #'evil-visualstar/begin-search-backward)
:config
(global-evil-visualstar-mode 1))
;; A side-panel for browsing my project files. Inspired by vim's NERDTree. Sure, ;; A side-panel for browsing my project files. Inspired by vim's NERDTree. Sure,

View file

@ -277,9 +277,24 @@
:i "C-p" (λ! (let ((company-selection-wrap-around t)) :i "C-p" (λ! (let ((company-selection-wrap-around t))
(call-interactively 'company-dabbrev-code) (call-interactively 'company-dabbrev-code)
(company-select-previous-or-abort)))) (company-select-previous-or-abort))))
;; evil-visual-star ;; evil-mc
:v "*" #'evil-visualstar/begin-search-forward :n "M-d" #'evil-mc-make-cursor-here
:v "#" #'evil-visualstar/begin-search-backward (:after evil-mc
:map evil-mc-key-map
:n "M-D" #'+evil/mc-toggle-cursors)
;; evil-multiedit
:v "M-d" #'evil-multiedit-match-and-next
:v "M-D" #'evil-multiedit-match-and-prev
:v "C-M-d" #'evil-multiedit-restore
:v "R" #'evil-multiedit-match-all
(:after evil-multiedit
(:map evil-multiedit-state-map
"M-d" #'evil-multiedit-match-and-next
"M-D" #'evil-multiedit-match-and-prev
"RET" #'evil-multiedit-toggle-or-restrict-region)
(:map (evil-multiedit-state-map evil-multiedit-insert-state-map)
"C-n" #'evil-multiedit-next
"C-p" #'evil-multiedit-prev))
;; evil-surround ;; evil-surround
:v "S" #'evil-surround-region :v "S" #'evil-surround-region
:o "s" #'evil-surround-edit :o "s" #'evil-surround-edit
@ -289,8 +304,6 @@
:v "V" #'er/contract-region :v "V" #'er/contract-region
;; rotate-text ;; rotate-text
:n "!" #'rotate-text :n "!" #'rotate-text
;; evil-matchit
:m "%" #'evilmi-jump-items
;; hide-show/evil-matchit ;; hide-show/evil-matchit
:nv "<tab>" #'+evil/matchit-or-toggle-fold :nv "<tab>" #'+evil/matchit-or-toggle-fold
@ -339,8 +352,6 @@
;; Emacsien motions for insert mode ;; Emacsien motions for insert mode
:i "C-b" #'backward-word :i "C-b" #'backward-word
:i "C-f" #'forward-word :i "C-f" #'forward-word
;; escape from insert mode (more responsive than using key-chord-define)
:irv "C-g" #'evil-normal-state
;; Highjacks space/backspace to: ;; Highjacks space/backspace to:
;; a) balance spaces inside brackets/parentheses ( | ) -> (|) ;; a) balance spaces inside brackets/parentheses ( | ) -> (|)