There are two steps to changing the way that zprint formats Clojure information.
There are a large number of options maps configuration elements which can be changed to get zprint to format Clojure source or data in a way different from the default and more to your liking.
There are several ways to determine how to change the options map:
- See below for references to some commonly configured changes
- See the reference information, which contains documentation on everything that can be changed
- Submit an issue and ask how to configure zprint to do what you want
- how user defined functions are formatted
- the indentation in lists
- the configuration to track the "community" standard
- how blank lines in source are handled
- how map keys are formatted
- the colors used for formatting source
- how the second element of a pair is indented
- how comments are handled
Different formatting regimes accept options map information from different places.
When using either the pre-built binaries, or the uberjar (with or without appcds acceleration), options maps may be read from:
The ~/.zprintrc
(also known as $HOME/.zprintrc
) file will be read
when zprint is first invoked. You can put options maps changes in that
file and they will always be used (unless overridden by a later options map).
If you are using lein-zprint, you can put an options map in the :zprint
key
in project.clj
.
If you have configured {:cwd-zprintrc? true}
in your ~/.zprintrc
or on the
command line options map, zprint will look in the current working directory
(cwd) for a .zprintrc
file.
If you have configured {:search-config? true}
in your ~/.zprintc
or
on the command line options map, zprint will look in the current working
directory for a .zprintrc
file. If it finds one, it will use it. If it
doesn't find one, it will look in the parent of the directory for a .zprintrc
file and use it if it finds one. zprint will keep looking up the directory
tree for a .zprintrc
file, using the first one it finds.
zprint will accept an options map on the command line every time it is called. These options will only be used for that particular call.
You can alter the way that zprint formats a single function or any part of an entire file by including comments in the file which contain zprint comment formatting directives.
When using zprint as a library, it will look for configuration information:
The ~/.zprintrc
(also known as $HOME/.zprintrc
) file will be read
when zprint is first invoked. You can put options maps changes in that
file and they will always be used (unless overridden by a later options map).
If you have configured {:cwd-zprintrc? true}
in your ~/.zprintrc
zprint will look in the current working directory
(cwd) for a .zprintrc
file.
If you have configured {:search-config? true}
in your ~/.zprintc
zprint will look in the current working
directory for a .zprintrc
file. If it finds one, it will use it. If it
doesn't find one, it will look in the parent of the directory for a .zprintrc
file and use it if it finds one. zprint will keep looking up the directory
tree for a .zprintrc
file, using the first one it finds.
A call to set-options!
containing an options map will be remembered
until another call to set-options!
changes the internal options map
again.
You can re-initialize zprint by calling configure-all!
, which
will cause all existing information remembered from set-options
calls
to be forgotten. A call to configure-all!
will cause zprint to reconfigure
itself by using all available external configuration (see the places
immediately above).
Every time you call zprint to format something, the third argument can be an options map, which is used for only the formatting being done by that call.