You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
At the moment the pretty-printing middleware is activated when initializing a new REPL, no problem, but if you're connecting to an existing nREPL server that wasn't started with lein repl you may be out of luck. It would be nice to figure out a way around this.
The text was updated successfully, but these errors were encountered:
I guess this is because the middleware must be supplied on the nrepl server and lein repl :connect does not start a server. I tested connecting to a server started with lein repl with ultra added and the client I connected seems to pretty print just fine.
I looked at this because I'm manually embedding an nREPL server using clojure.tools.nrepl.server/start-server. You can set a custom handler using the :handler parameter and that the default handler can optionally apply middleware. So I could start my server like this:
So, my question is: is there a way for me to grammatically access ultra's nREPL middleware so that I can add it to my embedded server?
I'm not familiar with leiningen plugins, so don't know if I can just include it as a dependency and pull it out of some var or call some function to generate it.
You're right - I knew this at one point in time and then forgot it and subsequently created this issue 😛
Re: middleware: you can, and you actually don't need to use Ultra to do it (though you can if you like). The middleware that needs to be included server-side is the Whidbey middleware, which is what Ultra uses for pretty-printing values. The relevant blocks of code in Ultra can be found here (https://github.com/venantius/ultra/blob/master/src/ultra/repl/whidbey.clj#L7) and here (https://github.com/venantius/ultra/blob/master/src/ultra/repl.clj#L23) (side note, I hadn't looked at those namespaces in a while but there's a rather ugly circular dependency I'm working around that could easily be circumvented and which I should probably create an issue for).
Anyways, the middleware you want is is in clojure.tools.nrepl.middleware.render-values/render-values, which is a Whidbey ns (it looks like it's from clojure.tools.nrepl, but it's not). Ultra modifies the start-server function to just do a partial in case the user wants to layer additional middleware on top of that.
At the moment the pretty-printing middleware is activated when initializing a new REPL, no problem, but if you're connecting to an existing nREPL server that wasn't started with
lein repl
you may be out of luck. It would be nice to figure out a way around this.The text was updated successfully, but these errors were encountered: