Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
hhugo committed Nov 26, 2024
1 parent a5de7ff commit 918887e
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 7 deletions.
6 changes: 6 additions & 0 deletions doc/manpage_ocamlformat.mld
Original file line number Diff line number Diff line change
Expand Up @@ -575,6 +575,9 @@ OPTIONS
Emit a warning if the formatted output exceeds the margin. The
flag is unset by default.

--metaocaml
Enable MetaOCaml support. The flag is unset by default.

-n N, --max-iters=N
Fail if output of formatting does not stabilize within N
iterations. May be set in .ocamlformat. The default value is 10.
Expand All @@ -601,6 +604,9 @@ OPTIONS
--no-margin-check
Unset margin-check.

--no-metaocaml
Unset metaocaml.

--no-quiet
Unset quiet.

Expand Down
18 changes: 11 additions & 7 deletions lib/Conf.ml
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,8 @@ module Formatting = struct
in
Decl.choice ~names ~all ~default ~doc ~kind
(fun conf elt ->
update conf ~f:(fun f -> {f with break_collection_expressions= elt}) )
update conf ~f:(fun f -> {f with break_collection_expressions= elt})
)
(fun conf -> conf.fmt_opts.break_collection_expressions)

let break_colon =
Expand Down Expand Up @@ -597,7 +598,8 @@ module Formatting = struct
Decl.choice ~names ~all ~default ~doc ~kind
(fun conf elt ->
update conf ~f:(fun f ->
{f with break_struct= Elt.make Poly.(elt.v = `Force) elt.from} ) )
{f with break_struct= Elt.make Poly.(elt.v = `Force) elt.from} )
)
(fun conf ->
let elt = conf.fmt_opts.break_struct in
if elt.v then Elt.make `Force elt.from
Expand Down Expand Up @@ -894,7 +896,8 @@ module Formatting = struct
in
Decl.choice ~names ~all ~default ~doc ~kind
(fun conf elt ->
update conf ~f:(fun f -> {f with indicate_nested_or_patterns= elt}) )
update conf ~f:(fun f -> {f with indicate_nested_or_patterns= elt})
)
(fun conf -> conf.fmt_opts.indicate_nested_or_patterns)

let infix_precedence =
Expand All @@ -921,7 +924,8 @@ module Formatting = struct
let names = ["leading-nested-match-parens"] in
Decl.flag ~names ~default ~doc ~kind ~allow_inline:false
(fun conf elt ->
update conf ~f:(fun f -> {f with leading_nested_match_parens= elt}) )
update conf ~f:(fun f -> {f with leading_nested_match_parens= elt})
)
(fun conf -> conf.fmt_opts.leading_nested_match_parens)

let let_and =
Expand Down Expand Up @@ -1456,7 +1460,7 @@ module Operational = struct
(fun conf -> conf.opr_opts.version_check)

let metaocaml =
let doc = "Enable metaocaml" in
let doc = "Enable MetaOCaml support." in
Decl.flag ~default ~names:["metaocaml"] ~doc ~kind
(fun conf elt -> update conf ~f:(fun f -> {f with metaocaml= elt}))
(fun conf -> conf.opr_opts.metaocaml)
Expand Down Expand Up @@ -1543,8 +1547,8 @@ let parse_attr {attr_name= {txt; loc= _}; attr_payload; _} =
| _ when String.is_prefix ~prefix:"ocamlformat." txt ->
Error
(`Msg
(Format.sprintf "Invalid format: Unknown suffix %S"
(String.chop_prefix_exn ~prefix:"ocamlformat." txt) ) )
(Format.sprintf "Invalid format: Unknown suffix %S"
(String.chop_prefix_exn ~prefix:"ocamlformat." txt) ) )
| _ -> Error `Ignore

let update ?(quiet = false) c ({attr_name= {txt; loc}; _} as attr) =
Expand Down

0 comments on commit 918887e

Please sign in to comment.