Fork me on GitHub

@cfleming do you use your own code format implementation or something open source? all I really need is a function to make maps like this:

{:a 1
 :aa 2}
into this:
{:a  1
 :aa 2}
clojure's pprint does not really do this : (


Also, cljstyle, which is a fork of cljfmt but compiled to GraalVM


I did, but it did not seem to work within time I spent playing with it. and all the docs are conveniently contain let forms with single char binding names, like

(let [x 1]
      y 2])


If you just need a function you can use this:


thank you. but the use case is arbitrary data structures (e.g. maps with vectors of maps, etc), which has to be pretty-printed, so simplistic implementation will not cut it, (where e.g. cursive's "format selection" seems to be a fit). And 2 pages of custom code not worth it in this case.


Yeah for arbitrary data structures that's a no-go, I thought you just wanted a simple data dump.


@misha Well, it’s open source, but probably not what you mean - it’s the IntelliJ code formatter, with extensions for Clojure code from Cursive. As you’ve found, some apparently-simple cases are decidedly non-trivial. I can make your case even more non-trivial by doing this:

{{:a  1
  :aa 2} 3
 :b      4}


For these reasons, IntelliJ’s code formatter uses a constraint algorithm with multiple passes until a solution converges, which is required for this sort of case. Cursive actually never breaks lines, which means that a simpler algorithm might suffice, but I might start breaking lines at some point, and then a naive algorithm gets extremely hard:


There's no way to use Cursive's test diffing when running CLJS tests, right?


No, sadly - that requires Cursive to understand CLJS REPLs better, which I’m struggling to get around to.


Well, in this case I don't really need to know anything CLJS specific. A cljc function returns a large structure that is just regular data. It's hard to eyeball what is different. Since it's regular data, it seems like Cursive's diff UI would "just work"


I guess I could go make a temporary .clj test file, paste the failing test, and then run the test haha


It’s not the diff that wouldn’t work, it’s the getting the data back from the test framework via the CLJS REPL. I actually also have plans to allow diffing of arbitrary structures from the REPL (something like (cursive.runtime.repl/diff first-thing second-thing)), but that also requires some jiggery pokery to work.


Oh I see haha. That's a cool idea! I support the jiggery pokery 🙂