Replace :xref-backend setting with :jump

Which takes :definitions, :references, :documentation and :xref-backend.
Each accepts a function that will jump to definitions, references, and
documentation respectively.

If a major-mode has an :xref-backend, you don't need :definitions or
:references.
This commit is contained in:
Henrik Lissner
2017-06-19 00:25:49 +02:00
parent 928812da8a
commit bc3aee2a4f
6 changed files with 102 additions and 56 deletions

View File

@@ -22,29 +22,46 @@
"An alist that maps online resources to their search url or a function that
produces an url. Used by `+jump/online'.")
(def-setting! :xref-backend (mode function)
"TODO"
`(add-hook! ,mode
(add-hook 'xref-backend-functions #',function nil t)))
(defvar +jump-function-alist nil
"TODO")
(set! :popup "*xref*" :noselect t :autokill t :autoclose t)
(defvar-local +jump-current-functions nil
"TODO")
(def-setting! :jump (modes &rest plist)
"TODO"
`(dolist (mode (doom-enlist ,modes))
(push (cons mode (list ,@plist)) +jump-function-alist)))
;; Let me control what backends to fall back on
(setq-default xref-backend-functions '(t))
(set! :popup "*xref*" :noselect t :autokill t :autoclose t)
;; Recenter after certain jumps
(add-hook!
'(imenu-after-jump-hook evil-jumps-post-jump-hook
counsel-grep-post-action-hook dumb-jump-after-jump-hook)
#'recenter)
(defun +jump|init ()
"Initialize `+jump-current-functions', used by `+jump/definition',
`+jump/references' and `+jump/documentation'."
(when-let (plist (cdr (assq major-mode +jump-function-alist)))
(when-let (backend (plist-get plist :xref-backend))
(make-variable-buffer-local 'xref-backend-functions)
(cl-pushnew backend xref-backend-functions :test #'eq))
(setq-local +jump-current-functions plist)))
(add-hook 'after-change-major-mode-hook #'+jump|init)
;;
;; Packages
;;
(def-package! dumb-jump
:commands (dumb-jump-go dumb-jump-quick-look dumb-jump-back)
:commands (dumb-jump-go dumb-jump-quick-look
dumb-jump-back dumb-jump-result-follow)
:config
(setq dumb-jump-default-project doom-emacs-dir
dumb-jump-aggressive nil