Is there anything like anakondo (i.e. that can operate without a repl) that will do jump to definition?
dumb-jump is pretty good and works across many languages https://github.com/jacktasia/dumb-jump
@jakemcc: Interesting… I guess unlike alc.index-defs
though, that it can’t jump to dependencies / git deps etc
still nice to have an option giving broad shallow coverage, rather than narrow but deep.
@rickmoynihan 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.
if you don't mind static generation periodically that takes some time, yes
this uses clj-kondo's analysis
yeah was looking for something that uses clj-kondo; thanks
👀
for use with emacs: https://github.com/sogaiu/alc.index-defs/blob/master/doc/emacs.md
note that this doesn't do locals
Cool seems to work on one project but on another it raises an exception…
lsp
$ clj -Sdeps '{:deps {alc.index-defs {:git/url "<https://github.com/sogaiu/alc.index-defs>" :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
exception is:
I can open an issue for it if you like
ah thanks -- if that's convenient for you. i'm also ok to take details here.
are there some bits i might use to reproduce?
it’s a proprietary project, so not really 😞
ah i see.
it looks like it involves some cljs -- is that correct?
yeah it’s clj and cljs/cljc combined in the same source tree
shadow-cljs build for clojurescript side, deps.edn project
is the shadow-cljs version recent?
ok, you can actually select to have clj compute the classpath.
shadow-cljs reports: cli version: 2.8.26 node: v13.7.0
ah ok
that's the issue
that shadow-cljs is too old
the ability for shadow-cljs to do classpath computation was 2.8.53 or so and above iiuc
will try bumping it and see if it resolves it… we normally keep it pretty up to date, but shadow moves pretty quick
indeed it does!
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
adding something like:
'{:method :deps}'
to the invocation at the end may workwill that still index the cljs?
i think it depends on what clj gives back as the classpath
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 😅 )
yeah in that case it should work
hmm so firstly I think I’ve upgraded shadow-cljs now, and I still seem to get the same error
hmm, may i ask which version?
2.11.0
ok, thanks. i haven't tried that version yet, but will do so.
cool… secondly adding the '{:method :deps}'
arguments also fails
is it the same error?
no
* 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
very sorry it hasn't worked for you 😞 i will investigate. thanks for trying things out.
@sogaiu: Not at all, I’m sorry for giving you a hard time 🙂
It seems to work on a different project
ah, sorry
please try '{:method :clj}'
my bad
ahh
yeah was just about to take a look myself
i grepped my shell history and had made an erroneous invocation before 😅
ok it’s doing something this time 🤞
(i hope the shadow-cljs upgrade is ok)
well I’ll only commit it, if it is 🙂
ah yes, the wonders of revision control 🙂
A colleague of mine is usually pretty fastidious at keeping that dependency upgraded… he’s obviously been slacking this time 😆
or may be he knows that things break 😛
he’ll be on it if it does, he’s pretty good at working through those issues
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
thanks for trying things out! please let me know if you have any problems / suggestions 🙂
I have one suggestion actually…
Adding support for the new -F
/ -X
params
Oh actually you already basically do… aic/do-it
takes a map of opts already :thinking_face:
thanks! i haven't tried the -F/-X
stuff but will investigate.
Ok I’ve just set it up this way in my ~/.clojure/deps.edn
:
:build-tags {:deps {alc.index-defs {:git/url "<https://github.com/sogaiu/alc.index-defs>" :sha "4d26c6109fad267839ba10e7144660193a8be9a2"}}
:fn alc.index-defs.core/do-it!
:args {:format :etags
:proj-dir "."
:method :clj}}
You can then call it from any project with:
clj -A:build-deps -X:build-deps
(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)
thanks for taking the time to explain!
@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/
for more info about lsp you can ask on #lsp too
thanks i have tried a few times before :)
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 :)
Yes 🙂 it's better than having no option
ha ha, indeed!