🔧 chore(cpp): trim clang-format to intentional google deviations

- keep only the options that differ from Google style, each annotated with
  the Google default, so every override carries its own rationale
- switch to Allman braces and a 120 column limit; short functions now
  collapse only when declared inline
- dropped overrides fall back to Google behaviour, which turns include
  sorting, argument binpacking, comment reflow and namespace comment
  fixing back on
- drop a stray trailing blank line in .clangd
This commit is contained in:
csh
2026-07-29 15:45:48 +08:00
parent 40a9885eb4
commit 9ef45155dd
2 changed files with 7 additions and 44 deletions
+7 -43
View File
@@ -2,46 +2,10 @@
Language: Cpp
BasedOnStyle: Google
# Keep consistent with the repo-wide 100 char guidance (adjust per-project if needed).
ColumnLimit: 100
IndentWidth: 4
AccessModifierOffset: -4
AlignEscapedNewlines: Left
AlignTrailingComments: false
AllowAllParametersOfDeclarationOnNextLine: false
AllowShortFunctionsOnASingleLine: All
AlwaysBreakTemplateDeclarations: Yes
BinPackArguments: false
BinPackParameters: false
BraceWrapping:
AfterCaseLabel: true
AfterUnion: true
AfterExternBlock: false
BreakBeforeTernaryOperators: false
BreakConstructorInitializers: AfterColon
BreakInheritanceList: AfterColon
CommentPragmas: "suppress"
ConstructorInitializerAllOnOneLineOrOnePerLine: true
Cpp11BracedListStyle: false
FixNamespaceComments: false
IncludeBlocks: Regroup
IncludeCategories:
- Regex: '^.*(precomp|pch|stdafx)'
Priority: -1
- Regex: '^".*"'
Priority: 1
- Regex: '^<.*>'
Priority: 2
- Regex: '.*'
Priority: 3
KeepEmptyLinesAtTheStartOfBlocks: false
MacroBlockBegin: "BEGIN_TEST_METHOD_PROPERTIES|BEGIN_MODULE|BEGIN_TEST_CLASS|BEGIN_TEST_METHOD"
MacroBlockEnd: "END_TEST_METHOD_PROPERTIES|END_MODULE|END_TEST_CLASS|END_TEST_METHOD"
NamespaceIndentation: None
PointerAlignment: Left
ReflowComments: false
SortIncludes: false
SpaceAfterTemplateKeyword: false
SpacesInAngles: false
SpacesInContainerLiterals: false
# --- intentional deviations from Google C++ defaults ---
ColumnLimit: 120 # Google: 80
IndentWidth: 4 # Google: 2
TabWidth: 4 # Google/LLVM: 8UseTab: Never 时几乎无感,与缩进对齐)
AccessModifierOffset: -4 # Google: -1(配合 IndentWidth 4,使 public/private 与 class 同级)
BreakBeforeBraces: Allman # Google: Attach
AllowShortFunctionsOnASingleLine: Inline # 需要显示Inline
-1
View File
@@ -22,4 +22,3 @@ CompileFlags:
Add:
- "-std=c17"
Compiler: clang