OCamlFormat 0.25.0
OCamlFormat 0.25.0 is now available with expanded formatting capabilities!
This release addresses numerous inconsistencies and bugs, particularly around comment positioning, parentheses handling, and alignment issues. Key fixes include proper indentation when OCamlFormat is disabled on expressions, correct formatting of chunks with enable/disable attributes, and improved handling of comments around variant identifiers, type aliases, and constructor records. The release also resolves several platform-specific issues, including Windows build automation and glob pattern interpretation in .ocamlformat-ignore
files.
New formatting options provide developers with more control over code layout. The break-colon
option allows customization of line breaks around colons in value bindings and type constraints. Both if-then-else
and break-cases
options now support a vertical
value for consistent vertical formatting. Additionally, OCamlFormat can now format .mld
files as odoc documentation, and a new wrap-or-vertical
value for break-infix
provides more nuanced control over high-precedence infix operator wrapping.
See full changelog
Library
- The declaration of options is a regular module instead of a functor. (#2193, @EmileTrotignon)
Bug fixes
- Fix indentation when ocamlformat is disabled on an expression (#2129, @gpetiot)
- Reset max-indent when the
max-indent
option is not set (#2131, @hhugo, @gpetiot) - Add missing parentheses around immediate objects having attributes attached in 4.14 (#2144, @gpetiot)
- Fix dropped comment attached to the identifier of an open-expression (#2155, @gpetiot)
- Correctly format chunks of file in presence of
enable
/disable
floating attributes (#2156, @gpetiot) - Remove abusive normalization in docstrings references (#2159, #2162, @EmileTrotignon)
- Fix parentheses around symbols in if-then-else branches (#2169, @gpetiot)
- Preserve position of comments around variant identifiers (#2179, @gpetiot)
- Fix parentheses around symbol identifiers (#2185, @gpetiot)
- Fix alignment inconsistency between let-binding and let-open (#2187, @gpetiot)
- Fix reporting of operational settings origin in presence of profiles (#2188, @EmileTrotignon)
- Fix alignment inconsistency of if-then-else in apply (#2203, @gpetiot)
- Fix automated Windows build (#2205, @nojb)
- Fix spacing between recursive module bindings and recursive module declarations (#2217, @gpetiot)
- ocamlformat-rpc: use binary mode for stdin/stdout (#2218, @rgrinberg)
- Fix interpretation of glob pattern in
.ocamlformat-ignore
under Windows (#2206, @nojb) - Remove conf mutability, and correctly display the conventional profile when using print-config (#2233, @EmileTrotignon)
- Preserve position of comments around type alias (#2239, @EmileTrotignon)
- Preserve position of comments around constructor record (#2237, @EmileTrotignon)
- Preserve position of comments around external declaration strings (#2238, @EmileTrotignon, @gpetiot)
- Preserve position of comments around module pack expressions (#2234, @EmileTrotignon, @gpetiot)
- Correctly parenthesize array literals with attributes in argument positions (#2250, @ccasin)
Changes
- Indent 2 columns after
initializer
keyword (#2145, @gpetiot) - Preserve syntax of generative modules (
(struct end)
vs()
) (#2135, #2146, @trefis, @gpetiot) - Preserve syntax of module unpack with type constraint (
((module X) : (module Y))
vs(module X : Y)
) (#2136, @trefis, @gpetiot) - Normalize location format for warning and error messages (#2139, @gpetiot)
- Preserve syntax and improve readability of indexop-access expressions (#2150, @trefis, @gpetiot)
- Break sequences containing indexop-access assignments
- Remove unnecessary parentheses around indices
- Mute warnings for odoc code blocks whose syntax is not specified (#2151, @gpetiot)
- Improve formatting of odoc links (#2152, @gpetiot)
- Preserve sugared extension node attached to an
if
carrying attributes (#2167, @trefis, @gpetiot) - Remove unnecessary parentheses around partially applied infix operators with attributes (#2198, @gpetiot)
- JaneStreet profile: doesn't align infix ops with open paren (#2204, @gpetiot)
- Re-use the type let_binding from the parser instead of value_binding, improve the spacing of let-bindings regarding of having extension or comments (#2219, @gpetiot)
- The
ocamlformat
package now only contains the binary, the library is available through theocamlformat-lib
package (#2230, @gpetiot)
New features
- Add a
break-colon
option to decide whether to break before or after the:
symbol in value binding declarations and type constraints. This behavior is no longer ensured byocp-indent-compat
. (#2149, @gpetiot) - Format
.mld
files as odoc documentation files (#2008, @gpetiot) - New value
vertical
for optionif-then-else
(#2174, @gpetiot) - New value
vertical
for optionbreak-cases
(#2176, @gpetiot) - New value
wrap-or-vertical
for optionbreak-infix
that only wraps high precedence infix ops (#1865, @gpetiot)