calva

Ryzh 2026-05-09T07:00:52.661139Z

Hello! I'm new to Clojure. I use Calva & VSCode. I use clj-reload and find myself regularly carrying the code

(comment
  (reload!))
with me across all files and evaluating it. Is there a way to create a shortcut that will send (reload!) into the REPL?

Ryzh 2026-05-09T12:16:23.699189Z

Yep, it's done like that

[
  {
    "key": "alt+shift+r",
    "command": "calva.runCustomREPLCommand",
    "args": "(reload!)"
  }
]

❗ 1
🤘 2
seancorfield 2026-05-09T19:26:22.425119Z

This project isn't ready for a formal release yet but I wanted to float it here first, since Calva has such a focus on being beginner-friendly: https://github.com/seancorfield/rephrase 0.1.0-SNAPSHOT -- Rephrase exceptions to be more beginner-friendly It can be used as nREPL middleware by adding org.corfield.rephrase.nrepl/wrap-rephrase to the list of middleware when starting a REPL. I don't know if that's something that can easily be configured for Calva. I know you can copy the jack-in command to the clipboard and then run it manually to start a REPL, e.g., :

clojure -Sdeps '{:deps {nrepl/nrepl {:mvn/version,"1.7.0"},cider/cider-nrepl {:mvn/version,"0.59.0"}}}' -M -m nrepl.cmdline --middleware "[cider.nrepl/cider-middleware]"
The change here would be to use:
clojure -Sdeps '{:deps {nrepl/nrepl {:mvn/version,"1.7.0"},cider/cider-nrepl {:mvn/version,"0.59.0"},org.corfield/rephrase {:mvn/version "0.1.0-SNAPSHOT"}}}' -M -m nrepl.cmdline --middleware "[cider.nrepl/cider-middleware,org.corfield.rephrase.nrepl/wrap-rephrase]"
Then connect to it from Calva or Leiningen or... more in 🧵

seancorfield 2026-05-09T19:27:03.442119Z

> lein repl :connect localhost:42671
Connecting to nREPL at localhost:42671
REPL-y 0.5.1, nREPL 1.7.0
Clojure 1.12.5-rc1
OpenJDK 64-Bit Server VM 26-ea+29-2803
Reflection warning, NO_SOURCE_PATH:1:1580 - reference to field ns can't be resolved.
    Docs: (doc function-name-here)
          (find-doc "part-of-name-here")
  Source: (source function-name-here)
 Javadoc: (javadoc java-object-or-class-here)
    Exit: Control+D or (exit) or (quit)
 Results: Stored in vars *1, *2, *3, an exception in *e

user=> (/ 1 :two)
Expected a number, but was given a keyword, at user/eval9452 (REPL:1) - runtime error (unexpected type).

seancorfield 2026-05-09T19:31:05.640819Z

Calva's inline evaluation display only shows the first line of an exception, so rephrase deliberately puts the cause first, then the location, and then the "summary" (which is the whole of line 1 in Clojure by default), so errors can be read more easily inline.

seancorfield 2026-05-09T19:32:50.730499Z

The mappings are all in an EDN file https://github.com/seancorfield/rephrase/blob/main/resources/org/corfield/rephrase/config.edn I plan to add a user-level file that will merge in, so that folks can develop their own additional mappings, with a view to those being added to the core library over time.

seancorfield 2026-05-09T19:34:42.719409Z

It would be great if Calva added a setting to auto-add rephrase to the jack-in command (and a version under the existing nREPL version stuff), so it could be easily enabled for beginners (and experts, if you want!) 🙂 🙂

seancorfield 2026-05-09T19:47:23.423179Z

More examples:

user=> (/)
/ was called with no arguments, but it requires at least one argument, at user/eval18704 (REPL:1) - runtime error (incorrect number of arguments).
user=> (/ 1)
1
user=> (/ 1 0)
Tried to divide by zero, at user/eval18708 (REPL:1) - runtime error (ArithmeticException).
user=> (:k)
The keyword :k was used as a function, with no arguments, but it expects one or two arguments, at user/eval18710 (REPL:1) - runtime error (incorrect number of arguments).
user=> (:k 1 2 3)
The keyword :k was used as a function, with 3 arguments, but it expects one or two arguments, at user/eval18712 (REPL:1) - runtime error (incorrect number of arguments).
user=> (1 2 3)
Expected a function, but was given a number, at user/eval18714 (REPL:1) - runtime error (unexpected type).
user=> (/ 1 :zero)
Expected a number, but was given a keyword, at user/eval18716 (REPL:1) - runtime error (unexpected type).

seancorfield 2026-05-09T19:50:15.290909Z

Follow-up here or in #rephrase

pez 2026-05-09T20:01:49.428709Z

Yes, would be nice with a setting to enable this. Meanwhile, I think it should work adding it via a connect sequence with extraNReplMiddleware

seancorfield 2026-05-09T20:05:31.156209Z

That would need the group/artifact, the version, and the function to add to the middleware list, right?

pez 2026-05-09T20:09:50.678399Z

I don’t remember right now what’s involved….

seancorfield 2026-05-09T20:12:45.655159Z

Ah, extraNReplMiddleware is an array of strings to add middleware, but not for the dependency itself...

seancorfield 2026-05-09T20:16:00.222539Z

There would need to be another option added for the group/artifact and version, for additional dependencies for jack-in.

pez 2026-05-09T20:20:31.568819Z

Yeah, but to experiment with it you’d add that in deps.edn and use the custom connect sequence to get the middleware into place. For the feature as such, I think it should just be a toggle in settings and Calva would inject both the dependencies and the middleware.

seancorfield 2026-05-09T20:37:54.911679Z

Well, for experimenting right now, I still start my REPL with a repl script that uses the :dev/repl alias from my dot-clojure repo, which adaptively starts a REPL based on what is on the classpath 🙂

JR 2026-05-09T20:49:33.622349Z

The doc for stacktraces in the output window says

You can also print the stack trace for any error message printed to the REPL Window via the Codelens button below it.
but I don't see a Codelens for the stacktrace in the output window anymore (see attached). Print Last Stacktrace works fine. Is this something that should be updated in the docs, or am I somehow missing the button? https://calva.io/repl-window/#stack-traces

pez 2026-05-09T20:51:50.409669Z

The code lens should be in the REPL Window. Your screenshot shows the Output terminal. Is that the confusion?

JR 2026-05-09T20:55:00.794039Z

This could very well be my misunderstanding. I also don't see it n (what I think is) the REPL window. Or should I be looking for another REPL window? Here's a screenshot of what I see

JR 2026-05-09T20:57:57.651649Z

(That editor comes from Calva: Show/Open REPL Window)

JR 2026-05-09T21:00:51.429129Z

Ha! I just realized that I accidentally put the period in the wrong place and was generating a different exception (IllegalArgumentException)... But it's still missing even when "fixing" that

pez 2026-05-09T21:01:02.438489Z

That looks like the REPL Window. Could be that the codelens feature is broken.

JR 2026-05-09T21:03:48.639949Z

I'm not sure if it's just me (I have a dev version of clojure-lsp, maybe that's causing a problem)

pez 2026-05-09T21:06:45.870679Z

clojure-lsp is not involved in this, so shouldn’t matter. It’s probably broken in general. We should remove the feature, I think….

pez 2026-05-09T21:07:34.058479Z

It’s a cute feature, but not really super necessary.

JR 2026-05-09T21:08:17.676759Z

I was going to suggest that too... but... I had to google how to show exception stack traces when I couldn't find the button. It's easy enough to google though

pez 2026-05-09T21:24:33.747859Z

We could surface the command in the REPL menu, maybe. So if there’s a stack trace the REPL statusbar item could show some indication and the menu could have that option.

pez 2026-05-09T21:25:25.856609Z

That would make it more generally available and not hidden in a REPL Window codelens.

👍 1
pez 2026-05-09T20:53:46.571999Z

Dear Calva friends: calva https://github.com/BetterThanTomorrow/calva/releases/tag/v2.0.586 • Fix: https://github.com/BetterThanTomorrow/calva/pull/2936, thanks @djblue! ❤️ 🙏https://github.com/BetterThanTomorrow/calva/issues/3103, preparing Calva for the nrepl-server-adding update of #glojure and #gloat

🎉 3
djblue 2026-05-10T02:12:25.746939Z

Thanks for the quick response and release @pez!