Fork me on GitHub

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".


Alright, it seems to be reliable right now. Thanks!


@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


Oh, I see.


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.


hum, I didn't understand the issue, could you elaborate with a repro/sample?


also, feel free to open an issue on 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."}
     (:import [processing.core PApplet PImage PGraphics PFont PConstants PShape]
              [processing.opengl PShader]
              [java.awt.event KeyEvent]))
     (:require quil.sketch
               [ :as docs]
               [quil.util :as u]
               [quil.applet :as ap])

     (:require clojure.string
               [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


it's a bug related with jar definitions indeed


feel free to open an issue, with a repro as minimal/simple as possible


clojure-lsp has indeed somethings to improve related with .cljc files


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


But how did you open sketch.cljs in the first place?


I added quil.sketch in a .cljs file and tried to go to definition, it was just to confirm my guess


Ah, right.


TLDR, it's an issue with definition navigation inside jar files


navigating from/between your source code should cause no issues


Found the bug and how to fix 🙂


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


I thought both clojure-lsp and nrepl helped with that.


I think they both do


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.


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.


Awesome response+fix time @UKFSJSM38 👏

thanks 3
🚀 3
☝️ 3

Honestly, I have forgotten what that configuration is supposed to do.


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:


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?


Awesome, thanks! Seems like they are, yes!


Great! Thanks for reporting. For many things it takes fresh eyes to see the flaws.