-
Hello, I'm adding a ”pretty print current form or selection” command to Calva. For when it is a selection I run into problems with that zprint-str only returns (and, I assume, formatted) the first form in the parsed string: (zprint-str "a b" {:parse-string? true}) => "a" How do I get all forms parsed and formatted? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
You use
Speaking of formatting a selection, I was working on someones VSCode extension to use zprint, and at least the API that he was using took the whole file and the lines for the selection. Since zprint only really operates on "whole" expressions, that is, "top-level" expressions, zprint has a Regardless of the how you handle the output, one nice feature of using zprint is that if you have your cursor in a function, you can just hit "format selection", and while there isn't really a selection, at least in VSCode the start and end line is the same, but zprint will expand the range to encompass the top-level function and format it. Which is pretty nice. Just point at a function and format. Anyway, I won't go into more detail on any of this unless you are interested. I can point you at the configuration approach if you want. |
Beta Was this translation helpful? Give feedback.
You use
zprint-file-str
, which takes the string of an entire file (or selection). The calling sequence is(zprint-file-str string-to-format identifier options-map)
. This is the doc-string (which says about what I was going to say):