Fork me on GitHub
#emacs
<
2019-11-14
>
andrea.crotti20:11:34

tiny helper but incredibly useful for me

(require 'dumb-jump)

(defun cider-or-dumb-jump ()
  (interactive)
  (if (cider-connected-p)
      (cider-find-var)
    (dumb-jump-go)))

(add-hook 'clojure-mode-hook
          (lambda ()
            (local-set-key (kbd "M-.") 'cider-or-dumb-jump)))

andrea.crotti20:11:11

Falls back to the dumb jump library if cider is connecter

andrea.crotti20:11:56

I heard that spacemacs does this by default, I should steal more from them

Jcaw22:11:34

It does but honestly their system is pretty dodgy.

Jcaw22:11:05

IIRC there's a package, smart-jump, that takes this approach for all modes. Might be worth making a PR.

sogaiu20:11:22

does dumb-jump work with one's dependencies?

andrea.crotti20:11:42

Well probably not it just jump around your local code

andrea.crotti20:11:32

It's not the same as the cider option of course, but useful on big projects you're just browsing when you don't want a repl

dpsutton20:11:31

lsp can serve the same benefit if you're interested in setting that up

sogaiu21:11:35

i've tried lsp, but am not big on the having to run additional servers approach. i didn't have success with dump-jump for working with identifiers in dependencies and wrote something that uses clj-kondo to create TAGS files -- it covers the project as well as the dependencies. it's taking a bit longer than i was hoping in order to handle namespace and alias prefixes, but a friend and i are finding it to be useful.

sogaiu21:11:38

wanted to know though if someone did get dump-jump working, because it would be less work 🙂

andrea.crotti21:11:11

Ah nice, can you share some code @sogaiu?

sogaiu21:11:44

@andrea.crotti if you don't mind some rough edges: https://gist.github.com/sogaiu/6cb947b00ae13d00d4ae16ab7aaf97e4 -- if you try it out, i'd be interested in hearing about your experience. working on improving it, but it's a bit slow-going 🙂

sogaiu21:11:11

(on a side note, with the advent of clindex, i wonder whether that couldn't be used to create TAGS/tags)

Jcaw22:11:05

IIRC there's a package, smart-jump, that takes this approach for all modes. Might be worth making a PR.