Add find-references/find-usages type bindings

Since these bindings have a potential usage clash with "gr", we add an
additional option here to do disable for the case where the user wants to keep
"gr" in their non programming modes but don't want find-refs type keybindings in
their programming modes.

g? may be another good candidate for finding references.
This commit is contained in:
James Nguyen 2021-02-03 11:47:59 -08:00
parent 1b86bac736
commit 48d2b1ef6e
9 changed files with 58 additions and 7 deletions

View File

@ -115,6 +115,13 @@ through removing their entry from `evil-collection-mode-list'."
:type 'boolean
:group 'evil-collection)
(defcustom evil-collection-want-find-usages-bindings t
"Whether to bind `xref-find-references'-like bindings.
This will bind additional find-* type commands, e.g. usages, assignments, etc.."
:type 'boolean
:group 'evil-collection)
(defvar evil-collection--supported-modes
`(2048-game
ag

View File

@ -51,14 +51,16 @@
"q" 'quit-window))
(evil-collection-define-key 'normal 'anaconda-mode-map
;; Would be nice to support these too.
;; 'anaconda-mode-find-assignments
;; 'anaconda-mode-find-references
"gd" 'anaconda-mode-find-definitions
(kbd "C-t") (if (fboundp 'anaconda-mode-go-back)
'anaconda-mode-go-back
'xref-pop-marker-stack)
"K" 'anaconda-mode-show-doc))
"K" 'anaconda-mode-show-doc)
(when evil-collection-want-find-usages-bindings
(evil-collection-define-key 'normal 'anaconda-mode-map
"gA" 'anaconda-mode-find-assignments
"gr" 'anaconda-mode-find-references)))
(provide 'evil-collection-anaconda-mode)
;;; evil-collection-anaconda-mode.el ends here

View File

@ -37,7 +37,11 @@
(evil-collection-define-key 'normal 'eglot-mode-map
"gd" 'xref-find-definitions
(kbd "C-t") 'xref-pop-marker-stack
"K" 'eldoc-doc-buffer))
"K" 'eldoc-doc-buffer)
(when evil-collection-want-find-usages-bindings
(evil-collection-define-key 'normal 'eglot-mode-map
"gr" 'xref-find-references)))
(provide 'evil-collection-eglot)
;;; evil-collection-eglot.el ends here

View File

@ -83,7 +83,11 @@ alternative printed representations that can be displayed."
(evil-set-initial-state 'emacs-lisp-mode 'normal)
(evil-collection-define-key 'normal 'emacs-lisp-mode-map
"gz" 'evil-collection-elisp-mode-ielm-repl))
"gz" 'evil-collection-elisp-mode-ielm-repl)
(when evil-collection-want-find-usages-bindings
(evil-collection-define-key 'normal 'emacs-lisp-mode-map
"gr" 'xref-find-references)))
(provide 'evil-collection-elisp-mode)
;;; evil-collection-elisp-mode.el ends here

View File

@ -98,7 +98,17 @@
(kbd "C-t") 'geiser-pop-symbol-stack
"gZ" 'geiser-mode-switch-to-repl-and-enter
"gz" 'geiser-mode-switch-to-repl
"K" 'geiser-doc-symbol-at-point))
"K" 'geiser-doc-symbol-at-point)
(when evil-collection-want-find-usages-bindings
;; FIXME:
;; ("Callers" ((kbd "C-c <")) geiser-xref-callers
;; :enable (and (geiser-eval--supported-p 'callers)
;; (geiser--symbol-at-point)))
;; ("Callees" ((kbd "C-c >")) geiser-xref-callees
;; :enable (and (geiser-eval--supported-p 'callees)
;; (geiser--symbol-at-point)))
))
(provide 'evil-collection-geiser)
;;; evil-collection-geiser.el ends here

View File

@ -58,6 +58,10 @@
(kbd "C-t") 'ggtags-prev-mark
"gf" 'ggtags-find-file)
(when evil-collection-want-find-usages-bindings
(evil-collection-define-key 'normal 'ggtags-mode-map
"gr" 'ggtags-find-reference))
(evil-collection-define-key 'normal 'ggtags-view-search-history-mode-map
"gj" 'ggtags-view-search-history-next
"gk" 'ggtags-view-search-history-prev

View File

@ -161,6 +161,10 @@
"gd" 'slime-edit-definition
"gz" 'slime-switch-to-output-buffer)
(when evil-collection-want-find-usages-bindings
(evil-collection-define-key 'normal 'slime-mode-map
"gr" 'slime-who-references))
(evil-collection-define-key 'normal 'slime-popup-buffer-mode-map
;; quit
"q" 'quit-window

View File

@ -169,6 +169,10 @@ Evil version of `sly-eval-print-last-expression' that accounts for
"gd" 'sly-edit-definition
"gz" 'sly-mrepl)
(when evil-collection-want-find-usages-bindings
(evil-collection-define-key 'normal 'sly-mode-map
"gr" 'sly-who-references))
(evil-collection-define-key 'normal 'sly-popup-buffer-mode-map
;; quit
"q" 'quit-window

View File

@ -101,6 +101,7 @@ more.
| evil-collection-setup-minibuffer | nil | Set up Vim style bindings in the minibuffer. |
| evil-collection-setup-debugger-keys | t | Set up debugger keys for certain modes. |
| evil-collection-want-unimpaired-p | t | Set up unimpaired bindings globally. |
| evil-collection-want-find-usages-bindings | t | Bind -find references-, etc to various modes. |
For example, if you want to enable Evil in the minibuffer, you'll have to turn it on
explicitly by customizing ~evil-collection-setup-minibuffer~ to ~t~.
@ -337,6 +338,17 @@ more.
- ~gd~: [g]o to [d]efinition. This is mostly for programming modes.
If there's a corresponding 'pop' action, use ~C-t~.
*** Go to references, etc (~gr~, ~gA~)
When ~evil-collection-want-find-usages-bindings~ is set to t:
- ~gr~: [g] to [r]eferences. This binding is also used for refresh/reverting
modes in non programming modes but is usually empty for programming modes.
- ~gA~: [g]o to [A]ssignments.
- Additional bindings:
There may be additional binds under this category. Please file a Pull Request if so.
*** Go to current entity
- ~.~: go to current entity (day for calendar, playing track for [[EMMS][EMMS]]).