From d90c84cce2e38347f342720261fd7afb069cee3b Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Thu, 31 Oct 2024 21:53:41 +0000 Subject: [PATCH 1/3] guessed format based on style detection of https://www.clangpowertools.com/clang-format-editor.html against FX_fcn.cpp --- .clang-format | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 .clang-format diff --git a/.clang-format b/.clang-format new file mode 100644 index 0000000000..7f1a0c290c --- /dev/null +++ b/.clang-format @@ -0,0 +1,23 @@ +--- +BasedOnStyle: Google +AlignAfterOpenBracket: DontAlign +AlignConsecutiveDeclarations: Consecutive +AlignEscapedNewlines: DontAlign +AlignOperands: DontAlign +AlignTrailingComments: false +AllowAllArgumentsOnNextLine: false +AllowShortCaseLabelsOnASingleLine: true +AllowShortFunctionsOnASingleLine: None +AllowShortIfStatementsOnASingleLine: Always +AlwaysBreakBeforeMultilineStrings: false +BreakBeforeTernaryOperators: false +BreakConstructorInitializersBeforeComma: true +BreakStringLiterals: false +ColumnLimit: 240 +ContinuationIndentWidth: 2 +IndentPPDirectives: BeforeHash +KeepEmptyLinesAtTheStartOfBlocks: true +MaxEmptyLinesToKeep: 2 +ReflowComments: false +SortIncludes: Never +SpacesBeforeTrailingComments: 1 From 16c91b6dbf2ba5173021e36d3d877b1cf58cdc12 Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Thu, 31 Oct 2024 22:13:00 +0000 Subject: [PATCH 2/3] bring .clang-format under version control --- .gitignore | 1 - 1 file changed, 1 deletion(-) diff --git a/.gitignore b/.gitignore index 8f083e3f6a..cde4390744 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,4 @@ .cache -.clang-format .direnv .DS_Store .idea From 6d1cc5d70117cbef9b403bcbd6f56056dfb64fbb Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Sat, 8 Aug 2026 11:35:12 +0100 Subject: [PATCH 3/3] Trim .clang-format to a minimal, empirically-tuned rule set Pared the config down from 24 keys to 12 by measuring the formatted diff against upstream wled00 for every contested option: several of the original overrides (IndentPPDirectives: BeforeHash, SpacesBeforeTrailingComments: 1, AlignConsecutiveDeclarations: Consecutive, ...) were actively worse than Google's own default and are simply dropped rather than replaced. AlignTrailingComments: Leave is the standout keep, since it avoids re-collapsing comment-column alignment on every line a contributor happens to touch. Also fixes the two deprecated-key warnings raised on the PR, but not via CodeRabbit's suggested replacement: KeepEmptyLinesAtTopOfFunctions turns out to be an unknown key on clang-format 14, 16, 18 and 22 alike, so the old KeepEmptyLinesAtTheStartOfBlocks alias is kept deliberately (it parses cleanly across all of them). BreakConstructorInitializers is switched to its non-deprecated spelling, which is safe everywhere. Requires clang-format 16+ for AlignTrailingComments' Kind-based syntax. Adds wled00/src/.clang-format with DisableFormat: true so the root config doesn't reach into vendored third-party code (src/dependencies) or generated font data (src/font). Co-Authored-By: Claude Sonnet 5 --- .clang-format | 40 +++++++++++++++++++--------------------- wled00/src/.clang-format | 8 ++++++++ 2 files changed, 27 insertions(+), 21 deletions(-) create mode 100644 wled00/src/.clang-format diff --git a/.clang-format b/.clang-format index 7f1a0c290c..2dd91a0f12 100644 --- a/.clang-format +++ b/.clang-format @@ -1,23 +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 -AlignAfterOpenBracket: DontAlign -AlignConsecutiveDeclarations: Consecutive -AlignEscapedNewlines: DontAlign -AlignOperands: DontAlign -AlignTrailingComments: false -AllowAllArgumentsOnNextLine: false -AllowShortCaseLabelsOnASingleLine: true -AllowShortFunctionsOnASingleLine: None -AllowShortIfStatementsOnASingleLine: Always -AlwaysBreakBeforeMultilineStrings: false -BreakBeforeTernaryOperators: false -BreakConstructorInitializersBeforeComma: true -BreakStringLiterals: false -ColumnLimit: 240 -ContinuationIndentWidth: 2 -IndentPPDirectives: BeforeHash -KeepEmptyLinesAtTheStartOfBlocks: true -MaxEmptyLinesToKeep: 2 -ReflowComments: false -SortIncludes: Never -SpacesBeforeTrailingComments: 1 +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/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