Hi everyone,
As a part of SAOC 2023, I've been working on porting dfmt to use the AST from DMD instead of libdparse (you might have come across my weekly updates). There are a few passes in the original dfmt that seem to allow for a purely aesthetic formatting inconsistency, and I wanted some community opinion on whether these should be made available in dmdfmt, or whether it would be better to retire them.
dfmt_single_template_constraint_indent
: If set to true, indents multi-line template constraints with a single tab. The default is false. E.g.// default void foo(T)() if (is(T == char) || is(T == dchar)) // true void foo(T)() if (is(T == char) || is(T == dchar))
dfmt_single_indent
: If set to true, indents multi-line function declarations with a single tab. The default is false. E.g.// default void foo(int a, char b, string c, int d, char e, string f) {} // true void foo(int a, char b, string c, int d, char e, string f) {}
IMO, code on the following line should ideally be indented by a single tab, irrespective of the context of the newline. This ensures formatting consistency across all types of expressions. With these options, it causes the reader to flip between single tab and double tab indents across different items like if/else/for/while and function declarations/template constraints, which is quite jarring.
What do you think about this? Would it be better to maintain a single standard for indentation and not allow configuration, or should a knob be provided at the cost of consistency?