Organisationsocaml-ppxocamlformat

ocamlformat

https://github.com/ocaml-ppx/ocamlformat
Branches (3)
metaocaml
Add MetaOCaml support Add a --metaocaml flag to enable MetaOCaml syntax (brackets .< >., escape .~, run .!) in the lexer and formatter. Lexer changes: - Split symbolchar into symbolcharnodot/symbolchar to avoid capturing MetaOCaml tokens as operator characters - Gate .~ (escape) and >. (bracket close) behind the metaocaml flag; .< (bracket open) is always lexed as METAOCAML_BRACKET_OPEN - Add symbolchars sub-lexer for consuming remaining operator chars after >. when metaocaml is disabled - Thread ~metaocaml through parse.ml to set lex_metaocaml ref Formatter changes: - Detect metaocaml.bracket and metaocaml.escape extension nodes (synthetic, with ghost loc) and render them with sugar syntax (.< expr >. and .~expr) instead of [%metaocaml.bracket ...] - Parenthesize .~ argument unless it is a simple identifier - Skip comment relocation for metaocaml extension nodes in Cmts Configuration: - Add metaocaml boolean to opr_opts (Conf_t), default false - Wire --metaocaml/--no-metaocaml flag through Conf and CLI - Thread ~metaocaml through Extended_ast, Std_ast, Parse_with_comments, Toplevel_lexer
d974c1
mll-support
FMT
c7659b
simplify-extended-std-ast
Move parsing logic from Extended_ast back to Parse_with_comments Re-create Parse_with_comments with the parsing pipeline (Parsed type, Warning50 exception, parse, parse_toplevel) that was absorbed into Extended_ast. Re-export Extended_ast.Parse in the .mli. Update all callers. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
9fd00b
Refs Branches (6)
Initial support for metaocaml
Add MetaOCaml support Add a --metaocaml flag to enable MetaOCaml syntax (brackets .< >., escape .~, run .!) in the lexer and formatter. Lexer changes: - Split symbolchar into symbolcharnodot/symbolchar to avoid capturing MetaOCaml tokens as operator characters - Gate .~ (escape) and >. (bracket close) behind the metaocaml flag; .< (bracket open) is always lexed as METAOCAML_BRACKET_OPEN - Add symbolchars sub-lexer for consuming remaining operator chars after >. when metaocaml is disabled - Thread ~metaocaml through parse.ml to set lex_metaocaml ref Formatter changes: - Detect metaocaml.bracket and metaocaml.escape extension nodes (synthetic, with ghost loc) and render them with sugar syntax (.< expr >. and .~expr) instead of [%metaocaml.bracket ...] - Parenthesize .~ argument unless it is a simple identifier - Skip comment relocation for metaocaml extension nodes in Cmts Configuration: - Add metaocaml boolean to opr_opts (Conf_t), default false - Wire --metaocaml/--no-metaocaml flag through Conf and CLI - Thread ~metaocaml through Extended_ast, Std_ast, Parse_with_comments, Toplevel_lexer
d974c1
#2630
Format: Backport scan_push change
Format
38b460
#2778
Add neocaml-mode support to ocamlformat-before-save
Add changelog entry for neocaml-mode support
53e1c0
#2787
Simplify Extended_ast vs Std_ast
Move parsing logic from Extended_ast back to Parse_with_comments Re-create Parse_with_comments with the parsing pipeline (Parsed type, Warning50 exception, parse, parse_toplevel) that was absorbed into Extended_ast. Re-export Extended_ast.Parse in the .mli. Update all callers. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
9fd00b
#2791
Add ocamllex (.mll) file formatting support
FMT
c7659b
#2792
Fix formatting oscillation with `if-then-else=fit-or-vertical` and `begin…end`
Fix formatting oscillation with if-then-else=fit-or-vertical and begin...end When `if-then-else=fit-or-vertical` formats a branch containing `begin (* long comment *) if ... then ... end`, comments between the `then` keyword and `begin` would get attached to different AST locations on each formatting pass ("after" the keyword vs "before" the begin...end expression). This caused `branch_pro` to compute different indentation each time, producing an infinite oscillation that triggered "BUG: formatting did not stabilize after 10 iterations". The fix has two parts: 1. In Fmt_ast, when the if-then-else branch is a special begin...end (wrapping match/try/function/ifthenelse), relocate "after keyword" comments to "before branch" before formatting. This ensures consistent comment placement regardless of source layout. 2. In Params, when computing branch_pro for Fit_or_vertical, also check for comments before the inner expression of a special begin...end, not just before the begin...end node itself. A new helper `Cmts.relocate_after_to_before` moves comments from the "after" position of one location to the "before" position of another.
db1b40
#2800