Fork me on GitHub
#emacs
<
2020-08-26
>
rickmoynihan07:08:20

Is there anything like anakondo (i.e. that can operate without a repl) that will do jump to definition?

jakemcc20:08:36

dumb-jump is pretty good and works across many languages https://github.com/jacktasia/dumb-jump

rickmoynihan08:08:42

@U06SWJ2RH: Interesting… I guess unlike alc.index-defs though, that it can’t jump to dependencies / git deps etc

rickmoynihan08:08:38

still nice to have an option giving broad shallow coverage, rather than narrow but deep.

jakemcc21:08:14

@U06HHF230 yeah. I really enjoy having it as the backstop. Can open many languages that I'm not set up for and get some amount of jumping within that project.

sogaiu07:08:13

if you don't mind static generation periodically that takes some time, yes

sogaiu07:08:40

this uses clj-kondo's analysis

rickmoynihan07:08:59

yeah was looking for something that uses clj-kondo; thanks

rickmoynihan07:08:45

Cool seems to work on one project but on another it raises an exception…

rickmoynihan07:08:37

$ clj -Sdeps '{:deps {alc.index-defs {:git/url "" :sha "4d26c6109fad267839ba10e7144660193a8be9a2"}}}' -m alc.index-defs.etags
* checking specified options
  input: {:proj-dir /Users/rick/repos/project, :format :etags}
  output: {:proj-dir /Users/rick/repos/project, :format :etags, :out-name TAGS, :overwrite false, :verbose true}
* determining paths to analyze
  found shadow-cljs.edn
  found deps.edn
  >> classpath computation by: shadow-cljs <<
  found yarn.lock
  found package-lock.json
  >> yarn.lock newer <<
  chose yarn to invoke shadow-cljs
Execution error (NumberFormatException) at java.lang.Integer/parseInt (Integer.java:542).
null

Full report at:
/var/folders/ln/536xqskd3_g80n5pdbsjkrjw0000gn/T/clojure-7955288199004901369.edn

rickmoynihan07:08:37

I can open an issue for it if you like

sogaiu07:08:31

ah thanks -- if that's convenient for you. i'm also ok to take details here.

sogaiu07:08:54

are there some bits i might use to reproduce?

rickmoynihan07:08:10

it’s a proprietary project, so not really 😞

sogaiu07:08:54

it looks like it involves some cljs -- is that correct?

rickmoynihan07:08:19

yeah it’s clj and cljs/cljc combined in the same source tree

rickmoynihan07:08:48

shadow-cljs build for clojurescript side, deps.edn project

sogaiu07:08:48

is the shadow-cljs version recent?

sogaiu07:08:07

ok, you can actually select to have clj compute the classpath.

rickmoynihan07:08:14

shadow-cljs reports: cli version: 2.8.26 node: v13.7.0

sogaiu07:08:58

that's the issue

sogaiu07:08:03

that shadow-cljs is too old

sogaiu07:08:26

the ability for shadow-cljs to do classpath computation was 2.8.53 or so and above iiuc

rickmoynihan07:08:35

will try bumping it and see if it resolves it… we normally keep it pretty up to date, but shadow moves pretty quick

sogaiu07:08:09

indeed it does!

sogaiu07:08:30

for reference you can choose to use clj do the classpath computation: https://github.com/sogaiu/alc.index-defs/blob/master/doc/technical-details.md

sogaiu07:08:56

adding something like:

'{:method :deps}'
to the invocation at the end may work

rickmoynihan07:08:39

will that still index the cljs?

sogaiu07:08:57

i think it depends on what clj gives back as the classpath

sogaiu07:08:27

so the classpath computation is used by clj-kondo to decide what to index (iirc, it's been a while since i've looked at the code 😅 )

rickmoynihan07:08:34

yeah in that case it should work

rickmoynihan07:08:28

hmm so firstly I think I’ve upgraded shadow-cljs now, and I still seem to get the same error

sogaiu07:08:47

hmm, may i ask which version?

sogaiu07:08:14

ok, thanks. i haven't tried that version yet, but will do so.

rickmoynihan07:08:44

cool… secondly adding the '{:method :deps}' arguments also fails

sogaiu07:08:54

is it the same error?

rickmoynihan07:08:10

* checking specified options
  input: {:proj-dir /Users/rick/repos/muttnik, :method :deps, :format :etags}
  output: {:proj-dir /Users/rick/repos/muttnik, :method :deps, :format :etags, :out-name TAGS, :overwrite false, :verbose true}
* determining paths to analyze
  found shadow-cljs.edn
  found deps.edn
  >> classpath computation by: deps <<
Execution error (IllegalArgumentException) at alc.index-defs.impl.analyze/study-project-and-deps (analyze.clj:104).
No method in multimethod 'get-lint-paths' for dispatch value: :deps

Full report at:
/var/folders/ln/536xqskd3_g80n5pdbsjkrjw0000gn/T/clojure-6386543814520584285.edn

sogaiu07:08:15

very sorry it hasn't worked for you 😞 i will investigate. thanks for trying things out.

rickmoynihan07:08:40

@sogaiu: Not at all, I’m sorry for giving you a hard time 🙂

rickmoynihan07:08:00

It seems to work on a different project

sogaiu07:08:12

please try '{:method :clj}'

rickmoynihan07:08:25

yeah was just about to take a look myself

sogaiu07:08:42

i grepped my shell history and had made an erroneous invocation before 😅

rickmoynihan07:08:19

ok it’s doing something this time 🤞

sogaiu07:08:05

(i hope the shadow-cljs upgrade is ok)

rickmoynihan07:08:35

well I’ll only commit it, if it is 🙂

sogaiu07:08:00

ah yes, the wonders of revision control 🙂

rickmoynihan07:08:58

A colleague of mine is usually pretty fastidious at keeping that dependency upgraded… he’s obviously been slacking this time 😆

sogaiu07:08:12

or may be he knows that things break 😛

rickmoynihan07:08:47

he’ll be on it if it does, he’s pretty good at working through those issues

rickmoynihan07:08:19

ok this seems to have worked… thanks a tonne for the help, and great project. It’ll save me starting a REPL when I want to do a casual code review on small PRs, or help colleagues understand what is going on

sogaiu07:08:46

thanks for trying things out! please let me know if you have any problems / suggestions 🙂

rickmoynihan07:08:56

I have one suggestion actually… Adding support for the new -F/ -X params

rickmoynihan07:08:12

Oh actually you already basically do… aic/do-it takes a map of opts already :thinking_face:

sogaiu07:08:36

thanks! i haven't tried the -F/-X stuff but will investigate.

rickmoynihan08:08:06

Ok I’ve just set it up this way in my ~/.clojure/deps.edn:

rickmoynihan08:08:11

:build-tags {:deps {alc.index-defs {:git/url "" :sha "4d26c6109fad267839ba10e7144660193a8be9a2"}}
               :fn alc.index-defs.core/do-it!
               :args {:format :etags
                      :proj-dir "."
                      :method :clj}}

rickmoynihan08:08:39

You can then call it from any project with: clj -A:build-deps -X:build-deps

rickmoynihan08:08:16

(IIRC a newer (future) version of tools.deps will mean you won’t need to also pass -A:build-deps, just -X:build-deps would be enough)

sogaiu08:08:32

thanks for taking the time to explain!

sogaiu07:08:12

note that this doesn't do locals

ericdallo13:08:06

@sogaiu take a look at https://github.com/snoe/clojure-lsp using https://emacs-lsp.github.io/lsp-mode/, you can have multiple features like go-to-definition, find references, code actions, clj-kondo analysis, breadcrumb, modeline diagnostics and a lot more 🙂 You can see the major features https://emacs-lsp.github.io/lsp-mode/page/main-features/

ericdallo13:08:15

for more info about lsp you can ask on #lsp too

sogaiu21:08:33

thanks i have tried a few times before :)

sogaiu21:08:33

i also usually prefer modular independent pieces and am not really into "servers", but having said that, i am happy there are multiple approaches. good to have choice in these matters :)

ericdallo21:08:35

Yes 🙂 it's better than having no option

sogaiu21:08:41

ha ha, indeed!