Skip to content

Commit 8c37a26

Browse files
committed
Add .clang-format and apply
1 parent d110d93 commit 8c37a26

3 files changed

Lines changed: 246 additions & 230 deletions

File tree

.clang-format

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
---
2+
# C++ Code Style Configuration for clang-format
3+
4+
# Base style
5+
BasedOnStyle: LLVM
6+
7+
# Indentation
8+
IndentWidth: 4
9+
UseTab: Never
10+
NamespaceIndentation: None
11+
AccessModifierOffset: -4
12+
13+
# Line length
14+
ColumnLimit: 120
15+
16+
# Braces (K&R style)
17+
BreakBeforeBraces: Attach
18+
InsertBraces: true
19+
20+
# Pointers and references (left-aligned with type)
21+
PointerAlignment: Left
22+
ReferenceAlignment: Left
23+
DerivePointerAlignment: false
24+
25+
# Templates
26+
SpaceAfterTemplateKeyword: false
27+
28+
# Function parameters and arguments
29+
# Use BlockIndent for minimal diffs - avoids vertical alignment that changes unrelated lines
30+
AlignAfterOpenBracket: BlockIndent
31+
BinPackParameters: false
32+
BinPackArguments: false
33+
AllowAllParametersOfDeclarationOnNextLine: false
34+
35+
# Constructor initializers
36+
BreakConstructorInitializers: BeforeComma
37+
ConstructorInitializerIndentWidth: 4
38+
PackConstructorInitializers: Never
39+
40+
# Short functions (allow inline getters)
41+
AllowShortFunctionsOnASingleLine: Inline
42+
AllowShortIfStatementsOnASingleLine: Never
43+
AllowShortLoopsOnASingleLine: false
44+
45+
# Include sorting
46+
SortIncludes: CaseSensitive
47+
IncludeBlocks: Regroup
48+
IncludeCategories:
49+
# Main header (matched by file name)
50+
- Regex: '^".*"$'
51+
Priority: 1
52+
# Standard library
53+
- Regex: '^<.*>'
54+
Priority: 2
55+
56+
# Spaces
57+
SpaceBeforeParens: ControlStatements
58+
SpaceInEmptyParentheses: false
59+
SpacesInContainerLiterals: false
60+
61+
# Alignment (minimize to avoid unrelated line changes in diffs)
62+
AlignConsecutiveAssignments: None
63+
AlignConsecutiveDeclarations: None
64+
AlignOperands: DontAlign
65+
66+
# Other formatting
67+
AlwaysBreakTemplateDeclarations: Yes
68+
KeepEmptyLinesAtTheStartOfBlocks: false
69+
MaxEmptyLinesToKeep: 1
70+
71+
# C++23 (using Latest for clang-format compatibility)
72+
Standard: Latest

0 commit comments

Comments
 (0)