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)
Improve position of ;; tokens (#1688, @gpetiot)
Depend on odoc-parser instead of odoc (#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
Named existentials in pattern-matching (ocaml#9584)
Let-punning (ocaml#10013)
Module type substitutions (ocaml#10133) (#1680, @gpetiot)
Emacs integration (disabled for ocamlformat < 0.19.0):
Indent a line or a region with ocamlformat when pressing
Break the line and reindent the cursor when pressing (#1639, #1685, @gpetiot) (#1687, @bcc32)
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 of ocamlformat using mingw64 toolchain under Cygwin.
0.18.0 (2021-03-30)
Bug fixes
Fix extraneous parenthesis after let open with closing-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
Expose a RPC interface through a new binary ocamlformat-rpc and a new library ocamlformat-rpc-lib (#1586, @gpetiot, @voodoos)
0.17.0 (2021-02-15)
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)
Preserve spacing of toplevel comments (#1554, @gpetiot)
Support more sugared extension points (#1587, @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
Support injectivity type annotations (OCaml 4.12 feature) (#1523, @gpetiot)
0.16.0 (2020-11-16)
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 with if-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 and try keywords (#1458, @gpetiot)
Add missing break in module statement (#1431, @gpetiot)
Indent attributes attached to included modules better (#1468, @gpetiot)
Clean up ocamlformat.el for submission to MELPA (#1476, #1495, @bcc32)
Added missing package metadata to ocamlformat.el (#1474, @bcc32)
Fix ocamlformat.el buffer replacement for MacOS Emacs (#1481, @juxd)
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 comments around desugared expression (#1487, @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 example open%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)
Preserve functor syntax for OCaml 4.12 (#1514, @gpetiot)
Fix inconsistencies of the closing parentheses with indicate-multiline-delimiters (#1377, #1540, @gpetiot)
Fix position of comments around list constructor (::) (#1524, @gpetiot)
Fix comments position in extensions (#1525, @gpetiot)
Fix formatting of field override with constraint (#1544, @gpetiot)
New features
0.15.1 (2020-11-02)
Internal
Use ppxlib instead of ocaml-migrate-parsetree 1.x. (#1482, @emillon)
Do not break inline elements such as {i blah} in docstrings (#1346, @jberdine)
Distinguish hash-getter from hash-comparison infix operators. Operators of the form #**# or #**. where ** can be 0 or more operator chars are considered getter operators and are not surrounded by spaces, as opposed to regular infix operators (#1376, @gpetiot)
Type constraint on return type of functions is now always printed before the function body (#1381, #1397, @gpetiot)
Bug fixes
Restore previous functionality for pre-post extension points (#1342, @jberdine)
Fix extra break before function body of a fun (#1343, @jberdine) Indent further args of anonymous functions (#1440, @gpetiot)
Do not clear the emacs *compilation* buffer on successful reformat (#1350, @jberdine)
Fix disabling with attributes on OCaml < 4.08 (#1322, @emillon)
Preserve unwrapped comments by not adding artificial breaks when wrap-comments=false and ocp-indent-compat=true are set to avoid interfering with ocp-indent indentation. (#1352, @gpetiot)
Break long literal strings at the margin (#1367, @gpetiot)
Break after a multiline argument in an argument list (#1360, @gpetiot)
Remove unnecessary parens around object (#1379, @gpetiot)
Fix placement of comments on constants (#1383, @gpetiot)
Do not escape arguments of some Odoc tags (#1391, 1408, @gpetiot, @Julow) The characters []{} must not be escaped in the arguments of @raise, @author, @version and others.
Fix missing open line between multi-line let-binding with poly-typexpr (#1372, @jberdine)
Remove trailing space after expression when followed by an attribute and break before attributes attached to multi-line phrases (#1382, @gpetiot)
Do not add a space to minimal comments (* *), (** *) and (*$ *) (#1407, @gpetiot)
Fix attributes position in labelled arguments type (#1434, @gpetiot)
Add missing parens around type annotation in anonymous function (#1433, @gpetiot)
Fix alignment of 'then' keyword in parenthesised expression (#1421, @gpetiot)
New features
Support quoted extensions (added in ocaml 4.11) (#1405, @gpetiot)
Recognise eliom file extensions (#1430, @jrochel)
0.14.3 (2020-07-22)
Changes
No functional changes from 0.14.2. The goal of this release is to be compatible with base and stdio v0.14.0.
Backport the following PRs:
#1386 - Update opam metadata
#1396 - Add compatibility with base.v0.14.0
#1399 - Allow stdio.v0.14
0.14.2 (2020-05-11)
Changes
Merge doc-comments-val option with doc-comments. The placement of documentation comments on val and external items is now controled by doc-comments.
doc-comments=after becomes doc-comments=after-when-possible to take into account the technical limitations of ocamlformat;
doc-comments=before is unchanged;
doc-comments-val is now replaced with doc-comments To reproduce the former behaviors
doc-comments=before + doc-comments-val=before: now use doc-comments=before;
doc-comments=before + doc-comments-val=after: now use doc-comments=before-except-val;
doc-comments=after + doc-comments-val=before: this behavior did not make much sense and is not available anymore;
doc-comments=after + doc-comments-val=after: now use doc-comments=after-when-possible.
This reverts changes introduced in 0.14.1 (#1335) and 0.14.0 (#1012).
0.14.1 (2020-04-14)
Changes
The default for doc-comments is changed to after (#1335) (Jules Aguillon) This reverts a change introduced in 0.14.0 (#1012).
Revert deprecation of the doc-comments option (#1331) (Jules Aguillon) This reverts a change introduced in 0.14.0 (#1293).
0.14.0 (2020-04-02)
New features
Add an option --format-invalid-files to print unparsable parts of the input as verbatim text. This feature is still experimental. (#1026) (Guillaume Petiot)
Support multi-indices extended indexing operators (#1279, #1277) (Jules Aguillon, Guillaume Petiot) This feature has been added in OCaml 4.10.0
Preserve functor syntax for consistency (#1312) (Guillaume Petiot) Previously both functor syntax: module M = functor (K : S) -> struct end and module M (K : S) = struct end would be formatted as the latter, the original syntax is now preserved.
Changes
Add the option doc-comments-val=before|after (#1012) (Jules Aguillon) This option set the placement of documentation comment on val and external only. It is set to after by default.
The default for doc-comments is changed from after to before (#1012, #1325) (Jules Aguillon) This affects both conventional (default) and ocamlformat profiles.
Some options are now deprecated:
doc-comments (#1293, #1012) This option depends on a flawed heuristic. It is replaced by doc-comments-val for val and external declarations. There is no equivalent to this option in the general case.
escape-chars, escape-strings and extension-sugar (#1293) These options are rarely used and their default behavior is considered to be the right behavior.
Add space between row_field attributes and the label or arguments, to be consistent with the non-polymorphic case. (#1299) (Craig Ferguson)
Bug fixes
Fix missing parentheses around let open (#1229) (Jules Aguillon) eg. M.f (M.(x) [@attr]) would be formatted to M.f M.(x) [@attr], which would crash OCamlformat
Remove unecessary parentheses with attributes in some structure items:
extensions and eval items (#1230) (Jules Aguillon) eg. the expression [%ext (() [@attr])] or the structure item (() [@attr]) ;;
let _ = ... constructs (#1244) (Etienne Millon)
Fix some bugs related to comments:
after a function on the rhs of an infix (#1231) (Jules Aguillon) eg. the comment in (x >>= fun y -> y (* A *)) would be dropped
in module unpack (#1309) (Jules Aguillon) eg. in the module expression module M = (val x : S (* A *))
Fix formatting of empty signature payload [%a:] (#1236) (Etienne Millon)
Fix parenthesizing when accessing field of construct application (#1247) (Guillaume Petiot)
Fix formatting of attributes on object overrides {< >} (#1238) (Etienne Millon)
Fix attributes on coercion (#1239) (Etienne Millon)
Fix formatting of attributes on packed modules (#1243) (Etienne Millon)
Fix parens around binop operations with attributes (#1252, #1306) (Guillaume Petiot, Craig Ferguson)
Remove unecessary parentheses in the argument of indexing operators (#1280) (Jules Aguillon)
Retain attributes on various AST nodes:
field set expressions, e.g. (a.x <- b) [@a] (#1284) (Craig Ferguson)
instance variable set expressions, e.g. (a <- b) [@a] (#1288) (Craig Ferguson)
indexing operators, e.g. (a.(b)) [@a] (#1300) (Craig Ferguson)
sequences, e.g. (a; b) [@a] (#1291) (Craig Ferguson)
Avoid unnecessary spacing after object types inside records and polymorphic variants, e.g. {foo : < .. > [@a]} and { foo : < .. > } (#1296) (Craig Ferguson)
Fix missing parentheses around tuples with attributes. (#1301) (Craig Ferguson) Previously, f ((0, 0) [@a]) would be formatted to f (0, 0) [@a], crashing OCamlformat.
Avoid emitting >] when an object type is contained in an extension point or attribute payload (#1298) (Craig Ferguson)
Fix crash on the expression (0).*(0) (#1304) (Jules Aguillon) It was formatting to 0.*(0) which parses as an other expression.
Preserve empty doc-comments syntax. (#1311) (Guillaume Petiot) Previously (**) would be formatted to (***).
Do not crash when a comment contains just a newline (#1290) (Etienne Millon)
Handle lazy patterns as arguments to class (#1289) (Etienne Millon)
Preserve cinaps comments containing unparsable code (#1303) (Jules Aguillon) Previously, OCamlformat would fallback to the "wrapping" logic, making the comment unreadable and crashing in some cases.
Fix normalization of attributes, fixing the docstrings in attributes (#1314) (Guillaume Petiot)
Add missing parentheses around OR-patterns with attributes (#1317) (Guillaume Petiot)
Fix spacing inside parens for symbols when the spacing was handled by the englobing exp (#1316) (Guillaume Petiot)
Fix invalid (unparsable) docstrings (#1315) (Guillaume Petiot) When parsing a comment raises an error in odoc, it is printed as-is.
Fix parenthesizing of optional arguments rebound to non-variables, e.g. let f ?a:(A) = () rather than the unparsable let f ?a:A = () (#1305) (Craig Ferguson)
0.13.0 (2020-01-28)
New features
Add an option --margin-check to emit a warning if the formatted output exceeds the margin (#1110) (Guillaume Petiot)
Preserve comment indentation when wrap-comments is unset (#1138, #1159) (Jules Aguillon)
Improve error messages (#1147) (Jules Aguillon)
Display standard output in the emacs plugin even when ocamlformat does not fail (#1189) (Guillaume Petiot)
Removed
Remove ocamlformat_reason (#254, #1185) (Etienne Millon). This tool has never been released to opam, has no known users, and overlaps with what refmt can do.
Remove ocamlformat-diff (#1205) (Guillaume Petiot) This tool has never been released to opam, has no known users, and overlaps with what merge-fmt can do.
Packaging
Work with base v0.13.0 (#1163) (Jules Aguillon)
Bug fixes
Fix placement of comments just before a '|' (#1203) (Jules Aguillon)
Fix build version detection when building in the absence of a git root (#1198) (Anil Madhavapeddy)
Fix wrapping of or-patterns in presence of comments with break-cases=fit (#1167) (Jules Aguillon) This also fixes an unstable comment bug in or-patterns
Fix an unstable comment bug in variant declarations (#1108) (Jules Aguillon)
Fix: types on named arguments were wrapped incorrectly when preceding comments (#1124) (Guillaume Petiot)
Fix the indentation produced by max-indent (#1118) (Guillaume Petiot)
Fix break after Psig_include depending on presence of docstring (#1125) (Guillaume Petiot)
Remove some calls to if_newline and break_unless_newline and fix break before closing brackets (#1168) (Guillaume Petiot)
Fix unstable cmt in or-pattern (#1173) (Guillaume Petiot)
Fix location of comment attached to the underscore of an open record (#1208) (Guillaume Petiot)
Fix parentheses around optional module parameter (#1212) (Christian Barcenas)
Fix grouping of horizontally aligned comments (#1209) (Guillaume Petiot)
Fix dropped comments around module pack expressions (#1214) (Jules Aguillon)
Fix regression of comment position in list patterns (#1141) (Josh Berdine)
Fix: adjust definition of Location.is_single_line to reflect margin (#1102) (Josh Berdine)
Documentation
Fix documentation of option version-check (#1135) (Wilfred Hughes)
Fix hint when using break-separators=after-and-docked (#1130) (Greta Yorsh)
0.12 (2019-11-04)
Changes
Set "conventional" as the default profile (#1060) (Guillaume Petiot) This new profile is made to better match the most used style and is encouraged. To continue using the previous default, use profile = ocamlformat in your .ocamlformat.
CLI: Allow both values of boolean options (#1062) (Jules Aguillon) Now, both --opt and --no-opt` are available on the CLI for any boolean option "opt". Previously, only one of them were available depending on the default value.
Auto mode for break-string-literals (#1057) (Guillaume Petiot) wrap, newlines and newlines-and-wrap values of break-string-literals are removed. auto replaces them, it is equivalent to newlines-and-wrap.
Dock collection brackets (#1014) (Guillaume Petiot) after-and-docked value of break-separators is removed and is replaced by a new dock-collection-brackets option.
Preserve begin and end keywords in if-then-else (#978) (Jules Aguillon) Previously, begin/end keywords around if-then-else branches were turned into parentheses.
New features
Give a hint when warning 50 is raised (#1111) (Guillaume Petiot)
Add a message when a config value is removed (#1089) (Etienne Millon) Explain what replaces removed options and avoid printing a parsing error.
Implement sequence-blank-line=preserve-one for let bindings (#1077) (Jules Aguillon) Preserve a blank line after let .. in when sequence-blank-line set to preserve-one. Previously, only blank lines after ; could be preserved.
Parse toplevel directives (#1020) (Jules Aguillon) Allow #directives in .ml files. Previously, files containing a directive needed to be parsed as "use file". The "use file" mode is removed and --use-file is now the same as --impl.
Don't require --name, require kind, forbid --inplace, allow --check, make --enable-outside-detected-project implicit when reading from stdin (#1018) (Guillaume Petiot)
Parse code in docstrings (#941) (Guillaume Petiot) Format OCaml code in cinaps-style comments (*$ code *) and code blocks in documentation comments (** {[ code ]} *).
Parse documentation comments with Odoc (#721) (Jules Aguillon) Formatting of documentation comments is more robust and support newer Odoc syntaxes. Internally, Odoc replaces Octavius as the documentation parser.
Bug fixes
Fix unstabilizing comments on assignments (#1093) (Guillaume Petiot)
Fix the default value documentation for max-indent (#1105) (Guillaume Petiot)
Fix closing parenthesis exceeding the margin in function application (#1098) (Jules Aguillon)
Missing break before attributes of Pmty_with (#1103) (Josh Berdine)
Fix closing quote exceeding the margin (#1096) (Jules Aguillon)
Fix break before the closing bracket of collections (exceeding the margin) (#1073) (Guillaume Petiot)
Fix precedence of Dot wrt Hash (#1058) (Guillaume Petiot)
Fix break in variant type definition to not exceed the margin (#1064) (Guillaume Petiot)
Fix newlines and indentation in toplevel extension points (#1054) (Guillaume Petiot)
Fix placement of doc comments around extensions (#1052) (Jules Aguillon)
Inline extensions that do not break (#1050) (Guillaume Petiot)
Add missing cut before attributes in type declarations (#1051) (Guillaume Petiot)
Fix alignment of cases (#1046) (Guillaume Petiot)
Fix blank line after comments at the end of lists (#1045) (Guillaume Petiot)