3 ms·
clang-format has so many useless options and yet it cannot do normal readable argument handling. At least not according to the documented options (as of a few v
by 3836293648 4y ago
clang-format has so many useless options and yet it cannot do normal readable argument handling. At least not according to the documented options (as of a few versions back at least).
function(
arg,
arg
);
New line per argument, closing parenthesis on a new line. This is standard in most langauges, yet clang-format cannot handle it.
Then it also insists on aligning everything prettily. Most, but not all of it can be disabled though.
And lastly it doesn't do very well with tab indents. Most of it works perfectly, you just need to set both tab size and indent size, but then it decides to do its alignment thing and suddenly that line is all spaces, even the base indent.
Clang-format is honestly by far the worst formatter I've had the displeasure to fight. C/C++ still needs to be formatted manually
- SOLAR_FIELDS 4y agoI think with this kind of stuff, it should be, give me a sane set of defaults and make me change it when they don’t make sense. Rather than go to make me search and configure and have to make 100 different decisions on minutiae and exhaust my brainpower on what I would consider important but relatively low impact work in the short term
- kps 4y agoSounds like {AlignAfterOpenBracket: BlockIndent, BinPackArguments: false}
- 3836293648 4y ago(EDIT: Newlines in the code example) Oooh, that's much closer. Not perfect, but so much better. Do you have a solution for this as well? →(StructType){ →····.a = 1, →····.b = 2, →}; It's not just this scenario, but this is the worst one. It does it regardless of useTab and what's worse is that it's four spaces when both indent width and tab size are set to 8
- kps 4y agoWeirdly, initializer indentation is controlled by `ContinuationIndentWidth` rather than by `IndentWidth`. That one I would agree is a clang-format bug, or a mistaken policy decision. I haven't myself worked on a tabbed code base during clang-format's existence. You might want to look at Linux's settings for ideas, although they clearly differ from your preferences in other ways. https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/.clang-format?h=v6.3-rc7 https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/lin...