conjure
conjure copied to clipboard
Pretty printing in babashka
Pretty printing in babashka doesn't work, if I try to print something it ends up using pr-str
, so in the log buffer you'll see something like:
{:hello "world", :some "other", :stuff "that's", :pretty "printed"}
Thanks to @borkdude I found that babashka's nrepl server uses clojure.pprint/pprint
for some values of :nrepl.middleware.print/print
.
https://github.com/babashka/babashka.nrepl/blob/c8c8a766e026d5f87e0968a179dad70e13aa13ee/src/babashka/nrepl/impl/server.clj#L25-L28
Once I added "conjure.internal/pprint"
to this list, I still got everything printed in one line. Then I realized babashka also has a custom "right-margin"
key for :nrepl.middleware.print/options
.
https://github.com/babashka/babashka.nrepl/blob/c8c8a766e026d5f87e0968a179dad70e13aa13ee/src/babashka/nrepl/impl/server.clj#L66-L70
For this I ended up modifying conjure like this:
https://github.com/frankitox/conjure/commit/3dad8c013abedadb1bfa2cd4e125ddb39184200d
But it may make more sense to add a default value to babashka, Clojure's code base uses 72
https://github.com/clojure/clojure/blob/master/src/clj/clojure/pprint/pprint_base.clj#L40-L45