Skip to content

Commit

Permalink
Expose let_binding_deindent_fun flag (#2521)
Browse files Browse the repository at this point in the history
  • Loading branch information
henrytill authored Feb 7, 2024
1 parent b8b0956 commit 8d63ea7
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ profile. This started with version 0.26.0.

### Changed

- Added `let-binding-deindent-fun` flag (#2521, @henrytill)
- Added back the flag `--disable-outside-detected-project` (#2439, @gpetiot)
It was removed in version 0.22.
- \* Consistent formatting of comments (#2371, @Julow)
Expand Down
6 changes: 6 additions & 0 deletions doc/manpage_ocamlformat.mld
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,9 @@ OPTIONS (CODE FORMATTING STYLE)
in a single line. sparse will always break between them. The
default value is compact.

--let-binding-deindent-fun
Deindent a line beginning with `fun`. The flag is set by default.

--let-binding-indent=COLS
Indentation of let binding expressions (COLS columns) if they do
not fit on a single line. The default value is 2. Cannot be set in
Expand Down Expand Up @@ -321,6 +324,9 @@ OPTIONS (CODE FORMATTING STYLE)
--no-leading-nested-match-parens
Unset leading-nested-match-parens.

--no-let-binding-deindent-fun
Unset let-binding-deindent-fun.

--no-ocp-indent-compat
Unset ocp-indent-compat.

Expand Down
9 changes: 9 additions & 0 deletions lib/Conf.ml
Original file line number Diff line number Diff line change
Expand Up @@ -953,6 +953,14 @@ module Formatting = struct
update conf ~f:(fun f -> {f with let_binding_indent= elt}) )
(fun conf -> conf.fmt_opts.let_binding_indent)

let let_binding_deindent_fun =
let doc = "Deindent a line beginning with `fun`." in
let names = ["let-binding-deindent-fun"] in
Decl.flag ~names ~default ~doc ~kind
(fun conf elt ->
update conf ~f:(fun f -> {f with let_binding_deindent_fun= elt}) )
(fun conf -> conf.fmt_opts.let_binding_deindent_fun)

let let_binding_spacing =
let doc = "Spacing between let binding." in
let names = ["let-binding-spacing"] in
Expand Down Expand Up @@ -1334,6 +1342,7 @@ module Formatting = struct
; elt leading_nested_match_parens
; elt let_and
; elt let_binding_indent
; elt let_binding_deindent_fun
; elt let_binding_spacing
; elt let_module
; elt line_endings
Expand Down
3 changes: 3 additions & 0 deletions test/cli/print_config.t
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ No redundant values:
leading-nested-match-parens=false (profile conventional (file .ocamlformat:1))
let-and=compact (profile conventional (file .ocamlformat:1))
let-binding-indent=2 (profile conventional (file .ocamlformat:1))
let-binding-deindent-fun=true (profile conventional (file .ocamlformat:1))
let-binding-spacing=compact (profile conventional (file .ocamlformat:1))
let-module=compact (profile conventional (file .ocamlformat:1))
line-endings=lf (profile conventional (file .ocamlformat:1))
Expand Down Expand Up @@ -133,6 +134,7 @@ Redundant values from the conventional profile:
leading-nested-match-parens=false (profile conventional (file .ocamlformat:1))
let-and=compact (profile conventional (file .ocamlformat:1))
let-binding-indent=2 (profile conventional (file .ocamlformat:1))
let-binding-deindent-fun=true (profile conventional (file .ocamlformat:1))
let-binding-spacing=compact (profile conventional (file .ocamlformat:1))
let-module=compact (profile conventional (file .ocamlformat:1))
line-endings=lf (profile conventional (file .ocamlformat:1))
Expand Down Expand Up @@ -211,6 +213,7 @@ Redundant values from the ocamlformat profile:
leading-nested-match-parens=false (profile ocamlformat (file .ocamlformat:1))
let-and=compact (profile ocamlformat (file .ocamlformat:1))
let-binding-indent=2 (profile ocamlformat (file .ocamlformat:1))
let-binding-deindent-fun=true (profile ocamlformat (file .ocamlformat:1))
let-binding-spacing=compact (profile ocamlformat (file .ocamlformat:1))
let-module=compact (profile ocamlformat (file .ocamlformat:1))
line-endings=lf (profile ocamlformat (file .ocamlformat:1))
Expand Down
1 change: 1 addition & 0 deletions test/passing/tests/print_config.ml.err
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ infix-precedence=indent (profile ocamlformat (file tests/.ocamlformat:1))
leading-nested-match-parens=false (profile ocamlformat (file tests/.ocamlformat:1))
let-and=compact (profile ocamlformat (file tests/.ocamlformat:1))
let-binding-indent=2 (profile ocamlformat (file tests/.ocamlformat:1))
let-binding-deindent-fun=true (profile ocamlformat (file tests/.ocamlformat:1))
let-binding-spacing=compact (profile ocamlformat (file tests/.ocamlformat:1))
let-module=compact (profile ocamlformat (file tests/.ocamlformat:1))
line-endings=lf (profile ocamlformat (file tests/.ocamlformat:1))
Expand Down
1 change: 1 addition & 0 deletions test/passing/tests/verbose1.ml.err
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ infix-precedence=indent (profile ocamlformat (file tests/.ocamlformat:1))
leading-nested-match-parens=false (profile ocamlformat (file tests/.ocamlformat:1))
let-and=compact (profile ocamlformat (file tests/.ocamlformat:1))
let-binding-indent=2 (profile ocamlformat (file tests/.ocamlformat:1))
let-binding-deindent-fun=true (profile ocamlformat (file tests/.ocamlformat:1))
let-binding-spacing=compact (profile ocamlformat (file tests/.ocamlformat:1))
let-module=compact (profile ocamlformat (file tests/.ocamlformat:1))
line-endings=lf (profile ocamlformat (file tests/.ocamlformat:1))
Expand Down

0 comments on commit 8d63ea7

Please sign in to comment.