Fork me on GitHub
#calva
<
2021-10-04
>
grumplet09:10:11

I’m running a Calva deps clj project in one VSCode workspace, and a Calva shadow-cljs project in another. They have nicely separate clj and cljs repls up and running except that they appear to share a common output.calva-repl. I get prompts like this on every cljs repl command. Is there any way to avoid this?

pez09:10:07

Please file an issue about this. We probably need to make the file path configurable…

pez09:10:37

It should be possible to use the same workspace, but people have had problems setting that up as well. But could be worth a try?

grumplet11:10:00

OK, will do. I did try a single workspace, but that made me share and switch a repl and organising the deps was really delicate. I could only get it working by connecting to a terminal started clj-repl and then using the shadow cli commands to switch to a cljs-repl. And it’s unpleasant having to switch repls.

pez11:10:40

Calva should use the CLJ repl in Clojure files and the CLJS one in ClojureScript files automatically. You mean that that was not happening?

grumplet12:10:41

It was getting very confused with dependencies when I tried that - I was using deps+shadow. The clj repl couldn’t find dependencies that were definitely in the deps, but when I ran in pure deps mode it could. So that started me on a search for alternatives.

pez12:10:58

Yeah, you’re in the but people have had problems setting that up cohort… I hope we will figure out the receipts for getting that to work.

grumplet12:10:55

Just tried that again and hit this on a shadow+deps jack-in while looking at app.cljs. This is what I saw:

clj꞉user꞉> 
; Creating cljs repl session...
; Connecting cljs repl: deps.edn + shadow-cljs...
;   The Calva Connection Log might have more connection progress information.
; Execution error (FileNotFoundException) at user/eval5213 (REPL:1).
Could not locate shadow/cljs/devtools/api__init.class, shadow/cljs/devtools/api.clj or shadow/cljs/devtools/api.cljc on classpath.
; Error while connecting cljs REPL: TypeError: Cannot read property 'search' of undefined
; Jack-in done.

pez12:10:29

You’ll need to have shadow-cljs as a dependency in the dev alias you are using, I think.

pez12:10:34

Or edit the jack-in CLI command used and add the dependency there. Then use that command to start the REPL and the Connect command from Calva.

grumplet12:10:24

Yeah I forgot to patch shadow back in to the deps on the retry. But I then get this issue, which is again caused by:

grumplet12:10:31

To quit, type: :cljs/quit Socket closed Socket closed Socket closed Socket closed Execution error (FileNotFoundException) at user/eval5213 (REPL:1). Could not locate shadow/cljs/devtools/api__init.class, shadow/cljs/devtools/api.clj or shadow/cljs/devtools/api.cljc on classpath. Socket closed

grumplet12:10:01

(That was the output channel)

grumplet12:10:49

I think i’m going to stick with separate cljs and clj for now. It feels simpler.

pez12:10:55

Yeah, I probably would too…

grumplet09:10:11

The two projects share a repo folder.

VK11:10:25

hi) would you please help me: I've installed VSCode with Calva on Windows 10. Is there a way to use a build-in leiningen from outside of VSCode? (from cmd or powershell, for example) Thanks!

pez11:10:25

Not sure I understand. If you mean if you can start the REPL from a terminal and connect Calva to it, then yes. See: https://calva.io/connect/#connecting-wo-jack-in

Hukka11:10:52

A misconception of having support built in, not the tool?

Hukka11:10:22

Hmh, perhaps I should have put those in the reverse order

VK11:10:39

I want to run commands like "lein new ...", "lein run", "lein test" from Windows cmd or powershell and I prefer to use leiningen which is already build-in Calva. I don't want to have separate installation for leiningen.

Hukka11:10:48

Anyway, calva doesn't ship leiningen code in it, I think (never having used lein with calva, just deps.edn)

👍 1
pez11:10:13

Calva doesn’t bundle anything lein. You have to use your local install. To connect Calva to the project’s REPL, you have to start it in a way that satisfies Calva’s dependency requirements. See the documentation for how to get Calva’s help with that.

👍 1
VK12:10:42

Thank a lot for clarification!

Michael Mackenzie14:10:10

Hey guys, I've recently started using Clojure professionally at work. In the past, I'd worked on hobby projects in Clojure and used intellij/cursive but at work I'd been using VS code for everything so decided to try out Calva to see where Clojure support was at. I'm working on a backend project, and one thing that's been extremely difficult to work with is being unable to see any java sources for the libraries I'm using in the project (i.e. being able to click on symbols and view their definitions, docstrings etc) Is there any way to get this working in Calva/VSCode?

pez14:10:34

Hi there! The support for Java can’t really compare with that of Cursive, but peeking at and navigating to code, as well as some completions works if you have the sources installed on your classpath. See this issue for some clues: https://github.com/BetterThanTomorrow/calva/issues/1304

Michael Mackenzie14:10:11

Thanks a lot, I'll take a look

borkdude14:10:43

There is also some work going on in clj-kondo about this, but currently only in the "what direction should we take phase"

borkdude14:10:53

(clj-kondo supports the navigation features in lsp)

borkdude14:10:43

e.g. bytecode inspection is one of the things that is being considered

borkdude14:10:06

I think it should be possible to extract at least method names, but where should you then direct the user when clicking on the method?

pez14:10:24

In cider-nrepl there is some attempt to look up sources online for Java things. I don’t know when it is supposed to be used, but maybe it is a feasible backup solution if the sources are not on the classpath?

Michael Mackenzie15:10:53

in intellij, it sends you to the decompiled .class file and if available gives you the option to download the sources

Chris S18:10:58

Hi all. I need your help setting up my VS Code on Mac to work with Clojure. I followed the instructions at https://practical.li/clojure/clojure-editors/editor-install-guides/vscode-calva.html and https://practical.li/clojure/clojure-editors/editor-install-guides/vspacecode-calva.html, but it doesn’t work. For example, I’m in the newest version of VS Code for Mac; I create a new file by going to File --> New File; I click in the editing pane for Untitled-1; I press Shift-CTRL-P and nothing happens. What am I doing wrong? Here are the extensions I have installed and enabled:

pez18:10:10

It's command+shift+p on Mac.

Chris S19:10:18

THX! (Where should I have looked to find that out without having to ask on #calva?)

Bob B20:10:34

the command palette specifically (which is that window where you can search for commands) can also be accessed from the "View" menu (and I think that'll show the shortcut as well). Fortunately, once you've got that shortcut down, you can use it to find pretty much any command, and at least on Windows, the command palette will also show you what the keyboard shortcut for that command is

pez21:10:21

What @U013JFLRFS8 says. We try to introduce this here a bit: https://calva.io/finding-commands/

pez21:10:30

It is interesting that you have to dig around quite a bit in the VS Code user docs to find out about the Command Palette … https://code.visualstudio.com/docs

pez21:10:45

> (Where should I have looked to find that out without having to ask on #calva?) I’m happy you asked here!

Chris S18:10:04

Thanks in advance!!