Skip to content

Commit 63485b3

Browse files
committed
formatting: add .clang-format config file
Fvwm has had a long history, with contributions from many people over the years. As a result the code formatting which has crept in is varied -- both in terms of whitespace, indentation, etc., with there being mass inconsistencies all over the code base. Even as far back as 2006 (see commit: 1c9e17f), there was an attempt at reformatting some of FvwmButton's code, but not all of it. Thankfully, technology exists to bring consistency to this automatically. clang-format (from llvm) is one example, but it seems to do the job well enough. This definition cribs from FreeBSD's style, which isn't too far off the codebase as it stands at the moment.
1 parent 53f6c8d commit 63485b3

File tree

1 file changed

+170
-20
lines changed

1 file changed

+170
-20
lines changed

.clang-format

Lines changed: 170 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,183 @@
1-
---
1+
# Basic .clang-format
2+
---
3+
BasedOnStyle: WebKit
24
AlignAfterOpenBracket: DontAlign
5+
AlignArrayOfStructures: Left
36
AlignConsecutiveAssignments: true
47
AlignConsecutiveDeclarations: true
5-
AlignEscapedNewlinesLeft: true
6-
AlignOperands: true
8+
AlignEscapedNewlines: Left
9+
AlignOperands: false
710
AlignTrailingComments: true
8-
AllowShortBlocksOnASingleLine: false
11+
AllowAllArgumentsOnNextLine: false
12+
AllowAllParametersOfDeclarationOnNextLine: false
13+
AllowShortBlocksOnASingleLine: Never
914
AllowShortCaseLabelsOnASingleLine: false
10-
AllowShortFunctionsOnASingleLine: None
11-
AllowShortIfStatementsOnASingleLine: false
15+
AllowShortFunctionsOnASingleLine: InlineOnly
16+
AllowShortIfStatementsOnASingleLine: Never
1217
AllowShortLoopsOnASingleLine: false
13-
AlwaysBreakAfterReturnType: All
14-
BasedOnStyle: LLVM
18+
AlwaysBreakAfterReturnType: TopLevelDefinitions
19+
AlwaysBreakBeforeMultilineStrings: false
20+
AlwaysBreakTemplateDeclarations: MultiLine
1521
BinPackArguments: true
1622
BinPackParameters: true
17-
BreakAfterJavaFieldAnnotations: true
18-
BreakBeforeBinaryOperators: NonAssignment
19-
BreakBeforeBraces: Mozilla
20-
ColumnLimit: 80
21-
ContinuationIndentWidth: 4
23+
BreakBeforeBinaryOperators: None
24+
BreakBeforeBraces: WebKit
25+
BreakBeforeTernaryOperators: false
26+
# TODO: BreakStringLiterals can cause very strange formatting so turn it off?
27+
BreakStringLiterals: false
28+
# Prefer:
29+
# some_var = function(arg1,
30+
# arg2)
31+
# over:
32+
# some_var =
33+
# function(arg1, arg2)
34+
PenaltyBreakAssignment: 100
35+
# Prefer:
36+
# some_long_function(arg1, arg2
37+
# arg3)
38+
# over:
39+
# some_long_function(
40+
# arg1, arg2, arg3)
41+
PenaltyBreakBeforeFirstCallParameter: 100
42+
CompactNamespaces: true
2243
DerivePointerAlignment: false
23-
ExperimentalAutoDetectBinPacking: false
24-
IndentWidth: 8
44+
DisableFormat: false
45+
ForEachMacros:
46+
- ARB_ARRFOREACH
47+
- ARB_ARRFOREACH_REVWCOND
48+
- ARB_ARRFOREACH_REVERSE
49+
- ARB_FOREACH
50+
- ARB_FOREACH_FROM
51+
- ARB_FOREACH_SAFE
52+
- ARB_FOREACH_REVERSE
53+
- ARB_FOREACH_REVERSE_FROM
54+
- ARB_FOREACH_REVERSE_SAFE
55+
- BIT_FOREACH_ISCLR
56+
- BIT_FOREACH_ISSET
57+
- CPU_FOREACH
58+
- CPU_FOREACH_ISCLR
59+
- CPU_FOREACH_ISSET
60+
- FOREACH_THREAD_IN_PROC
61+
- FOREACH_PROC_IN_SYSTEM
62+
- FOREACH_PRISON_CHILD
63+
- FOREACH_PRISON_DESCENDANT
64+
- FOREACH_PRISON_DESCENDANT_LOCKED
65+
- FOREACH_PRISON_DESCENDANT_LOCKED_LEVEL
66+
- MNT_VNODE_FOREACH_ALL
67+
- MNT_VNODE_FOREACH_ACTIVE
68+
- RB_FOREACH
69+
- RB_FOREACH_FROM
70+
- RB_FOREACH_SAFE
71+
- RB_FOREACH_REVERSE
72+
- RB_FOREACH_REVERSE_FROM
73+
- RB_FOREACH_REVERSE_SAFE
74+
- SLIST_FOREACH
75+
- SLIST_FOREACH_FROM
76+
- SLIST_FOREACH_FROM_SAFE
77+
- SLIST_FOREACH_SAFE
78+
- SLIST_FOREACH_PREVPTR
79+
- SPLAY_FOREACH
80+
- LIST_FOREACH
81+
- LIST_FOREACH_FROM
82+
- LIST_FOREACH_FROM_SAFE
83+
- LIST_FOREACH_SAFE
84+
- STAILQ_FOREACH
85+
- STAILQ_FOREACH_FROM
86+
- STAILQ_FOREACH_FROM_SAFE
87+
- STAILQ_FOREACH_SAFE
88+
- TAILQ_FOREACH
89+
- TAILQ_FOREACH_FROM
90+
- TAILQ_FOREACH_FROM_SAFE
91+
- TAILQ_FOREACH_REVERSE
92+
- TAILQ_FOREACH_REVERSE_FROM
93+
- TAILQ_FOREACH_REVERSE_FROM_SAFE
94+
- TAILQ_FOREACH_REVERSE_SAFE
95+
- TAILQ_FOREACH_SAFE
96+
- VM_MAP_ENTRY_FOREACH
97+
- VM_PAGE_DUMP_FOREACH
98+
IndentCaseLabels: false
99+
IndentPPDirectives: None
25100
Language: Cpp
26-
NamespaceIndentation: All
101+
NamespaceIndentation: None
27102
PointerAlignment: Right
28-
PointerBindsToType: false
29-
ReflowComments: true
30-
SortIncludes: true
103+
ContinuationIndentWidth: 4
104+
IndentWidth: 8
31105
TabWidth: 8
106+
ColumnLimit: 80
32107
UseTab: Always
33-
...
108+
SpaceAfterCStyleCast: false
109+
IncludeBlocks: Regroup
110+
IncludeCategories:
111+
- Regex: '^\"config\.h\"'
112+
Priority: 1
113+
SortPriority: 1
114+
- Regex: '^\"opt_.*\.h\"'
115+
Priority: 1
116+
SortPriority: 10
117+
- Regex: '^<sys/cdefs\.h>'
118+
Priority: 2
119+
SortPriority: 20
120+
- Regex: '^<sys/types\.h>'
121+
Priority: 2
122+
SortPriority: 21
123+
- Regex: '^<sys/param\.h>'
124+
Priority: 2
125+
SortPriority: 22
126+
- Regex: '^<sys/systm\.h>'
127+
Priority: 2
128+
SortPriority: 23
129+
- Regex: '^<sys.*/'
130+
Priority: 2
131+
SortPriority: 24
132+
- Regex: '\"libs\/.*\.h\"'
133+
Priority: 3
134+
SortPriority: 15
135+
- Regex: '^<[^/].*\.h'
136+
Priority: 9
137+
SortPriority: 90
138+
- Regex: '^\".*\.h\"'
139+
Priority: 10
140+
SortPriority: 100
141+
# LLVM's header include ordering style is almost the exact opposite of ours.
142+
# Unfortunately, they have hard-coded their preferences into clang-format.
143+
# Clobbering this regular expression to avoid matching prevents non-system
144+
# headers from being forcibly moved to the top of the include list.
145+
# http://llvm.org/docs/CodingStandards.html#include-style
146+
IncludeIsMainRegex: 'BLAH_DONT_MATCH_ANYTHING'
147+
# FIXME: We want SortIncludes to be "true", however, enabling this exposes
148+
# bugs in how headers in fvwm are including each other, leading to compilation
149+
# failures. Disable for now until this is fixed.
150+
SortIncludes: false
151+
KeepEmptyLinesAtTheStartOfBlocks: true
152+
TypenameMacros:
153+
- ARB_ELMTYPE
154+
- ARB_HEAD
155+
- ARB8_HEAD
156+
- ARB16_HEAD
157+
- ARB32_HEAD
158+
- ARB_ENTRY
159+
- ARB8_ENTRY
160+
- ARB16_ENTRY
161+
- ARB32_ENTRY
162+
- LIST_CLASS_ENTRY
163+
- LIST_CLASS_HEAD
164+
- LIST_ENTRY
165+
- LIST_HEAD
166+
- QUEUE_TYPEOF
167+
- RB_ENTRY
168+
- RB_HEAD
169+
- SLIST_CLASS_HEAD
170+
- SLIST_CLASS_ENTRY
171+
- SLIST_HEAD
172+
- SLIST_ENTRY
173+
- SMR_POINTER
174+
- SPLAY_ENTRY
175+
- SPLAY_HEAD
176+
- STAILQ_CLASS_ENTRY
177+
- STAILQ_CLASS_HEAD
178+
- STAILQ_ENTRY
179+
- STAILQ_HEAD
180+
- TAILQ_CLASS_ENTRY
181+
- TAILQ_CLASS_HEAD
182+
- TAILQ_ENTRY
183+
- TAILQ_HEAD

0 commit comments

Comments
 (0)