Improves jump-to-definition for Clojure modes

This commit is contained in:
Ag Ibragimov 2017-10-27 19:53:47 -07:00 committed by syl20bnr
parent 19b42377bb
commit 2be8400975
2 changed files with 15 additions and 1 deletions

View file

@ -170,3 +170,12 @@ If called with a prefix argument, uses the other-window instead."
(when (memq dotspacemacs-editing-style '(hybrid vim))
(evil-make-overriding-map cider--debug-mode-map 'normal)
(evil-normalize-keymaps)))
(defun spacemacs/clj-find-var ()
"Attempts to jump-to-definition of the symbol-at-point. If CIDER fails, or not available, falls back to dumb-jump"
(interactive)
(let ((var (cider-symbol-at-point)))
(if (and (cider-connected-p) (cider-var-info var))
(unless (eq 'symbol (type-of (cider-find-var nil var)))
(dumb-jump-go))
(dumb-jump-go))))

View file

@ -47,7 +47,12 @@
spacemacs-jump-handlers-clojurescript-mode
spacemacs-jump-handlers-clojurex-mode
spacemacs-jump-handlers-cider-repl-mode))
(add-to-list x 'cider-find-var))
(add-to-list x 'spacemacs/clj-find-var))
(add-hook 'clojure-mode-hook #'spacemacs//init-jump-handlers-clojure-mode)
(add-hook 'clojurescript-mode-hook #'spacemacs//init-jump-handlers-clojurescript-mode)
(add-hook 'clojurec-mode-hook #'spacemacs//init-jump-handlers-clojurec-mode)
(add-hook 'cider-repl-mode-hook #'spacemacs//init-jump-handlers-cider-repl-mode)
;; TODO: having this work for cider-macroexpansion-mode would be nice,
;; but the problem is that it uses clojure-mode as its major-mode