Define a diff-friendly profile
Closes #1958
This is a new profile I wanted to work on for quite some time. It doesn't impact existing profiles.
New values are added to a few existing options, that users can set individually, although I advise to just use this profile if they want this behavior.
-
if-then-else = vertical(#2174) -
break-cases = vertical(#2176)
It also adds new fields to the Conf.fmt_opts type that should not become new options, this is just how we implement behavior switches in ocamlformat instead of matching on the profile.
-
unfold-let-binding : bool
I just tried this on some code and really like it 🙂
Some notes:
- val ( and+ )
- : 'a Cmdliner.Term.t
- -> 'b Cmdliner.Term.t
- -> ('a * 'b) Cmdliner.Term.t
+ val ( and+ ) :
+ 'a Cmdliner.Term.t -> 'b Cmdliner.Term.t -> ('a * 'b) Cmdliner.Term.t
The former seems more diff friendly?
- Fmt_tty.setup_std_outputs ();
- Logs.set_level log_level;
- Logs.set_reporter (Logs_fmt.reporter ~app:Fmt.stdout ());
+ Fmt_tty.setup_std_outputs () ;
+ Logs.set_level log_level ;
+ Logs.set_reporter (Logs_fmt.reporter ~app:Fmt.stdout ())
Why add spaces there? It doesn't seem to improve the diff. I'm assuming this is something coming from the sparse profile, but should we use the default config here?
let handle_errors = function
- | Ok () -> if Logs.err_count () > 0 then 3 else 0
+ | Ok () ->
+ if Logs.err_count () > 0 then
+ 3
+ else
+ 0
| Error err ->
- Logs.err (fun m -> m "%s" (Error.to_string err));
+ Logs.err (fun m -> m "%s" (Error.to_string err)) ;
error_to_code err
This does seem to be a regression, we don't need two level of indentation here I think.
let term =
let open Common.Syntax in
- let+ _term = Common.term
+ let+ _term =
+ Common.term
and+ name =
- let doc = "The name to greet." in
- let docv = "NAME" in
+ let doc =
+ "The name to greet."
+ in
+ let docv =
+ "NAME"
+ in
That indeed could improve the diff, but perhaps breaking every let binding into three lines is a bit much? 😅
My feedback aside, thanks a lot for working on this @gpetiot, I'm very happy to see a profile that uses objective guidelines as an alternative to the other profiles.