BetterThanTomorrow / calva

Clojure & ClojureScript Interactive Programming for VS Code
https://marketplace.visualstudio.com/items?itemName=betterthantomorrow.calva
Other
1.68k stars 217 forks source link

Using Calva to work with Fennel? #2664

Open noncom opened 2 days ago

noncom commented 2 days ago

I'm currently trying to see if I can make the Fennel nREPL server JeeJah work with Calva Connect to REPL.

But:

So there are some problems in communication right from the start, the server gets confused by the handshake requests from Calva.

What I think is that if the connection is made, and all such specifics is emulated on the Fennel/nREPL-server side, further work should go pretty well. The source code format of Fennel is very similar to Clojure, so there would likely be not much problem further on?

So my hope is to emulate on the Fennel side what Calva expects, and make them work together.

PEZ commented 2 days ago

Hello! Super fun that you are experimenting with this. Less fun that it doesn't work, but let's make it work!

I'm thinking one source of problems could be the code in the calva.autoEvaluateCode.onConnect setting. It defaults to:

(when-let [requires (resolve 'clojure.main/repl-requires)] (clojure.core/apply clojure.core/require @requires))

Which maybe trips Fennel up?

I don't think Calva fiddles with *ns* directly, but I could remember that wrong.

Your strategy is sound, I think. However, maybe we could start in the Calva end of things and see how much Fennel support we can reach that way? Calva has a few adaptions like that for some different runtimes. Though, these are more Clojure runtimes, than Clojure-like runtimes, so who knows.

There is not much in the way of documentation on the protocol from the Calva side. The nREPL project is where this is described. The ultimate sources of truth will be Fennel's nREPL server and Calva's nREPL client.

There is a command in Calva for enabling logging of the messages that Calva sends and receives. Search the command palette for Calva Diagnostics and you should find it. If Fennel's nREPL server has any similar logging, that would be powerful in combo.

Please let me know if there is anything I can answer or help with. I can make myself available for a screen-sharing session, if you think that would speed things up.