Releases: ocaml-ppx/ocamlformat
0.22.3
CHANGES:
Removed
- Profiles
compact
andsparse
are now removed (#2075, @gpetiot) - Options
align-cases
,align-constructors-decl
andalign-variants-decl
are now removed (#2076, @gpetiot) - Option
disable-outside-detected-project
is now removed (#2077, @gpetiot)
Deprecated
Bug fixes
- emacs: Remove temp files in the event of an error (#2003, @gpetiot)
- Fix unstable comment formatting around prefix op (#2046, @gpetiot)
Changes
- Qtest comments are not re-formatted (#2034, @gpetiot)
- ocamlformat-rpc is now distributed through the ocamlformat package (#2035, @Julow)
- Doc-comments code blocks with a language other than 'ocaml' (set in metadata) are not parsed as OCaml (#2037, @gpetiot)
- More comprehensible error message in case of version mismatch (#2042, @gpetiot)
- The global configuration file (
$XDG_CONFIG_HOME
or$HOME/.config
) is only applied when no project is detected,--enable-outside-detected-project
is set, and no applicable.ocamlformat
file has been found. Global and local configurations are no longer used at the same time. (#2039, @gpetiot) - Set
ocaml-version
to a fixed version (4.04.0) by default to avoid reproducibility issues and surprising behaviours (#2064, @kit-ty-kate) - Split option
--numeric=X-Y
into--range=X-Y
and--numeric
(flag). For now--range
can only be used with--numeric
. (#2073, #2082, @gpetiot)
New features
- New syntax
(*= ... *)
for verbatim comments (#2028, @gpetiot) - Preserve the begin-end construction in the AST (#1785, @hhugo, @gpetiot)
- Preserve position of comments located after the semi-colon of the last element of lists/arrays/records (#2032, @gpetiot)
- Option
--print-config
displays a warning when an .ocamlformat file defines redundant options (already defined by a profile) (#2084, @gpetiot)
0.22.2
CHANGES:
Removed
- Profiles
compact
andsparse
are now removed (#2075, @gpetiot) - Options
align-cases
,align-constructors-decl
andalign-variants-decl
are now removed (#2076, @gpetiot) - Option
disable-outside-detected-project
is now removed (#2077, @gpetiot)
Deprecated
Bug fixes
- emacs: Remove temp files in the event of an error (#2003, @gpetiot)
- Fix unstable comment formatting around prefix op (#2046, @gpetiot)
Changes
- Qtest comments are not re-formatted (#2034, @gpetiot)
- ocamlformat-rpc is now distributed through the ocamlformat package (#2035, @Julow)
- Doc-comments code blocks with a language other than 'ocaml' (set in metadata) are not parsed as OCaml (#2037, @gpetiot)
- More comprehensible error message in case of version mismatch (#2042, @gpetiot)
- The global configuration file (
$XDG_CONFIG_HOME
or$HOME/.config
) is only applied when no project is detected,--enable-outside-detected-project
is set, and no applicable.ocamlformat
file has been found. Global and local configurations are no longer used at the same time. (#2039, @gpetiot) - Set
ocaml-version
to a fixed version (4.04.0) by default to avoid reproducibility issues and surprising behaviours (#2064, @kit-ty-kate) - Split option
--numeric=X-Y
into--range=X-Y
and--numeric
(flag). For now--range
can only be used with--numeric
. (#2073, #2082, @gpetiot)
New features
- New syntax
(*= ... *)
for verbatim comments (#2028, @gpetiot) - Preserve the begin-end construction in the AST (#1785, @hhugo, @gpetiot)
- Preserve position of comments located after the semi-colon of the last element of lists/arrays/records (#2032, @gpetiot)
- Option
--print-config
displays a warning when an .ocamlformat file defines redundant options (already defined by a profile) (#2084, @gpetiot)
0.21.0
CHANGES:
Bug fixes
-
Add missing parentheses around variant class arguments (#1967, @gpetiot)
-
Fix position of
:=
whenassignment-operator=end-line
(#1985, @gpetiot) -
Fix position of comments attached to constructor decl (#1986, @gpetiot)
-
Do not wrap docstrings,
wrap-comments
should only impact non-documentation comments, wrapping invalid docstrings would cause the whole file to not be formatted (#1988, @gpetiot) -
Do not break between 2 module items when the first one has a comment attached on the same line. Only a comment on the next line should induce a break to make it clear to which element it is attached to (#1989, @gpetiot)
-
Preserve position of comments attached to the last node of a subtree (#1667, @gpetiot)
-
Do not override the values of the following non-formatting options when a profile is set:
comment-check
,disable
,max-iters
,ocaml-version
, andquiet
(#1995, @gpetiot). -
Remove incorrect parentheses around polymorphic type constraint (#2002, @gpetiot)
-
Handle cases where an attribute is added to a bind expression, e.g.
(x >>= (fun () -> ())) [@a]
(#2013, @emillon) -
Fix indentation of constraints of a package type pattern (#2025, @gpetiot)
Changes
-
More expressions are considered "simple" (not inducing a break e.g. as an argument of an application):
-
Print odoc code block delimiters on their own line (#1980, @gpetiot)
-
Make formatting of cons-list patterns consistent with cons-list expressions, (::) operators are aligned when possible, comments position also improved (#1983, @gpetiot)
-
Apply 'sequence-style' to add a space before ';;' between toplevel items, consistently with the formatting of ';' in sequences (#2004, @gpetiot)
New features
- Format toplevel phrases and their output (#1941, @Julow, @gpetiot).
This feature is enabled with the flag--parse-toplevel-phrases
.
Toplevel phrases are supported when they are located in doc-comments blocks and cinaps comments.
Whole input files can also be formatted as toplevel phrases with the flag--repl-file
.
RPC
-
ocamlformat-rpc-lib is now functorized over the IO (#1975, @gpetiot).
Now handlesCsexp.t
types instead ofSexplib0.Sexp.t
. -
RPC v2 (#1935, @panglesd):
Define a 'Format' command parameterized with optionnal arguments to set or override the config and path, to format in the style of a file. -
Prevent RPC to crash on version mismatch with
.ocamlformat
(#2011, @panglesd, @Julow)
0.20.1
0.20.0
CHANGES:
Deprecated
-
Profiles
compact
andsparse
are now deprecated and will be removed by version 1.0 (#1803, @gpetiot) -
Options that are not set by the preset profiles are now deprecated and will be removed by version 1.0:
align-cases
,align-constructors-decl
andalign-variants-decl
(#1793, @gpetiot)disambiguate-non-breaking-match
(#1805, @gpetiot)break-before-in
(#1888, @gpetiot)break-cases={toplevel,all}
(#1890, @gpetiot)break-collection-expressions
(#1891, @gpetiot)break-fun-decl=smart
(#1892, @gpetiot)break-fun-sig=smart
(#1893, @gpetiot)break-string-literals
(#1894, @gpetiot)break-struct
(#1895, @gpetiot)extension-indent
(#1896, @gpetiot)function-indent
(#1897, @gpetiot)function-indent-nested
(#1898, @gpetiot)if-then-else={fit-or-vertical,k-r}
(#1899, @gpetiot)indicate-multiline-delimiters=closing-on-separate-line
(#1900, @gpetiot)indent-after-in
(#1901, @gpetiot)let-binding-indent
(#1902, @gpetiot)let-binding-spacing=sparse
(#1903, @gpetiot)match-indent
(#1904, @gpetiot)match-indent-nested
(#1905, @gpetiot)module-item-spacing=preserve
(#1906, @gpetiot)nested-match
(#1907, @gpetiot)parens-tuple-patterns
(#1908, @gpetiot)sequence-style=before
(#1909, @gpetiot)stritem-extension-indent
(#1910, @gpetiot)type-decl-indent
(#1911, @gpetiot)
Bug fixes
-
Fix normalization of sequences of expressions (#1731, @gpetiot)
-
Type constrained patterns are now always parenthesized, parentheses were missing in a class context (#1734, @gpetiot)
-
Support sugared form of coercions in let bindings (#1739, @gpetiot)
-
Add missing parentheses around constructor used as indexing op (#1740, @gpetiot)
-
Avoid normalizing newlines inside quoted strings
{|...|}
(#1754, @nojb, @hhugo) -
Fix quadratic behavior when certain constructs are nested. This corresponds
to the cases where a partial layout is triggered to determine if a construct
fits on a single line for example. (#1750, #1766, @emillon) -
Fix non stabilizing comments after infix operators (
*
,%
,#
-ops) (#1776, @gpetiot) -
Fix excessive break and wrong indentation after a short-open when
indicate-multiline-delimiters=closing-on-separate-line
(#1786, @gpetiot) -
Add parentheses around type alias used as type constraint (#1801, @gpetiot)
-
Fix alignment of comments inside a tuple pattern and remove incorrect linebreak.
Fix formatting of labelled arguments containing comments.
(#1797, @gpetiot) -
Emacs: only hook ocamlformat mode on tuareg/caml modes when ocamlformat is not disabled (#1814, @gpetiot)
-
Fix boxing of labelled arguments, avoid having a linebreak after a label when the argument has a comment attached (#1830, #1885, @gpetiot)
-
Add missing parentheses around application of prefix op when applied to other operands (#1825, @gpetiot)
-
Fix application of a monadic binding when 'break-infix-before-func=false' (#1849, @gpetiot)
-
Fix dropped comments attached to a sequence in a sugared extension node (#1853, @gpetiot)
-
Fix formatting of exception types, and add missing parentheses (#1873, @gpetiot)
-
Preserve sugared syntax of extension points with attributes (#1913, @gpetiot)
-
Improve comment attachment when followed but not preceded by a linebreak (#1926, @gpetiot)
-
Fix position of comments preceding Pmod_ident (#1939, @gpetiot)
-
Make the formatting of attributes and docstrings more consistent (#1929, @gpetiot)
-
Fix stabilization of comments inside attributes (#1942, @gpetiot)
Changes
-
Set 'module-item-spacing=compact' in the default/conventional profile (#1848, @gpetiot)
-
Preserve bracketed lists in the Parsetree (#1694, #1876, #1914, @gpetiot)
-
Line directives now cause OCamlFormat to emit an error, they were previously silently ignored (#1845, @gpetiot)
-
Apply option 'module-item-spacing' on mutually recursive type declarations for more consistency (#1854, @gpetiot)
New features
-
Handle punned labelled arguments with type constraint in function applications.
For example, function application of the formfoo ~(x:int)
instead of the explicitfoo ~x:(x:int)
. (ocaml#10434) (#1756, #1759, @gpetiot)
This syntax is only produced when the output syntax is at least OCaml 4.14. -
Allow explicit binders for type variables (ocaml#10437) (#1757, @gpetiot)
-
Add a new
ocaml-version
option to select the version of OCaml syntax of the output (#1759, @gpetiot) -
Allow disambiguated global identifiers (like t/2) so they can be formatted by tools like OCaml-LSP (#1716, @let-def)
-
Handle let operator punning uniformly with other punning forms.
Normalizes let operator to the punned form where possible, if output syntax version is at least OCaml 4.13.0. (#1834, #1846, @jberdine) -
Remove unnecessary surrounding parentheses for immediate objects.
This syntax is only produced when the output syntax is at least OCaml 4.14. (#1934, @gpetiot)
0.19.0
CHANGES:
Bug fixes
-
Fix formatting of odoc tags: the argument should be on the same line, indent description that wraps (#1634, #1635, @gpetiot)
-
Consistently format let bindings and monadic let bindings, do not drop comments before monadic bindings (#1636, @gpetiot)
-
Fix dropped comments attached to pattern constrained by polynewtype (#1645, @gpetiot)
-
Add missing spaces inside begin-end delimiting an ite branch (#1646, @gpetiot)
-
Add missing parens around function at RHS of infix op (#1642, @gpetiot)
-
Preserve begin-end keywords delimiting match cases (#1651, @gpetiot)
-
Fix alignment of closing paren on separate line for anonymous functions (#1649, @gpetiot)
-
Preserve begin-end keywords around infix operators (#1652, @gpetiot)
-
Preserve
begin%ext
syntax for infix opererator expressions (#1653, @gpetiot) -
Consistently format comments attached to let-and bindings located at toplevel (#1663, @gpetiot)
-
Remove double parens around a functor in a module application (#1681, @gpetiot)
-
Improve breaking of comments to avoid violating the margin (#1676, @jberdine)
-
Fix parentheses around successive unary operations (#1696, @gpetiot)
-
Add missing break between pattern and attribute (#1711, @gpetiot)
-
Add missing parentheses around expression having attributes or comments inside a shorthand let-open clause (#1708, @gpetiot)
-
Do not consider leading star '*' when checking the diff of doc comments (#1712, @hhugo)
-
Fix formatting of multiline non-wrapping comments (#1723, @gpetiot)
Changes
-
Improve the diff of unstable docstrings displayed in error messages (#1654, @gpetiot)
-
Use UTF8 length of strings, not only in wrapped comments (#1673, @jberdine)
-
Depend on
odoc-parser
instead ofodoc
(#1683, #1713, @kit-ty-kate, @jonludlam, @Julow)
The parser from odoc has been split from the main odoc package and put into its own package,odoc-parser
. -
Revert infix-form list formatting to pre-0.17.0 (#1717, @gpetiot)
New features
-
Implement OCaml 4.13 features
-
Emacs integration (disabled for ocamlformat < 0.19.0):
-
Add 'line-endings=lf|crlf' option to specify the line endings used in the
formatted output. (#1703, @nojb)
Internal
- A script
tools/build-mingw64.sh
is provided to build a native Windows
binary ofocamlformat
usingmingw64
toolchain under Cygwin.
0.18.0
CHANGES:
Bug fixes
-
Fix extraneous parenthesis after
let open
withclosing-on-separate-line
(#1612, @Julow) -
Add missing break between polytype quantification and arrow-type body (#1615, @gpetiot)
Changes
-
Use dune instrumentation backend for
bisect_ppx
(#1550, @tmattio) -
Format objects and classes consistently with structure and signature items (#1569, @bikallem)
New features
0.17.0
CHANGES:
Removed
-
Remove the 'let-open' option, deprecated since 0.16.0 (#1563, @gpetiot)
-
Remove support for OCaml 4.06 and 4.07, minimal version requirement bumped to OCaml 4.08 (#1549, @gpetiot)
-
Remove the 'extension-sugar' option, deprecated since 0.14.0 (#1588, @gpetiot)
Bug fixes
-
Fix parsing of invalid file wrt original source handling (#1542, @hhugo)
-
Preserve the syntax of infix set/get operators (#1528, @gpetiot)
String.get
and similar calls used to be automatically rewritten to their corresponding infix form.()
, that was incorrect when using the-unsafe
compilation flag. Now the concrete syntax of these calls is preserved. -
Add location of invalid docstring in warning messages (#1529, @gpetiot)
-
Fix comments on the same line as prev and next elements (#1556, @gpetiot)
-
Break or-patterns after comments and preserve their position at the end of line (#1555, @gpetiot)
-
Fix linebreak between signature items of the same group (#1560, @gpetiot)
-
Fix stack overflow on large string constants (#1562, @gpetiot)
-
Fix comment position around list cons operator (#1567, @gpetiot)
-
Fix the vertical alignment test to break down comment groups (#1575, @gpetiot)
Changes
-
Add buffer filename in the logs when applying ocamlformat (#1557, @dannywillems)
-
Improve comment position in pattern collection (#1576, @gpetiot)
-
Consistent positioning of lambda return type annotations when no-break-infix-before-func and pre/post extensions (#1581, @gpetiot)
New features
0.16.0
CHANGES:
Removed
-
Remove the 'escape-chars' option, deprecated since 0.14.0 (#1462, @gpetiot)
-
Remove the 'escape-strings' option, deprecated since 0.14.0 (#1463, @gpetiot)
-
Remove the 'doc-comments-val' option, deprecated since 0.14.2 (#1461, @gpetiot)
-
Removed options are now listed in the commandline manual (new REMOVED OPTIONS section) (#1469, @Julow)
Changes
-
Set 'indicate-multiline-delimiters=no' on default profile (#1452, @gpetiot)
-
Option 'let-open' is now deprecated, concrete syntax will always be preserved starting from OCamlFormat v0.17.0, corresponding to the current 'let-open=preserve' behavior. (#1467, @gpetiot)
-
Warnings printed by ocamlformat itself now use the 4.12 style with symbolic names (#1511, #1518, @emillon)
-
Remove extension from executable name in error messages. On Windows, this means that messages now start with "ocamlformat: ..." instead of "ocamlformat.exe: ..." (#1531, @emillon)
-
Using tokens instead of string manipulation when inspecting the original source (#1526, #1533, #1541 @hhugo) (#1532, @gpetiot)
Bug fixes
-
Allow a break after
if%ext
withif-then-else=keyword-first
(#1419, #1543, @gpetiot) -
Fix parentheses around infix applications having attributes (#1464, @gpetiot)
-
Fix parentheses around the index arg of a non-sugared index operation (#1465, @gpetiot)
-
Preserve comment position around
match
andtry
keywords (#1458, @gpetiot) -
Indent attributes attached to included modules better (#1468, @gpetiot)
-
Clean up
ocamlformat.el
for submission to MELPA (#1476, #1495, @bcc32) -
Add missing parentheses around a pattern matching that is the left-hand part of a sequence when an attribute is attached (#1483, @gpetiot)
-
Add missing parentheses around infix operator used to build a function (#1486, @gpetiot)
-
Fix invalid fragment delimiters of format-invalid-files recovery mode (#1485, @hhugo)
-
Fix misalignment of cases in docked
function
match (#1498, @gpetiot) -
Preserve short-form extensions for structure item extensions (#1502, @gpetiot)
For exampleopen%ext M
will not get rewritten to[%%ext open M]
. -
Do not change the spaces within the code spans in docstrings (#1499, @gpetiot)
-
Comments of type constrained label in record pattern have to be relocated in 4.12 (#1517, @gpetiot)
-
Fix inconsistencies of the closing parentheses with indicate-multiline-delimiters (#1377, #1540, @gpetiot)
-
Fix position of comments around list constructor (::) (#1524, @gpetiot)
-
Fix formatting of field override with constraint (#1544, @gpetiot)