Skip to content

Releases: kkinnear/zprint

zprint-filter-1.3.0

14 May 17:56

Choose a tag to compare

It has been a good long while since the last release, in large part because some of what appear to be small changes required significant rearchitecting of some of the internals. Thank you for your patience!

New and Changed:

  • Several people have requested differing treatment of "trailing right" characters. Those are characters that terminate a collection )]}, which also fall on their own line, either because of :respect-nl or because of a comment. Some have requested that these characters be indented to the indent of the structure involved. Others have requested that (unless required by a comment) they be brought up to the previous line so that they are not "trailing right" characters anymore. Both capabilties are now supported, the first by :indent-trailing-right? and the second by :collapse-trailing-right?, for lists, vectors, maps and sets. See the reference manual for details.
  • New style :docstring-nl which will render any embedded newlines in docstrings in structures as actual newlines, not \n. This is only useful if you are using zprint as a library to format actual runtime Clojure lists whose first element is defn.
  • The ability to locate and process multiple files directly. If you add the {:files {:glob "<filespec>"}} key-value pair to the options map that appears on the command line of one of the pre-built zprint binaries or the uberjar, it will process all of the specified files. An example that will process all of the .clj and .cljc files in the current directory and all subdirectories would be {:files {:glob "**{.clj,.cljc}"}}. Note that the string which is the value of the :glob key is just a string, not a string value of a Clojure data structure. The :files key can not appear on a command line which also includes file specifications for the shell -- you must either specify files with the shell, or with the :files key, but not both! See the reference manual for additional details.
  • Addtional control over lifting namespaces. Prior to this change :map {:lift-ns? ...} was soley boolean. It can now either be boolean or an integer. If it is an integer, the namespace will be lifted only if the number of keys is greater than the value of :lift-ns?. Thus, a value of 1 would be a reasonable value in many situations, as lifting a namespace from a single key looks pretty odd, but lifting namespaces from more than one key usually does not.
  • Documented new style :meta-guide, which appeared several releases ago. Also deprecated style :meta-alt -- use :meta-guide instead.
  • The capability :wrap-multi? is now supported for :list, :vector, and :set. It is false by default, but if true will allow a multi-line collection to be added to a line which already contains elements. If it is false, then every multi-line collection will "flow" and always start on the next line (which is what has always happened prior to this release). See the reference manual for some examples.
  • Formatting for tagged-literals was completely reimplemented. This corrected many problems (not least that they were ignored when they appeared in Clojure data structures formatted by zprint as a library) and brought the implementation and configuration into line with the rest of zprint. Unfortunately, this also caused a change to the interpretation of the :indent for tagged-literals. Previously, the default was :indent 0, which would place the literal one space to the right of the # if it formatted onto the line below the tag. That same placement remains the default, but the configuration to generate that output is now :indent 1, which is an unfortunate but necessary change.

Fixed:

  • Use of a "guide", which powers a few styles, could produce a deletion of code if the guide was generated from the option-fn in :vector. The styles at risk are :hiccup, :keyword-respect-nl, :odr, and :require-pair. If those styles encounter an empty vector, [], code may be deleted. Also, option configurations returned as the answer to an Issue may rarely include guides for :vector.
  • In extremely rare situations with both styles :respect-nl and :ns-justify code could be corrupted because a newline would be missing.
  • Even though :style :respect-nl was in use, newlines at the beginning of maps, binding vectors, and sets would sometimes be ignored.
  • The construct ~ @stuff was being formatted as though it were ~@stuff, which is very different.
  • In the event that {:list {:indent n}} was configured with n = size-of-the-first-element-of-a-list + 1, a newline was added after the first element of the list.
  • When using :style :sort-require if the :require wasn't the first element in the collection, zprint would loop forever.
  • Some incorrect indentation in vectors and lists when wrapping collections containing collections were fixed.
  • :no-wrap-after has been around for a while. This lets you specify an element where you would prefer the next element be on the same line. It has been completely re-implemented and now works well in many more situations. When specified, it also implies :wrap-multi? true for the next element. Note that the element you specify for :no-wrap-after should be short and not a collection.
  • Style :sort-require will fail and throw an exception in cases where there is an empty :refer [] clause.
  • When using :require-justify or any related styles that justify things in ns macros, elements in the :require that were not just vectors or lists could affect the justification while not actually participating in the justification after all.
  • When using clj to create a REPL, and testing with(set! *warn-on-reflection* true), some addtional issues appeared which were not flagged when using lein repl to create the REPL. These have been fixed.

zprint-filter-1.2.9

12 Mar 20:35

Choose a tag to compare

A good number of significant changes for this release. In many cases, a more complete explanation appears in the CHANGELOG.

  • If you would like to have the namespaces sorted in a (:require ...) in an ns macro, you can use the style :sort-require. You can also select (using regular expressions) namespaces to put first (or last, or both). Search for :sort-require in the reference manual for details. This will also, by default, sort the identifiers in the :refer vector, though you can disable that sorting.

  • If you configure :comment {:min-space-after-semi 1} then a comment like this: ;this is a comment will be changed after formatting into a comment like this: ; this is a comment. The default for :min-space-after-semi is 0, so by default no changes are made. Issue #306.

  • New option map to transform random Java classes into other, more manageable data types: :modify-sexpr-by-type. Issue #307.

  • The style :ns-justify was difficult to change in situations where it wouldn't justify something because the maximum variance was exceeded. It has been restructured using the new style-map approach to allow it to be easily parameterized. If you invoke :ns-justify by using its keyword name, the maximum variance for justification will be 20 for :require and :require-macros and will be 1000 for :import. You can change any or all of these by using a map to invoke the :ns-justify style. See the CHANGELOG for details.

  • zprint will now recognize when a set of pairs is being spliced in using reader-conditionals, and format them as a set of pairs. See the CHANGELOG for more details.

  • Extended the meaning of :one-line-ok? for {:style :rod-config} so that if a particular arity would format successfully onto one line, it will now do so if :one-line-ok? is true. Issue #282.

  • There was a bug where if you specified multiple styles in a vector, if there were any errors detected when applying the styles, the errors were lost unless they occurred in the rightmost (that is, final) style. If you have any configurations that suddenly start showing errors after updating to 1.2.9, see the CHANGELOG for details.

  • The style :minimal-smart-wrap added in 1.2.5 had a problem where it wouldn't properly deal with single lines ending in a period. It also didn't recognize lines ending in a period if it wasn't preceded by two lower-case characters. Both of these problems are now fixed. Issue #297.

zprint-filter-1.2.8

14 Sep 17:20

Choose a tag to compare

Major changes:

  • New pre-compiled binary for macOS running on Apple Silicon. Install zprintma-1.2.8 from this release to get it. Runs up to 3x the speed of the Intel binary on Apple Silicon! Discussion #302.
  • Now babashka compatible! You can run zprint as a babashka task, install it with bbin, and use the library inside of babashka. See the QuickStart for a link for how to do all of this.
  • See the CHANGELOG.md for additional details.

zprint-filter-1.2.7

07 Jun 19:31

Choose a tag to compare

Made some small fixes to "smart wrap", and fixed an unfortunate bug in wrapping "top level" comments. It is supposed to wrap the top level comments only when they exceed the :width, but it wrapped them instead when they were was 5 characters short of the :width. The new "smart wrap" has a 5 character border which is used for wrapping internal comments, but that border ended up also being used for top level comments. I would recommend using 1.2.7 over 1.2.6, though the number of comments unnecessarily wrapped with 1.2.6 depends entirely on how wide your top level comments are.

zprint-filter-1.2.6

27 May 16:57

Choose a tag to compare

A significant release, fixing several reported problems and adding some requested features. The biggest change is the change to comment wrapping -- the creation of "smart" comment wrapping. This is now the default (as comment wrapping has always been the default). It will fix most of the problems created by the previous "not very smart" comment wrapping, while creating fewer problems in the future with respect to comment wrapping. See the CHANGELOG for specific details.

Other changes:

  • You can now specify some keys to come last in a map as well as some keys to appear first in a sorted map. See the CHANGELOG for details.
  • Added function type :list, for when you want a list interpreted as just a list of data, without assuming that the first element of the list is a function of some type.
  • You can pass a string value of an options map to set-options!, and it will read and 'compile' that options map (including any functions) using the Small Clojure Interpreter (sci) built into zprint, the same way that zprint handles reading external configuration files.
  • Configurable Styles: See CHANGELOG for details.
  • The handling of tagged literals (for example, #js) has been enhanced.
  • Upgraded to [org.babashka/sci "0.7.39"] and [rewrite-clj/rewrite-clj "1.1.47"].
  • The style :hiccup was sometimes recognizing destructuring in argument vectors as a hiccup vector.
  • Found and fixed several areas of justification that were slower than they needed to be.

zprint-filter-1.2.5

24 Jan 19:05

Choose a tag to compare

Lots of minor to moderate changes and fixes in this release.

NOTE: This is the first release where zprintl (the linux pre-built binary) has been taken from the GitHub CI build and test process, instead of built on my aging 2012 Intel MacBook Air. Please let me know if you have any issues using zprintl. Thanks!

  • Added a bunch of changes to justification, which are not on by default. In pairs, if you have a collection as the left-hand-side of a pair, and you would like the right-hand-side of the pair to format on the last line of a multi-line left-hand-side, include :style :multi-lhs-hang. See the CHANGELOG.md for more details.
  • You can now get regular expression matching for function names -> function types. More info in the CHANGELOG too.
  • Formatted files would sometimes change if they were immediately formatted again. Particularly when using :respect-nl. This is now mostly fixed. There are still some issues when comments wrap, which I will be working on, but formatting now appears largely stable. This has led to some changes in the formatting heuristics, which were rather "discontinuous", and didn't blend gracefully together. So the formatting has changed as I have wrestled with the heuristics (by turning some off, and changing the tuning for others to compensate). The changes aren't terrible, but if you prefer the old way, use :style :original-tuning. You will lose the stability, but if it didn't bother you before then I expect it won't bother you now.
  • Lots of fixes for bugs, for example empty vectors were dropped when using :format :off. See the CHANGELOG for details of all of the fixes.

zprint-filter-1.2.5-alpha1

26 Sep 17:42

Choose a tag to compare

Pre-release

This alpha release is for testing a fix for issue #263. Please do not use it for anything else, and do not put it into production.

zprint-filter-1.2.4

02 Aug 16:37

Choose a tag to compare

A release with considerable content:

  • Now supports :hiccup and :html output, both in library and prebuilt binaries. #214
  • You can alias one function to the format of another in the :fn-map. #234
  • Support for "consistent cond formatting". :flow-all-if-any? #235
  • Internal {:list {:nl-count <n>}} for newlines #236
  • Supports :max-gap for justification #239
  • Fixed: Namespaced maps don't work with :indent-only #242
  • Fixed: Inconsistent indentation in anon fns with :indent-only #243
  • Fixes: {:meta {:split? true}} doesn't handle multiple ^:stuff #245
  • Fixed: Use newer rewrite-clj and change edn*. #247

See CHANGELOG.md for more details on how to use some of these new things. Of course, they are in the documentation as well.

zprint-filter-1.2.3

12 Apr 21:35

Choose a tag to compare

A fair number of fixes and changes in this release. See the CHANGELOG.md for details, but notable new things are:

  • New :range configuration options: :use-previous-!zprint? and :continue-after-!zprint-error?. These allow someone doing :range formatting on a file (string) which has ;!zprint formatting directives to have the lines in the range formatted the same when doing just the range or the whole file. :use-previous-!zprint? if true will scan all previous ;!zprint directives prior to formatting the range. :continue-after-!zprint-error? if true will ignore errors in any ;!zprint directives, and output any errors in the map returned by :output {:range? true}.

  • An alternative way to format metadata was created. It is :style :meta-alt. It is presently experiemental. Issue #224.

  • letfn didn't indent its fns like fns. Now it does. And if they are multi-arity, the various arities don't hang, but rather flow. Issue #221.

  • The styles :community and :rod didn't compose, because :guided was not considered a "body" function type. Now they do. Issue #223.

  • zprint-file-str was not thread-safe, for a variety of reasons. Now it is, and configuration is thread-safe as well. Issue #226.

  • Figured out some Figwheel issues. If you use zprint with Figwheel, check out the CHANGELOG.md, or see issue #231.

zprint-filter-1.2.2

11 Feb 23:10

Choose a tag to compare

Two (relatively small) issues fixed here:

  • Complex :style declarations with a vector of styles didn't work well when some of those styles also had :style keys with vector values. Issue #217.
  • Added "defn-" to :style :rod since it already processed "defn".

The first issue, with :style, is important to upcoming enhancements to the VSCode zprint extension, vscode-clj-zprint.