2020-04-08 15:31:44 -04:00
|
|
|
;;; editor/evil/init.el -*- lexical-binding: t; -*-
|
|
|
|
|
2020-05-15 01:44:53 -04:00
|
|
|
(defvar evil-collection-key-blacklist)
|
|
|
|
|
2020-04-08 15:31:44 -04:00
|
|
|
;; We load evil-collection ourselves for these reasons:
|
|
|
|
;;
|
|
|
|
;; 1. To truly lazy load it. Some of its modules, like
|
|
|
|
;; evil-collection-{elisp-mode,buff-menu} are loaded immediately, because
|
|
|
|
;; Emacs loads their packages immediately, which pulls in all of
|
|
|
|
;; evil-collection (and other packages with it, sometimes).
|
|
|
|
;; 2. This ensures a predictable load order, versus lazy loading using :defer or
|
|
|
|
;; :after-call. This means users can use (after! org ...) and be sure that
|
|
|
|
;; their changes will override evil-collection's.
|
|
|
|
;; 3. Ideally, we'd do away with evil-collection entirely. It changes too often,
|
|
|
|
;; introduces breaking bugs too frequently, and I don't agree with all their
|
|
|
|
;; design choices. Regardless, it does more good than trouble, so it may be
|
|
|
|
;; here to stay.
|
|
|
|
;; 4. Adds `+evil-collection-disabled-list', to make it easier for users to
|
|
|
|
;; disable modules, and to reduce the effort required to maintain our copy of
|
|
|
|
;; `evil-collection-list' (now I can just copy it from time to time).
|
|
|
|
|
2020-05-25 02:58:07 -04:00
|
|
|
(when (and doom-interactive-p
|
2020-04-16 21:55:59 -04:00
|
|
|
(not doom-reloading-p)
|
|
|
|
(featurep! +everywhere))
|
2020-04-08 15:31:44 -04:00
|
|
|
|
2020-04-08 15:54:16 -04:00
|
|
|
(setq evil-collection-company-use-tng (featurep! :completion company +tng)
|
|
|
|
;; must be set before evil/evil-collection is loaded
|
|
|
|
evil-want-keybinding nil)
|
2020-04-08 15:31:44 -04:00
|
|
|
|
|
|
|
(defvar +evil-collection-disabled-list
|
|
|
|
'(anaconda-mode
|
|
|
|
buff-menu
|
2021-05-06 00:28:11 -04:00
|
|
|
calc
|
2020-04-08 15:31:44 -04:00
|
|
|
comint
|
|
|
|
company
|
|
|
|
custom
|
|
|
|
eldoc
|
|
|
|
elisp-mode
|
|
|
|
ert
|
|
|
|
free-keys
|
|
|
|
helm
|
2021-08-05 21:24:01 -04:00
|
|
|
help
|
2020-11-10 17:15:13 -05:00
|
|
|
indent
|
2020-04-08 15:31:44 -04:00
|
|
|
image
|
|
|
|
kotlin-mode
|
|
|
|
occur
|
2021-03-05 14:42:03 -05:00
|
|
|
outline
|
2020-04-08 15:31:44 -04:00
|
|
|
simple
|
|
|
|
slime
|
|
|
|
lispy)
|
|
|
|
"A list of `evil-collection' modules to ignore. See the definition of this
|
|
|
|
variable for an explanation of the defaults (in comments). See
|
|
|
|
`evil-collection-mode-list' for a list of available options.")
|
|
|
|
|
|
|
|
(defvar evil-collection-setup-minibuffer nil)
|
|
|
|
|
|
|
|
;; We do this ourselves, and better.
|
|
|
|
(defvar evil-collection-want-unimpaired-p nil)
|
2021-02-11 20:13:49 -05:00
|
|
|
;; Doom binds goto-reference on gD and goto-assignments on gA ourselves
|
|
|
|
(defvar evil-collection-want-find-usages-bindings-p nil)
|
2020-04-08 15:31:44 -04:00
|
|
|
|
|
|
|
;; We handle loading evil-collection ourselves
|
|
|
|
(defvar evil-collection--supported-modes nil)
|
|
|
|
|
|
|
|
;; This has to be defined here since evil-collection doesn't autoload its own.
|
|
|
|
;; It must be updated whenever evil-collection updates theirs. Here's an easy
|
|
|
|
;; way to update it:
|
|
|
|
;;
|
|
|
|
;; (with-current-buffer
|
|
|
|
;; (url-retrieve-synchronously "https://raw.githubusercontent.com/emacs-evil/evil-collection/master/evil-collection.el" t t)
|
|
|
|
;; (goto-char (point-min))
|
|
|
|
;; (when (re-search-forward "^(defvar evil-collection--supported-modes\n[^(]+")
|
|
|
|
;; (let ((list (sexp-at-point)))
|
|
|
|
;; ;; Fixes
|
|
|
|
;; (when (assq 'pdf list)
|
|
|
|
;; (setf (alist-get 'pdf list) '(pdf-tools)))
|
|
|
|
;; (let ((diff (cl-set-difference evil-collection-mode-list list :test #'equal)))
|
|
|
|
;; (list (- (length list) (length evil-collection-mode-list))
|
|
|
|
;; diff)
|
|
|
|
;; (message "diff: %s" diff)
|
|
|
|
;; (kill-new (prin1-to-string list))))))
|
|
|
|
|
|
|
|
(defvar evil-collection-mode-list
|
|
|
|
`(2048-game
|
|
|
|
ag
|
|
|
|
alchemist
|
|
|
|
anaconda-mode
|
|
|
|
apropos
|
|
|
|
arc-mode
|
2020-10-09 04:41:45 -04:00
|
|
|
auto-package-update
|
|
|
|
bm
|
2020-04-08 15:31:44 -04:00
|
|
|
bookmark
|
|
|
|
(buff-menu "buff-menu")
|
|
|
|
calc
|
|
|
|
calendar
|
|
|
|
cider
|
|
|
|
cmake-mode
|
|
|
|
comint
|
|
|
|
company
|
|
|
|
compile
|
2021-01-09 19:43:13 -05:00
|
|
|
consult
|
2020-04-08 15:31:44 -04:00
|
|
|
(custom cus-edit)
|
|
|
|
cus-theme
|
|
|
|
daemons
|
|
|
|
dashboard
|
|
|
|
deadgrep
|
|
|
|
debbugs
|
|
|
|
debug
|
2021-07-11 17:51:31 -04:00
|
|
|
devdocs
|
2021-01-09 19:43:13 -05:00
|
|
|
dictionary
|
2020-04-08 15:31:44 -04:00
|
|
|
diff-mode
|
|
|
|
dired
|
|
|
|
dired-sidebar
|
|
|
|
disk-usage
|
|
|
|
doc-view
|
|
|
|
docker
|
|
|
|
ebib
|
|
|
|
edbi
|
|
|
|
edebug
|
|
|
|
ediff
|
|
|
|
eglot
|
2020-07-17 01:17:22 -04:00
|
|
|
explain-pause-mode
|
2020-04-08 15:31:44 -04:00
|
|
|
elfeed
|
|
|
|
elisp-mode
|
|
|
|
elisp-refs
|
|
|
|
elisp-slime-nav
|
2021-07-11 17:51:31 -04:00
|
|
|
embark
|
2020-04-08 15:31:44 -04:00
|
|
|
emms
|
|
|
|
epa
|
|
|
|
ert
|
|
|
|
eshell
|
|
|
|
eval-sexp-fu
|
|
|
|
evil-mc
|
|
|
|
eww
|
2020-10-09 04:41:45 -04:00
|
|
|
finder
|
2020-04-08 15:31:44 -04:00
|
|
|
flycheck
|
|
|
|
flymake
|
|
|
|
free-keys
|
|
|
|
geiser
|
|
|
|
ggtags
|
|
|
|
git-timemachine
|
|
|
|
gnus
|
|
|
|
go-mode
|
|
|
|
grep
|
|
|
|
guix
|
|
|
|
hackernews
|
|
|
|
helm
|
|
|
|
help
|
|
|
|
helpful
|
|
|
|
hg-histedit
|
|
|
|
hungry-delete
|
|
|
|
ibuffer
|
|
|
|
image
|
|
|
|
image-dired
|
|
|
|
image+
|
2020-10-09 04:41:45 -04:00
|
|
|
imenu
|
2020-04-08 15:31:44 -04:00
|
|
|
imenu-list
|
2020-11-10 17:15:13 -05:00
|
|
|
(indent "indent")
|
2020-04-08 15:31:44 -04:00
|
|
|
indium
|
|
|
|
info
|
|
|
|
ivy
|
|
|
|
js2-mode
|
|
|
|
leetcode
|
|
|
|
lispy
|
|
|
|
log-edit
|
|
|
|
log-view
|
|
|
|
lsp-ui-imenu
|
|
|
|
lua-mode
|
|
|
|
kotlin-mode
|
|
|
|
macrostep
|
|
|
|
man
|
|
|
|
magit
|
|
|
|
magit-todos
|
|
|
|
monky
|
|
|
|
mu4e
|
|
|
|
mu4e-conversation
|
|
|
|
neotree
|
2020-10-09 04:41:45 -04:00
|
|
|
newsticker
|
2020-04-08 15:31:44 -04:00
|
|
|
notmuch
|
|
|
|
nov
|
|
|
|
(occur replace)
|
|
|
|
omnisharp
|
2020-10-09 04:41:45 -04:00
|
|
|
org-present
|
|
|
|
osx-dictionary
|
2020-04-08 15:31:44 -04:00
|
|
|
outline
|
|
|
|
p4
|
|
|
|
(package-menu package)
|
|
|
|
pass
|
|
|
|
(pdf pdf-tools)
|
|
|
|
popup
|
|
|
|
proced
|
|
|
|
prodigy
|
|
|
|
profiler
|
|
|
|
python
|
|
|
|
quickrun
|
|
|
|
racer
|
2021-01-18 19:55:04 -05:00
|
|
|
racket-describe
|
2020-04-08 15:31:44 -04:00
|
|
|
realgud
|
|
|
|
reftex
|
|
|
|
restclient
|
2020-10-09 04:41:45 -04:00
|
|
|
rg
|
2021-01-09 19:43:13 -05:00
|
|
|
ripgrep
|
2020-04-08 15:31:44 -04:00
|
|
|
rjsx-mode
|
|
|
|
robe
|
|
|
|
rtags
|
|
|
|
ruby-mode
|
2020-12-05 16:55:27 -05:00
|
|
|
sh-script
|
2020-04-08 15:31:44 -04:00
|
|
|
simple
|
|
|
|
slime
|
|
|
|
sly
|
2020-07-17 01:17:22 -04:00
|
|
|
speedbar
|
2020-04-08 15:31:44 -04:00
|
|
|
tablist
|
|
|
|
tar-mode
|
2021-07-11 17:51:31 -04:00
|
|
|
telega
|
2020-04-08 15:31:44 -04:00
|
|
|
(term term ansi-term multi-term)
|
|
|
|
tetris
|
2021-07-10 15:52:19 +03:00
|
|
|
thread
|
2020-04-08 15:31:44 -04:00
|
|
|
tide
|
2020-10-09 04:41:45 -04:00
|
|
|
timer-list
|
2020-04-08 15:31:44 -04:00
|
|
|
transmission
|
2020-10-09 04:41:45 -04:00
|
|
|
trashed
|
2021-07-12 00:19:49 -04:00
|
|
|
tuareg
|
2020-04-08 15:31:44 -04:00
|
|
|
typescript-mode
|
|
|
|
vc-annotate
|
|
|
|
vc-dir
|
|
|
|
vc-git
|
|
|
|
vdiff
|
|
|
|
view
|
|
|
|
vlf
|
|
|
|
vterm
|
|
|
|
w3m
|
|
|
|
wdired
|
|
|
|
wgrep
|
|
|
|
which-key
|
|
|
|
woman
|
|
|
|
xref
|
2020-10-12 23:54:26 -04:00
|
|
|
xwidget
|
2020-04-08 15:31:44 -04:00
|
|
|
youtube-dl
|
2020-11-10 17:15:13 -05:00
|
|
|
zmusic
|
2020-04-08 15:31:44 -04:00
|
|
|
(ztree ztree-diff)))
|
|
|
|
|
|
|
|
(defun +evil-collection-init (module &optional disabled-list)
|
|
|
|
"Initialize evil-collection-MODULE.
|
|
|
|
|
|
|
|
Unlike `evil-collection-init', this respects `+evil-collection-disabled-list',
|
|
|
|
and complains if a module is loaded too early (during startup)."
|
|
|
|
(unless (memq (or (car-safe module) module) disabled-list)
|
|
|
|
(doom-log "Initialized evil-collection-%s %s"
|
|
|
|
(or (car-safe module) module)
|
|
|
|
(if doom-init-time "" "(too early!)"))
|
|
|
|
(with-demoted-errors "evil-collection error: %s"
|
|
|
|
(evil-collection-init (list module)))))
|
|
|
|
|
2021-08-04 01:18:06 -04:00
|
|
|
(defadvice! +evil-collection-disable-blacklist-a (fn)
|
2020-08-17 18:00:11 -04:00
|
|
|
:around #'evil-collection-vterm-toggle-send-escape ; allow binding to ESC
|
|
|
|
(let (evil-collection-key-blacklist)
|
2021-08-04 01:18:06 -04:00
|
|
|
(funcall-interactively fn)))
|
2020-08-17 18:00:11 -04:00
|
|
|
|
2020-04-08 15:31:44 -04:00
|
|
|
;; These modes belong to packages that Emacs always loads at startup, causing
|
2020-10-09 04:41:45 -04:00
|
|
|
;; evil-collection and it's co-packages to all load immediately. We avoid this
|
|
|
|
;; by loading them after evil-collection has first loaded...
|
2020-04-08 15:31:44 -04:00
|
|
|
(with-eval-after-load 'evil-collection
|
|
|
|
;; Don't let evil-collection interfere with certain keys
|
|
|
|
(setq evil-collection-key-blacklist
|
|
|
|
(append (list doom-leader-key doom-localleader-key
|
|
|
|
doom-leader-alt-key)
|
|
|
|
(when (featurep! :tools lookup)
|
|
|
|
'("gd" "gf" "K"))
|
|
|
|
(when (featurep! :tools eval)
|
|
|
|
'("gr" "gR"))
|
|
|
|
'("[" "]" "gz" "<escape>")))
|
|
|
|
|
|
|
|
(evil-define-key* 'normal process-menu-mode-map
|
|
|
|
"q" #'kill-current-buffer
|
|
|
|
"d" #'process-menu-delete-process)
|
|
|
|
|
2020-12-11 05:01:33 -05:00
|
|
|
(mapc #'+evil-collection-init '(comint custom)))
|
2020-04-08 15:31:44 -04:00
|
|
|
|
|
|
|
;; ...or on first invokation of their associated major/minor modes.
|
2020-08-17 18:00:11 -04:00
|
|
|
(after! evil
|
2020-12-11 05:01:33 -05:00
|
|
|
;; Emacs loads these two packages immediately, at startup, which needlessly
|
|
|
|
;; convolutes load order for evil-collection-help.
|
2021-08-05 21:24:01 -04:00
|
|
|
(add-transient-hook! 'help-mode
|
|
|
|
(+evil-collection-init 'help))
|
2020-08-17 18:00:11 -04:00
|
|
|
(add-transient-hook! 'Buffer-menu-mode
|
|
|
|
(+evil-collection-init '(buff-menu "buff-menu")))
|
2021-05-06 00:28:11 -04:00
|
|
|
(add-transient-hook! 'calc-mode
|
|
|
|
(+evil-collection-init 'calc))
|
2020-08-17 18:00:11 -04:00
|
|
|
(add-transient-hook! 'image-mode
|
|
|
|
(+evil-collection-init 'image))
|
|
|
|
(add-transient-hook! 'emacs-lisp-mode
|
|
|
|
(+evil-collection-init 'elisp-mode))
|
|
|
|
(add-transient-hook! 'occur-mode
|
|
|
|
(+evil-collection-init '(occur replace)))
|
2020-11-10 17:15:13 -05:00
|
|
|
(add-transient-hook! 'indent-rigidly
|
|
|
|
(+evil-collection-init '(indent "indent")))
|
2020-08-17 18:00:11 -04:00
|
|
|
(add-transient-hook! 'minibuffer-setup-hook
|
|
|
|
(when evil-collection-setup-minibuffer
|
|
|
|
(+evil-collection-init 'minibuffer)
|
|
|
|
(evil-collection-minibuffer-insert)))
|
|
|
|
(add-transient-hook! 'process-menu-mode
|
|
|
|
(+evil-collection-init '(process-menu simple)))
|
2020-10-09 04:41:45 -04:00
|
|
|
(add-transient-hook! 'tabulated-list-mode
|
|
|
|
(+evil-collection-init 'tabulated-list))
|
2021-07-10 15:52:19 +03:00
|
|
|
(add-transient-hook! 'tab-bar-mode
|
|
|
|
(+evil-collection-init 'tab-bar))
|
2020-04-08 15:31:44 -04:00
|
|
|
|
2020-08-17 18:00:11 -04:00
|
|
|
;; HACK Do this ourselves because evil-collection break's `eval-after-load'
|
|
|
|
;; load order by loading their target plugin before applying keys. This
|
|
|
|
;; makes it hard for end-users to overwrite these keybinds with a
|
|
|
|
;; simple `after!' or `with-eval-after-load'.
|
|
|
|
(dolist (mode evil-collection-mode-list)
|
|
|
|
(dolist (req (or (cdr-safe mode) (list mode)))
|
|
|
|
(with-eval-after-load req
|
|
|
|
(+evil-collection-init mode +evil-collection-disabled-list))))))
|