Fork me on GitHub
#calva
<
2021-08-19
>
flowthing08:08:52

Trying to help a coworker with Calva. View » Go to Symbol in Editor yields "The active text editor does not provide symbol information", and View » Go to Symbol in Workspace yields "no matching workspace symbols". Is there any way to make them work with Clojure?

eins7808:08:19

I tried with clojure and clojurescript and it should work. I am also using the “rename symbol” feature regularly which i guess uses the same data. Look in the “Output” tab if there any errors logged by Calva (or clujre-lsp)

pez08:08:49

Those should work. It is provided by #lsp . There is a setting calva.trace.server that can enable verbose logging from clojure-lsp. Maybe you can see something there what is going wrong?

flowthing08:08:33

Oh, I didn't realize it's LSP-powered. I thought it was powered by syntax definitions. That explains it -- the LSP integration doesn't work on my coworker's machine.

flowthing08:08:19

Anyway, that's good to know. Thanks!

pez08:08:40

Do you know why the integration does not work?

flowthing08:08:31

Afraid not. It's this issue, I think: https://github.com/BetterThanTomorrow/calva/issues/1050#issuecomment-890701486 But the recent fix to clojure-lsp doesn't seem to have fixed it.

flowthing08:08:33

My best guess is that some corporate anti-virus or monitoring software is interfering with clj-kondo, but not sure.

pez08:08:02

Wow, that’s some thread! It looks from that conversation that that particular issue should be fixed, though. Maybe I read it too quickly.

flowthing08:08:35

Yes, but there seems to be another issue that causes the same error message.

flowthing08:08:36

I believe I've narrowed it down to this bit in clj-kondo: https://github.com/clj-kondo/clj-kondo/blob/b6f76ea8371d2497ed14314cf99a679e41f5db4f/src/clj_kondo/impl/core.clj#L337-L339 But I don't yet know which file it is unsuccessfully trying to access.

flowthing08:08:54

Anyway, we'll try to figure it out. 🙂

👍 3
bringe20:08:38

Please add your findings to the issue when/if you narrow it down more or find a solution. Thanks!

flowthing05:08:17

Yeah, we figured it out in the end. I'll add a comment in the issue about it.

👍 3
jmayaalv08:08:38

Hi, there we are facing a weird problem when running a single test in windows. If we ran a single test

; Evaluating file: reports_test.clj
#'edge.test.reports-test/sb-switches-report-test
; Running test: _…
; No tests found. 
, ns: 0, vars: 0
but if we ran all the tests in the namespace the tests run. this is happening with all the tests

jmayaalv08:08:38

is this a known issue or something? it’s similar to what was reported https://github.com/BetterThanTomorrow/calva/issues/1086 here, but in our case is happening even if we refer deftest

pez09:08:26

I don’t know how known it is, but I have certainly experienced that tests that I expect to run instead gives me that message. You can help it being more known by filing an issue. 😃 It might be that it is some known issue on cider-nrepl as well. Maybe @U051BLM8F have seen it?

bozhidar11:08:22

Nope, I haven't.

bozhidar11:08:39

Tests are detected by the test metadata added to the vars, nothing else.

jmayaalv07:08:56

Thank you, will add the issue. thanks a lot

Hukka12:08:35

When I try to evaluate a cljs file (with the repl running the shadowcljs repl already) I just get a popup with something like "calva.loadFile failed"

Hukka13:08:08

Unfortunately google doesn't really give anything for that error, nor much more for using calva with cljs

Hukka13:08:55

Also trying to send the current form doesn't do anything, not even the popup

Hukka13:08:34

Hm, looking at the bottom bar, the file seems to show "clj" while if I am in the repl window, it shows "cljc/cljs"

Hukka13:08:45

No idea what to do about that, though, and how does it decide it

Hukka13:08:14

It shows the repl as cljc/cljs no matter am I actually in clj or cljs

pez13:08:50

Can you describe the steps you take to start the repl?

pez13:08:36

If it is a public project, it would help with a link.

Hukka17:08:23

I launch the repl with the jack in, selecting deps and the :serve alias. From there run (shadow/repl :main) in the clj repl

Hukka07:08:49

Ok, I kinda managed to get it working, I think?

Hukka07:08:42

So I had jacked in, and while the repl window worked, I couldn't run anything from the file. But I ran "Connect to a repl ctrl-alt-c c-a-c" and chose the shadow repl this time, and it started working

pez07:08:33

Try jacking in using the shadow-cljs option directly too. Not sure it will work, it depends on the project (which I will check when I have freed up som time).

pez07:08:59

Now checked it quickly. I think it should work with a shadow-cljs jack-in.

pez07:08:17

We should write a guide (or two) about these shadow-cljs scenarious.

Hukka07:08:30

Jacking in as shadow-cljs does not work, I tried that at first. Sorry for not mentioning

Hukka07:08:46

It's trying to run the shadow repl with npx, and the project just isn't set up like that I guess

Hukka07:08:25

So the working process seems to be 1. Jack in to the deps.edn repl 2. Restart the connection setting the type to shadow-cljs

Hukka07:08:50

But I don't really see why calva refuses to send any forms/sexps from the editor to the repl without 2

Hukka07:08:22

Or fails perhaps, not refuses. Nothing just happens for single sexps, and evaluating the whole file gives that error popup

Hukka07:08:14

Oh, and also, I didn't find the documentation for this at first. I was looking for it at "Using calva with X", with X being clojurescript or shadow-cljs. Only now I was reading the "In Depth", though it's not really much help for this problem ;/

Hukka07:08:39

> 1. A Clojure nREPL connection needs to be established. We've covered that above. Calva makes an nREPL session clone to use for the ClojureScript REPL and then: > 2. Your ClojureScript app needs to be compiled. > 3. Your ClojureScript app needs to be started. > 4. The Clojure nREPL session needs to be promoted to a ClojureScript nREPL session. (This is what piggieback helps with.) is what I thought I did when I jacked in to deps.edn repl and ran the (shadow/repl :main)

pez07:08:01

> It’s trying to run the shadow repl with npx, and the project just isn’t set up like that I guess Hmmm…. I must have a look now. 😃

Hukka07:08:08

I guess I have misunderstood the promotion, and I somehow need to tell calva about it?

pez07:08:55

Currently Calva needs to do the promotion in order to know about it.

Hukka07:08:55

Sure, yes… but what is promotion 🙂 ?

pez07:08:07

> I was looking for it at “Using calva with X”, with X being clojurescript or shadow-cljs Yeah, this is lacking. And what I was referring to as “write a guide (or two)“.

Hukka07:08:12

I thought it means I need to run whatever needs to be run in the CLJ repl, to move it to the CLJS mode

pez07:08:09

> to move it to the CLJS mode This is promotion. 😃 Not sure that is a good term for it, but anyway. We say that we promote the CLJ repl session to a CLJS one.

Hukka07:08:12

Ok, so it's the same thing as without calva

Hukka07:08:32

But how do I then let Calva do it, if doing by hand in calva's repl window doesn't help?

Hukka07:08:34

Oh, and when the focus is in the repl window, the bottom bar show s the repl type as cljc/cljs. But when I move the focus to the file, it's clj. But after I do the reconnect, then the file side also shows it as cljs

Hukka07:08:13

So it kinda gives the impression that there is a cljs repl, but it thinks the file is not cljs, and thus refuses to send the forms to the repl? I have no idea really, just speculating

pez07:08:27

You are probably speculating correctly. Part of the complexity here is that this is a bit bug ridden.

pez07:08:34

> But how do I then let Calva do it, if doing by hand in calva’s repl window doesn’t help? It’s done as part of the connect. Which is why your workaround works.

pez07:08:28

We might be able to use a REPL Jack-in/Connect Sequence for this. https://calva.io/connect-sequences/

Hukka07:08:38

So is there some kind of logic, that Calva tries to track are files and repls clj or cljs, and doesn't let them cross?

Hukka07:08:05

I guess so you could run commands from both kinds of files at the same time, without fiddling with the repl manually?

pez07:08:13

For clj files the clj repl session is used. From cljs files the cljs repl. When you have a cljc file you might want to use either, so that indicator is also button that lets you switch which repl is backing the file. And the REPL window is treated as a cljc file.

pez07:08:30

That’s the intention. But there are bugs, And especially so if the jack-in/connect is not happening correctly.

Hukka07:08:34

Ok. The feature makes sense. Just odd that based on the bottom bar, the repl is actually categorized correctly, but the file is not

Hukka07:08:58

But yeah, bugs can manifest in surprising ways (cause if it wasn't surprising, why would it be allowed to happen)

Hukka07:08:42

I would suggest that the documentation re cljs would start by explaining this end goal / feature! I was expecting actually that calva would just send the forms to the repl, and it's my responsibility (though calva might help) to have a proper repl ready for them

Hukka07:08:03

But yeah. I have it working now, I understand what it's trying to do. Changing docs and fixing bugs is then a separate issue. At least for this case there's a handy repo that doesn't work smoothly, when it's time to work on it

Hukka07:08:35

Heh, I'm tempted to check the source a bit 😉

pez07:08:57

Indeed. You are welcome to file an issue about it.

Hukka07:08:41

I will do at least that much!

pez07:08:19

> I was expecting actually that calva would just send the forms to the repl, and it’s my responsibility (though calva might help) to have a proper repl ready for them I think that using a custom connect sequence you can trick Calva into doing this (something like using (println "foo") as connect command and foo as isConnected regex. This might fool Calva that it has a cljs session, which you can then promote manually.

Hukka07:08:18

Hm, I'll consider it, but for now seems like a more difficult workaround than reconntecing

pez07:08:20

I’m not really suggesting to do that, but it tells that this “manual” cljs setting should be reasonably straight-forward to include by default.

pez08:08:30

I can’t reconnect either when I try that. I’ll have a look at this during the weekend.

Hukka08:08:23

Thanks. Redoing everything for the issue, I noticed that things have either changed or I just didn't remember: The repl type in the repl after jack in is cljc/clj and in the file clj, but it still won't evaluate

Hukka08:08:08

https://github.com/BetterThanTomorrow/calva/issues/1270 in case you use this slack thread to find all the info

Pratik14:08:12

Hello, I am using https://github.com/venantius/ultra for showing diffs in the tests, cider already has a support for it. Can it be integrated with VSCode? found relevant issue here - https://github.com/BetterThanTomorrow/calva/issues/1007.

pez14:08:23

It should be possible. A PR would be welcome!

Pratik14:08:35

Alright, I will look into it

Pratik14:08:55

My bad, I think cider doesn’t support it, rather it has some https://github.com/venantius/ultra/issues/79 with cider

pez16:08:41

Haha, well, if so I take my comment back. 😃

seancorfield16:08:11

That's a common problem with plugin-style things that modify how clojure.test reports failures -- they don't work together. I think both Leiningen and CIDER already mess with clojure.test -- I know Paul Stadig's Humane Test Output has problems when run in those contexts (I use HTO because I do not use CIDER or Leiningen!).

seancorfield16:08:29

I've seen quite a few reports of Ultra causing other problems by interacting badly with tooling. It's very... opinionated... For a while it was popular enough and causing enough problems for beginners that I started warning people to stop using it unless they really understood their toolchain 😐

Pratik17:08:09

right, I really miss the test diff functionality in VSCode though, I have to mostly use ultra for getting exact diff while comparing big nested objects

mschmele20:08:18

I just took a look through the calva settings and didn’t see an option: is there a way to run the refresh changed namespaces command automatically when running tests?

pez20:08:35

There isn’t. The file is loaded before running the tests though.

pez20:08:17

Please file an issue about the behaviour you like to have.

mschmele20:08:33

Will do, thanks! Didn’t want to file a redundant issue 🙂

pez20:08:23

Please give this post, and the guide, some of your attention, Calva friends.

3
pez21:08:23

Yes, we should tap into knowledge collected about these things. @U09LZR36F is putting me into contact with a guy who has studied how people learn and about teaching ans stuff and he is eager to leverage this for helping people learn Clojure. I have no idea what could come out of that contact, but am stoked to find out!

pez21:08:07

Also, generally, I think people learn in very different ways. So covering a lot of bases is probably a good idea.

3
danieroux06:08:41

The pedagogy of "Maria" https://www.maria.cloud is an interesting read: "Curriculum · mhuebert/maria Wiki · GitHub" https://github.com/mhuebert/maria/wiki/Curriculum

pez07:08:32

I think easing the install story is super important.