calva

Wednesdays you might find @U0ETXRFEW in the Gather Calva space. Invite is https://gather.town/invite?token=GZqrm7CR and the password is `Be kind`.
paulbutcher 2020-11-05T16:12:15.110700Z

Can someone help me diagnose why Calva isn’t able to find definitions in my own code? I have (as far as I know) successfully jacked-in, but Calva claims to be unable to find definitions of any of the functions in the project itself (although it does successfully find definitions in libraries that I’m using. I can’t see any error messages anywhere (but perhaps I’m not looking in the right place?). Thanks in advance!

pez 2020-11-05T17:14:49.111400Z

Have you loaded the file?

paulbutcher 2020-11-05T17:27:07.112700Z

The fact that I’m not sure what you mean by “have you loaded the file” suggests that I’m missing something pretty crucial :rolling_on_the_floor_laughing:. I’ve jacked-in and the file is open in the editor. What else do I need to do?

paulbutcher 2020-11-05T17:57:56.114600Z

Oh! Sorry - I’ve just found it (and yes, it’s almost the first bit of the documentation so I don’t know how I missed it). I think that what was foxing me was that things seemed to work without loading a file. If I create a brand-new project with lein new , open it and jack-in (without loading the file) then I can see definitions. So I was expecting that that would always work.

paulbutcher 2020-11-05T17:58:16.115100Z

Stupid question time - is there any reason why Calva doesn’t load files automatically when they’re opened within the editor?

pez 2020-11-05T18:02:21.116600Z

I've noticed that things sometime work a bit w/o loading the file. I'm not quite sure why, but maybe nrepl needs to load some stuff while it is starting.

pez 2020-11-05T18:09:26.122400Z

As to your totally valid question about why the files are not auto-loaded. It is because the files can contain about anything and evaluating them might start whatever resource hungry processes. We have decided that it must be the user who is in control about when and what to evaluate, and opening a file should not have such effects. I have considered making it an option, but that still wouldn't help new users, because they need to figure it out and find the option. It's quite an Ux dilemma. We should probably inform about the file load in the repl window when jacking in as well. Cover more bases...

pez 2020-11-05T18:10:48.123900Z

Also when we see that someone tries to peek definitions and stuff and it fails we could hint about loading the file...

paulbutcher 2020-11-05T18:10:53.124100Z

OK - that makes sense. How about putting “have you loaded the file (Ctrl-Alt-C, Enter)?” after the “No definition found” error message?

paulbutcher 2020-11-05T18:10:57.124300Z

Snap!

pez 2020-11-05T18:12:31.125700Z

Haha, in my family we say Gammelsmurf (Papa Smurf) in these situations. I don't know why, but when two people think the same thing, it is said. 😃

paulbutcher 2020-11-05T18:14:00.127500Z

Sorry - I’ve just realised something. Does that mean that loading the file is executing the file? So any top-level code is actually run?

paulbutcher 2020-11-05T18:14:25.128400Z

Is there no way to get the definitions (and associated docstrings etc) out of a file without kicking off potentially disastrous side-effects?

pez 2020-11-05T18:15:17.128900Z

That would leave you in the same place with the situation in the screenshot, right?

paulbutcher 2020-11-05T18:16:00.129300Z

Sorry - not sure I understand?

pez 2020-11-05T18:16:47.130200Z

The thing is that in Calva the definition lookup is dynamic. Things need to be evaluated to be seen.

pez 2020-11-05T18:19:18.133100Z

We do want to support static analysis, but it has so far not been something we have found the time to do. If you check this thread you'll fins a dev build of Calva that doesn't need to load files to peek at definitions:

paulbutcher 2020-11-05T18:19:25.133400Z

OK, got it. That’s a wrinkle which really didn’t occur to me. I know that code is executing when I do Ctrl-Enter, and obviously I need to worry about side-effects then. But it never occurred to me that loading a file so that I could automatically cross-reference definitions would do the same.

paulbutcher 2020-11-05T18:20:20.134Z

That looks encouraging!

pez 2020-11-05T18:21:55.135200Z

It needs some serious code design skills to pull it together neatly, I think. I'm hoping we can pick thee brains of @brandon.ringe and @stefan.van.den.oord to form a good plan.

🤞 1
pez 2020-11-05T19:53:38.138200Z

Dear Calva-friends, v2.0.131 is out, containing the QA fixes to parsing and syntax highlighting that I've previously mentioned. Please upgrade. And big thanks to @sogaiu for the help with spotting the glitches, and reporting in such an actionable manner. :calva: ❤️ :calva: ❤️

2
pez 2020-11-05T19:58:11.139300Z

And always keep in mind that a review of Calva is a way to help the project: https://marketplace.visualstudio.com/items?itemName=betterthantomorrow.calva#review-details