Skip to content

Commit 8d63ea7

Browse files
authored
Expose let_binding_deindent_fun flag (#2521)
1 parent b8b0956 commit 8d63ea7

File tree

6 files changed

+21
-0
lines changed

6 files changed

+21
-0
lines changed

CHANGES.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ profile. This started with version 0.26.0.
88

99
### Changed
1010

11+
- Added `let-binding-deindent-fun` flag (#2521, @henrytill)
1112
- Added back the flag `--disable-outside-detected-project` (#2439, @gpetiot)
1213
It was removed in version 0.22.
1314
- \* Consistent formatting of comments (#2371, @Julow)

doc/manpage_ocamlformat.mld

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,9 @@ OPTIONS (CODE FORMATTING STYLE)
248248
in a single line. sparse will always break between them. The
249249
default value is compact.
250250

251+
--let-binding-deindent-fun
252+
Deindent a line beginning with `fun`. The flag is set by default.
253+
251254
--let-binding-indent=COLS
252255
Indentation of let binding expressions (COLS columns) if they do
253256
not fit on a single line. The default value is 2. Cannot be set in
@@ -321,6 +324,9 @@ OPTIONS (CODE FORMATTING STYLE)
321324
--no-leading-nested-match-parens
322325
Unset leading-nested-match-parens.
323326

327+
--no-let-binding-deindent-fun
328+
Unset let-binding-deindent-fun.
329+
324330
--no-ocp-indent-compat
325331
Unset ocp-indent-compat.
326332

lib/Conf.ml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -953,6 +953,14 @@ module Formatting = struct
953953
update conf ~f:(fun f -> {f with let_binding_indent= elt}) )
954954
(fun conf -> conf.fmt_opts.let_binding_indent)
955955

956+
let let_binding_deindent_fun =
957+
let doc = "Deindent a line beginning with `fun`." in
958+
let names = ["let-binding-deindent-fun"] in
959+
Decl.flag ~names ~default ~doc ~kind
960+
(fun conf elt ->
961+
update conf ~f:(fun f -> {f with let_binding_deindent_fun= elt}) )
962+
(fun conf -> conf.fmt_opts.let_binding_deindent_fun)
963+
956964
let let_binding_spacing =
957965
let doc = "Spacing between let binding." in
958966
let names = ["let-binding-spacing"] in
@@ -1334,6 +1342,7 @@ module Formatting = struct
13341342
; elt leading_nested_match_parens
13351343
; elt let_and
13361344
; elt let_binding_indent
1345+
; elt let_binding_deindent_fun
13371346
; elt let_binding_spacing
13381347
; elt let_module
13391348
; elt line_endings

test/cli/print_config.t

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ No redundant values:
5555
leading-nested-match-parens=false (profile conventional (file .ocamlformat:1))
5656
let-and=compact (profile conventional (file .ocamlformat:1))
5757
let-binding-indent=2 (profile conventional (file .ocamlformat:1))
58+
let-binding-deindent-fun=true (profile conventional (file .ocamlformat:1))
5859
let-binding-spacing=compact (profile conventional (file .ocamlformat:1))
5960
let-module=compact (profile conventional (file .ocamlformat:1))
6061
line-endings=lf (profile conventional (file .ocamlformat:1))
@@ -133,6 +134,7 @@ Redundant values from the conventional profile:
133134
leading-nested-match-parens=false (profile conventional (file .ocamlformat:1))
134135
let-and=compact (profile conventional (file .ocamlformat:1))
135136
let-binding-indent=2 (profile conventional (file .ocamlformat:1))
137+
let-binding-deindent-fun=true (profile conventional (file .ocamlformat:1))
136138
let-binding-spacing=compact (profile conventional (file .ocamlformat:1))
137139
let-module=compact (profile conventional (file .ocamlformat:1))
138140
line-endings=lf (profile conventional (file .ocamlformat:1))
@@ -211,6 +213,7 @@ Redundant values from the ocamlformat profile:
211213
leading-nested-match-parens=false (profile ocamlformat (file .ocamlformat:1))
212214
let-and=compact (profile ocamlformat (file .ocamlformat:1))
213215
let-binding-indent=2 (profile ocamlformat (file .ocamlformat:1))
216+
let-binding-deindent-fun=true (profile ocamlformat (file .ocamlformat:1))
214217
let-binding-spacing=compact (profile ocamlformat (file .ocamlformat:1))
215218
let-module=compact (profile ocamlformat (file .ocamlformat:1))
216219
line-endings=lf (profile ocamlformat (file .ocamlformat:1))

test/passing/tests/print_config.ml.err

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ infix-precedence=indent (profile ocamlformat (file tests/.ocamlformat:1))
4040
leading-nested-match-parens=false (profile ocamlformat (file tests/.ocamlformat:1))
4141
let-and=compact (profile ocamlformat (file tests/.ocamlformat:1))
4242
let-binding-indent=2 (profile ocamlformat (file tests/.ocamlformat:1))
43+
let-binding-deindent-fun=true (profile ocamlformat (file tests/.ocamlformat:1))
4344
let-binding-spacing=compact (profile ocamlformat (file tests/.ocamlformat:1))
4445
let-module=compact (profile ocamlformat (file tests/.ocamlformat:1))
4546
line-endings=lf (profile ocamlformat (file tests/.ocamlformat:1))

test/passing/tests/verbose1.ml.err

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ infix-precedence=indent (profile ocamlformat (file tests/.ocamlformat:1))
4040
leading-nested-match-parens=false (profile ocamlformat (file tests/.ocamlformat:1))
4141
let-and=compact (profile ocamlformat (file tests/.ocamlformat:1))
4242
let-binding-indent=2 (profile ocamlformat (file tests/.ocamlformat:1))
43+
let-binding-deindent-fun=true (profile ocamlformat (file tests/.ocamlformat:1))
4344
let-binding-spacing=compact (profile ocamlformat (file tests/.ocamlformat:1))
4445
let-module=compact (profile ocamlformat (file tests/.ocamlformat:1))
4546
line-endings=lf (profile ocamlformat (file tests/.ocamlformat:1))

0 commit comments

Comments
 (0)