dfmt
dfmt copied to clipboard
infer format option by providing a formatted example
It would be nice if there'd be an option to infer (most of the) format options by providing an example:
void fun () {
int a = b + c;
if (a) fun();
}
The parser would infer the parameters, eg:
- space around operators
- one-liners allowed
It would reject the example if the inferred options would not be idem-potent (ie if the formatting the input via the inferred options would change the input).
The odds of me implementing this are incredibly low.
it's by no mean urgent, could be picked up later by someone else if there's more interest.
clang-format started with the idea that this is the main use case. Infer style from input file via "majority voting" and then unify the style. Turned out that an external style definition is the main use case.