diff --git a/.clang-format b/.clang-format new file mode 100644 index 0000000000..2dd91a0f12 --- /dev/null +++ b/.clang-format @@ -0,0 +1,21 @@ +--- +# Deliberately minimal: every key below is here because leaving it at the +# Google default (or at the value the earlier draft of this file used) +# measurably increased the diff against WLED's existing code. Options that +# already matched Google's default, or made no measurable difference, were +# left out rather than spelled out for documentation's sake. +# +# Requires clang-format 16+ (AlignTrailingComments' Kind-based syntax below +# needs it). Verified to parse cleanly on clang-format 16, 18 and 22. +BasedOnStyle: Google +ColumnLimit: 240 # WLED convention: wide lines, not the 80-col default +AlignTrailingComments: Leave # preserves existing comment-column alignment; forcing "Never" re-collapses spacing on every touched line, breaking alignment with untouched neighbours +AllowShortCaseLabelsOnASingleLine: true # matches the `case X: doThing(); break;` style used throughout +AllowShortFunctionsOnASingleLine: Inline # keeps short wrapper/getter functions on one line, closer to existing code than Google's stricter default +AllowShortIfStatementsOnASingleLine: AllIfsAndElse # un-deprecates the old "Always" value used before; matches existing single-line if/else usage +BreakConstructorInitializers: BeforeComma # non-deprecated replacement for BreakConstructorInitializersBeforeComma +InsertNewlineAtEOF: true # text files should end with a newline +KeepEmptyLinesAtTheStartOfBlocks: true # deliberately kept in its deprecated spelling: the modern nested "KeepEmptyLines" key errors out on clang-format 16 and 18, and CodeRabbit's suggested "KeepEmptyLinesAtTopOfFunctions" is an unknown key on 14/16/18/22 alike. This old alias parses cleanly on all of them. +MaxEmptyLinesToKeep: 2 # existing code frequently uses double blank lines; Google's default of 1 would touch far more of it +ReflowComments: false # don't rewrap comment text/wording +SortIncludes: Never # WLED sometimes orders includes deliberately (platform/feature guards); alphabetising risks reordering them and breaking a build diff --git a/.gitignore b/.gitignore index 62e72a9a0a..c1174f5e2c 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,4 @@ .cache -.clang-format .direnv .DS_Store .idea diff --git a/wled00/src/.clang-format b/wled00/src/.clang-format new file mode 100644 index 0000000000..339dac8712 --- /dev/null +++ b/wled00/src/.clang-format @@ -0,0 +1,8 @@ +--- +# This directory holds vendored third-party code (src/dependencies/*: json, +# fastled_slim, espalexa, e131, dmx, ws2812fx, etc.) and generated font data +# (src/font/*), none of which follows WLED's own style. A child .clang-format +# fully replaces the parent's config for everything below it (no merging), so +# this disables formatting entirely rather than letting the root .clang-format +# reach in and reformat upstream/generated code. +DisableFormat: true