Browse Source

Adding .clang-format and lint.sh

Luiserebii 1 year ago
parent
commit
b4383db0b9
Signed by: Luiserebii <luis@serebii.io> GPG Key ID: 3B7E2D68E27CBBCF
2 changed files with 95 additions and 0 deletions
  1. 93
    0
      .clang-format
  2. 2
    0
      scripts/lint.sh

+ 93
- 0
.clang-format View File

@@ -0,0 +1,93 @@
1
+---
2
+Language:        Cpp
3
+# BasedOnStyle:  Google
4
+# Any comments will probably be directed towards settings that I'm not 100% certain on
5
+# If no comments exist, it means I've approved it 100%
6
+AccessModifierOffset: -2 # Was -1, doubling this to mimick Google's offset logic
7
+AlignAfterOpenBracket: Align # Sure, this is probably fine, but I think I tend to use DontAlign
8
+AlignConsecutiveAssignments: false
9
+AlignConsecutiveDeclarations: false
10
+AlignEscapedNewlinesLeft: true # Sure
11
+AlignOperands:   true # Sure
12
+AlignTrailingComments: false # This was true, but I don't think I want a linter to force this
13
+AllowAllParametersOfDeclarationOnNextLine: true # Sure
14
+AllowShortBlocksOnASingleLine: false # Uncertain on this; but sure
15
+AllowShortCaseLabelsOnASingleLine: false 
16
+AllowShortFunctionsOnASingleLine: Inline # Was All, I think that only really inline should have this
17
+AllowShortIfStatementsOnASingleLine: true
18
+AllowShortLoopsOnASingleLine: true
19
+AlwaysBreakAfterDefinitionReturnType: None # A note that this is deprecated
20
+AlwaysBreakAfterReturnType: None
21
+AlwaysBreakBeforeMultilineStrings: true # Sure
22
+AlwaysBreakTemplateDeclarations: true
23
+BinPackArguments: true 
24
+BinPackParameters: true
25
+BraceWrapping:   
26
+  AfterClass:      false # Sure, I think
27
+  AfterControlStatement: false
28
+  AfterEnum:       false
29
+  AfterFunction:   false
30
+  AfterNamespace:  false
31
+  AfterObjCDeclaration: false
32
+  AfterStruct:     false
33
+  AfterUnion:      false
34
+  BeforeCatch:     false
35
+  BeforeElse:      false
36
+  IndentBraces:    false
37
+BreakBeforeBinaryOperators: None # Was None; I like the breaking before operators when things get too long
38
+BreakBeforeBraces: Attach # Sure
39
+BreakBeforeTernaryOperators: true
40
+BreakConstructorInitializersBeforeComma: false # Sure
41
+ColumnLimit:     120
42
+CommentPragmas:  '^[^ ]' # Don't mess with comments that start with chars other than space, e.g. no space after comment delimiter
43
+# # Used to be: CommentPragmas:  '^ IWYU pragma:' # OwO
44
+ConstructorInitializerAllOnOneLineOrOnePerLine: true # Sure
45
+ConstructorInitializerIndentWidth: 4 # Sure
46
+ContinuationIndentWidth: 4 # Sure
47
+Cpp11BracedListStyle: true
48
+DerivePointerAlignment: true # Sure
49
+DisableFormat:   false 
50
+ForEachMacros:   [ foreach, Q_FOREACH, BOOST_FOREACH ] # OwO
51
+IncludeCategories: 
52
+  - Regex:           '^<.*\.h>'
53
+    Priority:        1
54
+  - Regex:           '^<.*'
55
+    Priority:        2
56
+  - Regex:           '.*'
57
+    Priority:        3
58
+IndentCaseLabels: true
59
+IndentWidth:     4
60
+IndentWrappedFunctionNames: false
61
+KeepEmptyLinesAtTheStartOfBlocks: true # Was false; I'd rather keep this loose
62
+MacroBlockBegin: '' # OwO
63
+MacroBlockEnd:   '' # OwO
64
+MaxEmptyLinesToKeep: 1
65
+NamespaceIndentation: None # I'm tempted to select Inner here, but I've never quite done this
66
+ObjCBlockIndentWidth: 4 # OwO
67
+ObjCSpaceAfterProperty: false 
68
+ObjCSpaceBeforeProtocolList: false
69
+PenaltyBreakBeforeFirstCallParameter: 1 # Penalty OwO - Penalty game??? Yugioh! Zero????
70
+PenaltyBreakComment: 300
71
+PenaltyBreakFirstLessLess: 120
72
+PenaltyBreakString: 1000
73
+PenaltyExcessCharacter: 1000000
74
+PenaltyReturnTypeOnItsOwnLine: 200
75
+PointerAlignment: Left
76
+ReflowComments:  true # Sure
77
+SortIncludes:    true 
78
+SpaceAfterCStyleCast: true # Was false; this is something we want, I think
79
+SpaceBeforeAssignmentOperators: true
80
+SpaceBeforeParens: Never # Ahhh, yes, this is the option for controlling that... hm. ControlStatements option is very likely the convention, but, I will actually set this to Never due to personal preference
81
+SpaceInEmptyParentheses: false
82
+SpacesBeforeTrailingComments: 1 # Was 2; I can see how 2 might be nice, but 1 is fine
83
+SpacesInAngles:  false
84
+SpacesInContainerLiterals: false # Was true
85
+SpacesInCStyleCastParentheses: false
86
+SpacesInParentheses: false
87
+SpacesInSquareBrackets: false
88
+Standard:        Cpp03 # Was Auto
89
+TabWidth:        8
90
+UseTab:          Never
91
+...
92
+
93
+

+ 2
- 0
scripts/lint.sh View File

@@ -0,0 +1,2 @@
1
+#!/bin/bash
2
+find . -regex '.*\.\(cpp\|hpp\|cu\|c\|h\)' -exec clang-format -style=file -i {} \;

Loading…
Cancel
Save