Fork me on GitHub
#calva
<
2022-05-18
>
skapoor08:05:14

Hi, I've recently started using calva and am really liking it! Am connected to a REPL running in docker and 'Goto Definition' etc doesn't work for me because it tries to find the file using the docker container paths. Is there an equivalent to cider-path-translations in Calva?

pez08:05:01

We don't have that. Issue welcome!

skapoor10:05:21

Sure, will file it!

Max00:05:35

Ooo mind posting the link to the issue here? I’d love to +1 it

pez05:05:47

A pretty old one...

pez05:05:52

Wanna have a go at a PR, @U01EB0V3H39 or @U07Q1DKB8? Whatever CIDER does is probably what we should do.

skapoor05:05:07

It'll be my first time for VSCode extension but it's something I can investigate. I added a comment about jump to definition using LSP, to the same issue: https://github.com/BetterThanTomorrow/calva/issues/73#issuecomment-1131233587

partyparrot 1
pez06:05:32

Thanks. I also commented some now. Would be super valuable if someone with the actual problem takes it on. I have many, many setups here, but at some point it gets hard for me make sense of them all.

stagmoose09:05:27

I was playing around with fulcro https://github.com/fulcrologic/fulcro-template#the-api-server in the readme, it said clj -A:dev -J-Dtrace -J-Dguardrails.enabled=true to start a backend server. I can start repl using calva jack-in, but how can I add additional parameters like -J-Dtrace -J-Dguardrails.enabled=true

pez10:05:54

Hi! Calva does not have configuration for setting Java options directly. You can provide these via :jvm-opts on an alias in deps.edn, or via the environment variable JAVA_TOOL_OPTIONS. Something like this would be an equivalent command line invokation (assuming something Unix-like):

JAVA_TOOL_OPTIONS='-Dtrace -Dguardrails.enabled=true' clj -A:dev
You then can use the command Calva: Copy Jack-in Command Line to Clipboard, to get the REPL started in a Calva compliant way, then use Calva: Connect to a Running REPL in your Project, to connect to it. However, you can also still use Jack-in. Calva has a settings calva.jackInEnv, where you can provide this environment variable, and Jack-in should work. Yet another option, that is Jack-in compatible, is to add this in your deps.edn. Something like:
:aliases {:dev {:jvm-opts ["-Dtrace" "-Dguardrails.enabled=true"]}}
You could then specify the :dev alias at Calva Jack-in. I think I would go with the last one, as it makes the project config portable and easy for others to use.

❤️ 1
stagmoose11:05:37

Okay, I will try these later! Thanks for your help as always~

🙏 1
pez11:05:16

You are most welcome, @U020WAVDMMK! If you have some little time, I have a favor to ask: We are trying to populate https://ask.clojure.org with content about Calva. So that it will be easier to google for it. This question you ask is pretty common, and would make excellent content. Would you consider asking this question there? Then I can write my answer there as well.

stagmoose11:05:41

@U0ETXRFEW Sure. No Doubt. I'll do this in a minute and post the link here.

❤️ 1
Yehonathan Sharvit13:05:38

Is there a way to clear the REPL window (not the REPL history)?

pez13:05:33

There is no special command for it. I do Select all, then delete.

pez13:05:44

Might be possible to create a command for it using #joyride. Not sure about this, though.

pez13:05:39

Also: There are commands for showing the output window, and for showing the file for whatever current namespace the output window has. Those two commands are bound to the same keyboard shortcut: ctrl+alt+o o, and will ”do the right thing” depending on context.

pez13:05:17

If the output window is not in the namespace of the current file, you can make it so with the command Switch namespace of output window to current file (or something like that). Default keybinding ctrl+alt+c n

Yehonathan Sharvit13:05:19

I was already aware of ctrl+alt+o o

pez13:05:45

I tried to automate it with #joyride, using all these commands, but Calva is not fully prepared for it yet. It doesn't block on some key promises as it should.

pez13:05:49

Noting the non-working Joyride function down here, so that I can return to it later when I have fixed Calva:

(defn clear-output-window []
  (p/do (vscode/commands.executeCommand "calva.showOutputWindow")
        (vscode/commands.executeCommand "editor.action.selectAll")
        (vscode/commands.executeCommand "deleteLeft")
        (vscode/commands.executeCommand "calva.showFileForOutputWindowNS")))

zakkor13:05:48

Hey guys! First of all, thanks to all the contributors for this awesome extension. For the longest time, it was my impression that lisp programming can only be done properly in Emacs - well, not anymore! Now a question: I have some commands that take a long time to complete, but when I eval and send them to the REPL, there is no feedback, so it's hard to figure out what's happening sometimes. Also if I eval a command that runs forever, same kind of trouble. I stumbled upon this issue on Github and posted a suggestion there: https://github.com/BetterThanTomorrow/calva/issues/1543#issuecomment-1130045200 But is there anything else I could do in the meantime to get better eval feedback?

pez14:05:09

Thanks. That change with when we print the code to the output window should be fairly quick to implement. If you wanna PR it, that would be great.

pez14:05:34

In the meantime... You can experiment with some different themes. Calva does highlight the code being evaluated. Only all too subtle. Maybe some themes will make it more or less visible than others.

zakkor14:05:14

Would love to open a PR, will do that now.

🙏 1
zakkor14:05:20

For the highlighting, is it the same as the regular selected text highlighting? Like when you select text with the mouse

pez14:05:35

Not the same. But quite similar. It is more ”the same” as the highlighting when the code has been evaluated.

👍 1
pez14:05:55

Awesome. Thanks! Review in. 😃

zakkor14:05:20

Cool, will add the changelog entry in a sec

zakkor14:05:08

Added now - hopefully I did that right 😄

pez15:05:18

Merged! 🎉

brazil-parrot 1
🎉 1
pinkfrog14:05:21

Anyone has jump to java source working? I saw it successful once, and I want to see it one more time. 😉

pez14:05:27

I haven't gotten it to work for a long while. This needs to be fixed soon.

pez15:05:45

Dear Calva friends: @edward.partenie helped himself and all us other Calva users get a bit better feedback about when long running evaluations has really started. A new Calva version with this change is now out: https://github.com/BetterThanTomorrow/calva/releases/tag/v2.0.275 • Addressing: https://github.com/BetterThanTomorrow/calva/issues/1725 Thanks, @edward.partenie! 🙏 calva ❤️

zakkor15:05:24

Thanks for the quick release! Also, whoops, I messed up the ID number of the referenced issue 😞

pez15:05:36

Haha, yeah, Sloppy review as well! What is it Rich Hickey says is common for all bugs in production now again? 😃

pez15:05:51

Now fixed. Don't know if Slack caches it though: https://github.com/BetterThanTomorrow/calva/releases/tag/v2.0.275

🙏 1
sashton16:05:29

How does calva locate the java installation, and is it configurable? I didn’t find anything in the settings/docs. I’m trying to use a specific version of java.

pez16:05:09

For Calva Jack-in this is the Java that you reach from the environment that VS Code runs in. I use sdk-man to set a new default Java before Jack-in, if I need something special. Or I use the command Copy Jack-in command line to clipboard and run it from the terminal where I have set whatever Java as the current one. Then connect Calva to the REPL started.

sashton16:05:21

Any tips on how I can figure out what VS Code is seeing for paths? When I open a VS Code Terminal and run java -version` , I see the same version as I do from an external terminal. But when I Jack-In, the java process reports a much newer java version. Also, I started VS Code in my project directory from the same terminal which shows the correct java version: code .

sashton16:05:11

so I would have thought the VS Code process would find the same java version as I see from the command line

sashton17:05:21

nevermind, user error. :face_palm:

alias code='JAVA_HOME=$JAVA_16_HOME code'

😂 1
pez18:05:00

It is still strange that you see different Java versions from an internal terminal and from Jack-in when VS Code is started from a terminal...

sashton19:05:38

From what I can tell, it looks like the internal terminal runs my bash_profile, which does set JAVA_HOME to an older version.

pez19:05:18

But if you start code form a terminal where you have that profile, I thought that would be the environment that Jack-in has. (Jack-in is spawning a nodejs child_process, if that tells you anything.)

sashton19:05:00

except the alias above is in bash_profile. so only for code is java set differently

pez19:05:12

Maybe now is when I should also mention that there is a setting calva.jackInEnv, where you can set JAVA_HOME. That should let you control the java version as well.

👍 1
sashton19:05:25

i think i did that because lsp requires some minimum java version

pez20:05:37

Then the jackInEnv setting might come in extra handy. One JAVA_HOME for clojure-lsp, the other for the REPL.

sashton20:05:40

how do I specify them separately?

sashton15:05:05

oh, did you mean: • specify Java 16 in my alias as before, which will apply to lsp • but then to specify older Java version in jackInEnv for my repl

pez15:05:11

Yes. I think that should work. Maybe name the alias something else, in case you forget again what's happening. 😃

sashton15:05:27

haha, yeah good call

seancorfield21:05:15

The latest Joyride posts remind me to ask: has there been any progress on exposing an API from Calva that can be manipulated from Joyride, e.g., allowing for Joyride scripts to send code to the current editor's connected REPL for evaluation and getting the result back (as a string or better as Clojure data)?

pez21:05:44

Not much progress there yet. But we should be able to create that particular API pretty quickly. Not sure about Clojure data, but it would be in the same form as Calva itself gets it. That's a string, I guess, not sure if we have clojure.edn/read-string in Joyride, do we, @U04V15CAJ?

borkdude21:05:59

but not all evaluation results are valid edn of course

pez21:05:09

A brief intro to Joyride, dear Calva friends: https://clojureverse.org/t/say-hello-to-joyride-the-clojure-repl-in-vs-code/8957 Come'on join the #joyride! joyride