Fork me on GitHub

Do you want keyword definition look-up and stuff? Time to upgrade Calva, because v2.0.160 has these changes: •

clojure-lsp 6
🎉 3

Hey everyone, can I get a recommendation for either a Calva doc page or some other reference material? I'm pretty new to Clojure and the REPL in general. So far I've used Calva for faily basic stuff: cd into project, start repl, develop, etc. I've heard, however, that you can jack in to running REPL processes. This could be used to diagnose or do hotfixes to a production app. Another use case for jacking in to a remote REPL is for apps which are hosted in a VM (Docker, Vagrant, etc.). So ... uh, where do I start if I want to do something like that 😅


Check this out: You can embed an nrepl server in your application. Say it's a web server backend/api - you can run an embedded nrepl server, and then when it's running, you can use the host:<port-you-started-embedded-nrepl-server-on> with Calva's connect command to connect to it. Then you are inside your running web backend/api. You can require namespaces from it, redefine an endpoint handler, etc.


@U01HMCQMBKP Something else to consider: any Clojure process can start a Socket REPL at startup just by specifying a JVM option -- which means you do not need any code or dependencies in your process at all -- and then you can connect to that socket server via telnet, nc (netcat), or from your editor if you use a plugin that understands plain socket REPLs (Clover for VS Code, Chlorine for Atom). Calva cannot currently connect to a socket REPL though.


We run socket REPLs in many of our processes, even in production, because all it needs is a JVM option at startup...


(at some point, nREPL should be able to be "side-loaded" over a socket REPL, and then Calva could use that approach to connect to a socket REPL and "upgrade" it)


To give you an example usage, clojure-lsp, which Calva runs to provide some language features, starts an embedded nrepl server: If we want to poke around in the running clojure-lsp program, we can run the Calva command "LSP Server Info", take the :port value from the map returned, which is the nrepl server port, and use Calva's connect command to connect to it. Then we can navigate clojure-lsp's namespaces, check it's state, run functions ourselves to debug things, etc.


Speaking of, this :port is now coming back as nil @UKFSJSM38 😄. It was working a while back, and I see the nrepl code was moved around at some point lately.


yeah, this is on purpose, we only show the port if you compile it with lein with-profile debug bin


this is to reduce image size, (also it doesn't work for graalvm compiled images, which should be the default soon)


Ah ok, thanks!


Great, thank you everybody! I think I've got a better grasp on what I need to do now: 1. embed nrepl into project 2. connect to repl via Calva 3. ??? 4. profit


#3. Run code to change/run project code

(require 'my-project.core)
(in-ns 'my-project.core)

(some-core-fn "test-args")



Something like the above. I'm not guaranteeing that is correct code lol


It's not specific to Calva, really, but we have a Connect to a REPL command. What's important for Calva then is that the host program has an nrepl server running, and even better if it has cider-nrepl middleware loaded.


Dear Calva friends. The Calva team just started AMA:s at both ClojureVerse and Reddit. Please feel invited! • Reddit: • ClojureVerse:

calva 9