Add flag to control space around high precedence infix #2638
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hello,
With version 0.27, and specifically #2580, things like this following code are formatted a bit weird:
ocamlformat/bench/test/source.ml
Lines 7371 to 7375 in 5bac2e7
As follows:
ocamlformat/test/passing/refs.ocamlformat/extensions.ml.ref
Lines 498 to 500 in 5bac2e7
It happens that a lot of my code looks like this (in fact this code is mine 🤣 - #1371). 0.27 makes these expressions very hard to read while they are supposed to look like arithmetics (or a OCaml DSL to build an AST).
This PR proposes a flag to disable this new behaviour.
Now, note that I understand where this comes from, and I acknowledge that this is somewhat necessary: ocamlformat rewrites
some_function some_arg (a #+ b)
intosome_function some_arg a #+ b
, and this is also hard to read. Another option from this PR would be to have the following conf instead:where
compact
is the 0.27 choice and parens would do something likeso that precedence is made clear without sacrificing readability, but I have to admit I haven't quite been able to implement it with my limited knowledge of the codebase. Happy to discuss this :)