Fork me on GitHub
#calva
<
2021-12-14
>
Jack Arrington02:12:24

Is there some way to get stack traces working with Calva and shadow-cljs? I can do something really basic like this:

(defn greeting-for
   [name]
   {:pre [(string? name)]}
   (str "Hello " name))
(greeting-for 123)
But all I get in my output.calva-repl is just #object[Error Error: Assert failed: (string? name)] -- no mention of the name of the function that failed. That's obviously less than helpful, especially beyond a trivial example like this. Is there some way to fix this to show the function name or full stack trace?

bringe05:12:34

I’m not sure, but I wonder what a terminal repl would show in this case. With the shadow-cljs watch process running, you can run shadow-cljs cljs-repl <build-id> and then run (greeting-for 123) there and see what kind of output you get. You may need to run (in-ns '<namespace-of-that-function>) first, or use the fully qualified symbol for it.

Jack Arrington13:12:43

Looks like if I do in at the terminal REPL I get the same thing: #object[Error Error: Assert failed: (string? name)], no additional information.

bringe16:12:15

This might just be the nature of ClojureScript. I’m not sure if a stack trace can be gathered from the repl in that case or not. The #object part is due to JavaScript.

bringe16:12:32

You could try asking for more info in #shadow-cljs or #clojurescript. I’d suggest using the terminal repl as your case, rather than using Calva, so no one thinks it’s something related to Calva.

Jack Arrington16:12:29

Yep, sounds like that's the case. Will try asking in other channels, thanks!

👍 1
bringe04:12:37

Does anyone here ever use Go to Definition with Java symbols? I don’t think I’ve ever had this work from Clojure, but apparently it is possible with nrepl/cider-nrepl/orchard. If anyone knows how to make it work, please post information on this thread: https://github.com/BetterThanTomorrow/calva/issues/1436.

pez09:12:26

I have this working most of the time. Added a comment to the issue.

ericdallo12:12:49

it should not work with clojure-lsp

👍 1
pez12:12:48

It’s a cider-nrepl feature.

Tomas Brejla12:12:24

Recently I started to use code actions accessible via Ctrl+. Namely Add require is a handy thing sometimes. For example it offers me a Add require '[clojure.string :as str] , when I use str/join in my code. This alone works nicely, the require gets added to my ns defition. But I still have to manually jump to the ns defition and re-evaluate that ns form in order to be able to use that require in my REPL session. It's logical that I have to do it, it's just a bit annoying to jump to the top of the file and then back again. Do you use this feature? And if so, do you have any trick in your sleeve to somehow automate this?

pez12:12:13

There is no such feature currently. I think it makes sense to have it.

pez12:12:12

For now I can think of these two: • cmd+up, alt+enter, ctrl+- (on mac, this will go to the start of the file, evaluate the current form, and then go to wherever you were.) • Load the file (is not always an option, I know)

JR15:12:46

I also really like that feature. I use cmd+opt+c enter to reaload the file when I use it (like pez mentioned in the second bullet)

JR15:12:00

I was just reading that I can Command-Click on a stack frame to goto the source. This is great! But the source file shows up in the same editor group as the REPL. The REPL is in a different editor group. It’s usually source on the right and REPL on the left so I get the source file in the left and the right. Is there some way to not open a new source file on command click? release: 2.0.231

pez16:12:49

There isn’t, unfortunately. VS Code lacks the APIs to support it. It’s one of the oldest requests on the API I know of which is this generally important, but never seem to really move: https://github.com/microsoft/vscode/issues/15178

JR16:12:19

Got it. And I’m happy to have the stack traces even with a double open file. Thanks for the reply!

Herman Nurlygayanov15:12:45

Anyone else having issues with Go to Definition? Broke down today, can't figure out a fix. Tried rolling back a few versions, didn't help.

pez16:12:51

I saw, @UKFSJSM38 mention, somewhere, that some fix for something else caused something like this. Not sure if related.

pez16:12:45

So that’s for external deps. Is that what you are experiencing, @UDRFLNJUV?

Herman Nurlygayanov16:12:44

Not quite, in my case even definitions from the same folder are not found.

ericdallo16:12:50

sounds like a wrong project configuration for clojure-lsp, could you print the output of command Calva diagnostics: clojure-lsp server info ?

pez16:12:30

Or, it could be the REPL that is in some funny state. Check if works when not connected.

☝️ 1
Herman Nurlygayanov16:12:50

I didn't change any project settings recently, so it's probably some broken state. How can I reset it?

ericdallo17:12:05

BTW Sounds like you have a really outdated clojure-lsp

Herman Nurlygayanov17:12:35

Yeah, I tried rolling back to fix the issue. Here's output from the last version.

ericdallo17:12:10

is file:///d%3A/projects/dev/zigiwave/ih3-platform your project root uri?

ericdallo17:12:43

is it possible to create a sample repro? I can't see why all go to definitions couldn't work

Herman Nurlygayanov10:12:08

Not sure how to reproduce it. Tried deleting .lsp, using different versions of Calva, the issue persists on Windows. But it does work on Linux, so the problem is not in Calva.

Herman Nurlygayanov12:12:52

I'm out of ideas on how to fix this. Any suggestions?

ericdallo12:12:30

so if the issue is only for windows, we need to check if it's not working for all cases or something specific, could you create a simple repro repo where the issue happens so we can debug it better?

emccue20:12:37

Is there a way to turn off getting click to definition info from the running repl? Like i want to keep getting that from clojure-lsp since i might not have loaded in all the relevant namespaces

☝️ 1
pez20:12:25

Not currently. But i’ve seen it suggested from others. Might even have been in some issue on the repo. If not, please file an issue.