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) <[email protected]>
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) <[email protected]>
9fd00b
#2791
Add ocamllex (.mll) file formatting support
FMT
c7659b
#2792
Fix formatting oscillation in if-then-else branches
Fix formatting oscillation in if-then-else branches When a comment sits between a keyword (then/else) and certain branch expressions (begin...end wrapping match/try/function/ifthenelse, or bare match/try/function/ifthenelse), the comment would alternate between "after keyword" and "before expression" placements across formatting iterations. This caused branch_pro to compute different indentation each time, producing "formatting did not stabilize after 10 iterations". The fix detects these oscillation-prone patterns and ensures stable formatting regardless of the initial comment placement: - In Fmt_ast, when a branch matches `needs_raw_cmts_after_kw`, extract "after keyword" comments without breaks and override branch_pro using `Params.raw_cmts_branch_pro` (which computes mode-appropriate break+indent+comment output). - In Params, `branch_pro_with_cmts` detects comments "before expression" (the alternate placement) and forces a break, producing the same layout as the "after keyword" path. - For begin...end branches, `branch_pro` checks for comments before the inner expression (not just the begin...end node) to handle the case where the comment migrates inside the begin...end scope. Affected modes: Fit_or_vertical, Compact (profile=conventional). Assisted-by: GitHub Copilot:claude-opus-4-20250514
af4faa
#2800