This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-08-06
Channels
- # aleph (1)
- # announcements (2)
- # beginners (109)
- # calva (48)
- # cider (25)
- # clj-kondo (38)
- # cljdoc (13)
- # clojure (203)
- # clojure-europe (23)
- # clojure-gamedev (3)
- # clojure-nl (3)
- # clojure-uk (7)
- # conjure (2)
- # data-science (1)
- # datalog (2)
- # datomic (7)
- # deps-new (16)
- # depstar (2)
- # docker (2)
- # fulcro (67)
- # graalvm (58)
- # honeysql (16)
- # java (2)
- # jobs (2)
- # jobs-discuss (2)
- # kaocha (4)
- # lsp (82)
- # malli (23)
- # off-topic (35)
- # polylith (18)
- # practicalli (5)
- # releases (1)
- # remote-jobs (1)
- # shadow-cljs (15)
- # sql (17)
- # timbre (1)
- # tools-deps (24)
- # vim (20)
- # xtdb (9)
Trying to use shadow-cljs with deps.edn and make the CLJS REPL work while also being able to navigate to symbol definitions.
Struggled a bit since the default deps.edn + shadow-cljs
project type didn't work - had to search through GitHub issues for Error while connecting cljs REPL: TypeError: Cannot read property 'search' of undefined
to find that there's a way to use shadow-cljs via deps.edn.
But that didn't work because I can't evaluate CLJS files there, even after running (shadow/repl :main)
.
Seems like just shadow-cljs
project type works, although it doesn't like that -d
option, so I added the dependency from it to my deps.edn.
Now I can evaluate the CLJS file. Although using Go To Definition
sometimes works as intended and sometimes just jumps to a seemingly random line in the ns declaration.
With that many problems at every stage of the process - is there a bare bones project that:
• Uses shadow-cljs.edn
with :deps
set to something
• Uses CLJS REPL (ideally alongside with a CLJ one)
• Allows for robust symbol navigation
• Makes it possible to evaluate whole files (not needed if the symbol navigation works just fine without it)
?
> Allows for robust symbol navigation Question, does that works without the REPL? as I suppose Calva will use only clojure-lsp
In one of the issues on GitHub, I have read that if it doesn't work then evaluating the whole file should make it work.
> You don't need to do anything to start clojure-lsp. No install, no commands, no nothing And that's exactly what I did. :) Seems like it didn't help.
What happens when you try to go to definition only using clojure-lsp? Did clojure-lsp start correctly for you (you can check the troubleshooting section)
Just restarted VSCode and noticed that initializing LSP server status in the bar below. Perhaps it didn't work before only because I was trying to navigate to a symbol while it was still running - it takes quite some time with an almost empty project. It doesn't help that the pop-up then says "No definition found for 'x'" instead of something like "Wait for the LSP initialization to complete".
@U2FRKM4TW the very first time show analyze the whole project + external deps (for cljs usually this take a little more because cljs libs has a lot of more libs)
the next time, clojure-lsp uses external analysis cache, only analyzing your project code, which usually is fast for medium/small projects
> "Wait for the LSP initialization to complete" Yeah, probably something to be improved on vscode side, as this request was not sent yet to clojure-lsp as it didn't start yet.
Makes sense! Took around 6 seconds this time. Not sure why the previous took 20+, given that it wasn't the first time either.
probably you changed your deps/shadow file, then clojure-lsp needs to recheck for extra deps
That's still imperfect - jumping to definitions used in CLJC files always defaults to the :clj
path, it seems.
Maybe you know a way to go to a file/namespace that's defined within a jar? At least I would be able to navigate to some of the symbols myself.
also, feel free to open an issue on clojure-lsp https://github.com/clojure-lsp/clojure-lsp/
I'm hesitant to start opening issues just yet since it still might be me missing something that's actually there. :)
I'm trying to get started with quil
. Here's a namespace declaration from one of its files:
(ns ^{:doc "Wrappers and extensions around the core API."}
quil.core
#?(:clj
(:import [processing.core PApplet PImage PGraphics PFont PConstants PShape]
[processing.opengl PShader]
[java.awt.event KeyEvent]))
#?(:clj
(:require quil.sketch
[clojure.set]
[quil.helpers.docs :as docs]
[quil.util :as u]
[quil.applet :as ap])
:cljs
(:require clojure.string
cljsjs.p5
[quil.sketch :as ap :include-macros true]
[quil.util :as u :include-macros true])))
If I go to the definition of quil.sketch
mentioned above in both :clj
and :cljs
branches, I will always be directed to the definition in sketch.clj
, so I cannot see what's going on in sketch.cljs
.
And Go to File...
doesn't list files in jars, so I can't navigate to sketch.cljs
manually.And, of course, there's no Reveal in Side Bar
context menu option for an editor tab for a file from a jar, so I can't just browse a jar as well. Although this has more to do with Java rather than Clojure.
Yeah, I can confirm this is a issue, I think it's related with you only having opened previously the sketch.clj
so clojure-lsp has only that file available
I confirmed it works if you already opened sketch.cljs before, so the bug it's related with clojure-lsp doesn't know there is another file with that definition for other lang
I added quil.sketch
in a .cljs file and tried to go to definition, it was just to confirm my guess
And just plain navigation to files within jars has nothing to do with clojure-lsp, right? I'd think it's a purely Calva feature.
yeah, I don't know anything about that feature, probably a vscode thing, not a Calva feature 😕 Maybe @U9A1RLFNV knows about it
Or maybe I don’t understand what “plain navigation to files within jars” mean. If you have a jar path and navigate to that, then it is VS Code built in behaviour.
@U2FRKM4TW fixed: https://github.com/clojure-lsp/clojure-lsp/issues/509#issuecomment-894385739
Ah, yeah if we aren't talking about go-to-definition, then what I said is not relevant.
I’m sorry for the inconvenience with the shadow-cljs + deps.edn
configuration, @U2FRKM4TW. It has been broken a while. I should fix it or remove it.
Thanks!
Yeah, I was talking about Go to File...
when it comes to jars, sorry for the confusion.
I created an issue for the project config confusion: https://github.com/BetterThanTomorrow/calva/issues/1253
New Calva out, @U2FRKM4TW. It just removes the confusing shadow-cljs + deps.edn
config. And Thomas Heller fixed that confusing warning. And I think the issue you found with CLJC files also is fixed now. Would you say that all issues you raised are fixed now?