Skip to content

Commit 2c11728

Browse files
committed
Add clang-format
1 parent b4e525a commit 2c11728

File tree

3 files changed

+112
-0
lines changed

3 files changed

+112
-0
lines changed

Diff for: .clang-format

+71
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
---
2+
Language: Cpp
3+
BasedOnStyle: LLVM
4+
Standard: Auto
5+
IndentWidth: 4
6+
TabWidth: 4
7+
UseTab: Never
8+
NamespaceIndentation: Inner
9+
PointerAlignment: Left
10+
ColumnLimit: 120
11+
SortIncludes: true
12+
ReflowComments: true
13+
ConstructorInitializerAllOnOneLineOrOnePerLine: true
14+
15+
# AccessModifierOffset: -2
16+
# ConstructorInitializerIndentWidth: 4
17+
# AlignEscapedNewlinesLeft: false
18+
# AlignTrailingComments: true
19+
# AllowAllParametersOfDeclarationOnNextLine: true
20+
# AllowShortBlocksOnASingleLine: false
21+
# AllowShortCaseLabelsOnASingleLine: false
22+
# AllowShortIfStatementsOnASingleLine: false
23+
# AllowShortLoopsOnASingleLine: false
24+
# AllowShortFunctionsOnASingleLine: All
25+
# AlwaysBreakAfterDefinitionReturnType: false
26+
# AlwaysBreakTemplateDeclarations: false
27+
# AlwaysBreakBeforeMultilineStrings: false
28+
# BreakBeforeBinaryOperators: None
29+
# BreakBeforeTernaryOperators: true
30+
# BreakConstructorInitializersBeforeComma: false
31+
# BinPackParameters: true
32+
# ColumnLimit: 80
33+
# ConstructorInitializerAllOnOneLineOrOnePerLine: false
34+
# DerivePointerAlignment: false
35+
# ExperimentalAutoDetectBinPacking: false
36+
# IndentCaseLabels: false
37+
# IndentWrappedFunctionNames: false
38+
# IndentFunctionDeclarationAfterType: false
39+
# MaxEmptyLinesToKeep: 1
40+
# KeepEmptyLinesAtTheStartOfBlocks: true
41+
# NamespaceIndentation: None
42+
# ObjCSpaceAfterProperty: false
43+
# ObjCSpaceBeforeProtocolList: true
44+
# PenaltyBreakBeforeFirstCallParameter: 19
45+
# PenaltyBreakComment: 300
46+
# PenaltyBreakString: 1000
47+
# PenaltyBreakFirstLessLess: 120
48+
# PenaltyExcessCharacter: 1000000
49+
# PenaltyReturnTypeOnItsOwnLine: 60
50+
# PointerAlignment: Right
51+
# SpacesBeforeTrailingComments: 1
52+
# Cpp11BracedListStyle: true
53+
# Standard: Cpp11
54+
# IndentWidth: 2
55+
# TabWidth: 8
56+
# UseTab: Never
57+
# BreakBeforeBraces: Attach
58+
# SpacesInParentheses: false
59+
# SpacesInSquareBrackets: false
60+
# SpacesInAngles: false
61+
# SpaceInEmptyParentheses: false
62+
# SpacesInCStyleCastParentheses: false
63+
# SpaceAfterCStyleCast: false
64+
# SpacesInContainerLiterals: true
65+
# SpaceBeforeAssignmentOperators: true
66+
# ContinuationIndentWidth: 4
67+
# CommentPragmas: '^ IWYU pragma:'
68+
# ForEachMacros: [ foreach, Q_FOREACH, BOOST_FOREACH ]
69+
# SpaceBeforeParens: ControlStatements
70+
# DisableFormat: false
71+
# ...

Diff for: .editorconfig

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# http://editorconfig.org
2+
root = true
3+
4+
[*]
5+
indent_style = space
6+
indent_size = 4
7+
charset = utf-8
8+
trim_trailing_whitespace = true
9+
insert_final_newline = true
10+
11+
[*.md]
12+
trim_trailing_whitespace = false
13+
14+
# CMake files
15+
[*.{txt,cmake}]
16+
indent_style = tab

Diff for: format-project.sh

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/bin/sh
2+
3+
# Takes each line as being a filename, turns it into a null-delimited string
4+
# and hands it to xargs -0 to pass to clang-format efficiently (because running
5+
# clang-format once for each file is very slow)
6+
run_clang_format_on_input_lines() {
7+
(while read fn; do
8+
printf "%s\0" "$fn"
9+
done) | xargs -0 clang-format -style=file -i
10+
}
11+
12+
(
13+
cd $(dirname $0)
14+
15+
(
16+
cd include
17+
ls *.h | run_clang_format_on_input_lines
18+
)
19+
20+
(
21+
cd src
22+
ls *.cpp | run_clang_format_on_input_lines
23+
)
24+
25+
)

0 commit comments

Comments
 (0)