diff --git a/.clang-format b/.clang-format new file mode 100644 index 000000000..7af7c0f54 --- /dev/null +++ b/.clang-format @@ -0,0 +1,63 @@ +--- +BasedOnStyle: Google +AccessModifierOffset: -2 +ConstructorInitializerIndentWidth: 2 +AlignEscapedNewlinesLeft: false +AlignTrailingComments: true +AllowAllParametersOfDeclarationOnNextLine: false +AllowShortIfStatementsOnASingleLine: false +AllowShortLoopsOnASingleLine: false +AllowShortFunctionsOnASingleLine: None +AlwaysBreakTemplateDeclarations: true +AlwaysBreakBeforeMultilineStrings: true +BreakBeforeBinaryOperators: false +BreakBeforeTernaryOperators: false +BreakConstructorInitializersBeforeComma: true +BinPackParameters: true +ColumnLimit: 120 +ConstructorInitializerAllOnOneLineOrOnePerLine: true +DerivePointerBinding: false +PointerBindsToType: true +ExperimentalAutoDetectBinPacking: false +IndentCaseLabels: true +MaxEmptyLinesToKeep: 1 +NamespaceIndentation: None +ObjCSpaceBeforeProtocolList: true +PenaltyBreakBeforeFirstCallParameter: 19 +PenaltyBreakComment: 60 +PenaltyBreakString: 1 +PenaltyBreakFirstLessLess: 1000 +PenaltyExcessCharacter: 1000 +PenaltyReturnTypeOnItsOwnLine: 90 +SpacesBeforeTrailingComments: 2 +Cpp11BracedListStyle: false +Standard: Auto +IndentWidth: 2 +TabWidth: 2 +UseTab: Never +IndentFunctionDeclarationAfterType: false +SpacesInParentheses: false +SpacesInAngles: false +SpaceInEmptyParentheses: false +SpacesInCStyleCastParentheses: false +SpaceAfterControlStatementKeyword: true +SpaceBeforeAssignmentOperators: true +ContinuationIndentWidth: 4 +SortIncludes: false +SpaceAfterCStyleCast: false + +# Configure each individual brace in BraceWrapping +BreakBeforeBraces: Custom + +# Control of individual brace wrapping cases +BraceWrapping: + AfterClass: true + AfterControlStatement: 'true' + AfterEnum: true + AfterFunction: true + AfterNamespace: true + AfterStruct: true + AfterUnion: true + BeforeCatch: true + BeforeElse: true + IndentBraces: false diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 000000000..5dc508125 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,32 @@ +--- +repos: + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v2.3.0 + hooks: + - id: check-yaml + - id: check-xml + - id: check-json + - id: end-of-file-fixer + - id: trailing-whitespace + - id: check-added-large-files + + # Python + - repo: https://github.com/psf/black + rev: 22.10.0 + hooks: + - id: black + language: python + args: [--line-length=120] + + # C++ + - repo: https://github.com/pre-commit/mirrors-clang-format + rev: v17.0.3 + hooks: + - id: clang-format + +# # YAML - still bad support for comments in YAML files +# - repo: https://github.com/jumanjihouse/pre-commit-hook-yamlfmt +# rev: 0.2.1 # or other specific tag +# hooks: +# - id: yamlfmt +# args: [--mapping, '2', --sequence, '4', --offset, '2', --width, '120'] diff --git a/docs/how_to_contribute.md b/docs/how_to_contribute.md index 8d13b16b4..e9dde7bef 100644 --- a/docs/how_to_contribute.md +++ b/docs/how_to_contribute.md @@ -14,6 +14,6 @@ Pre-commit, the format plugin, will run automatically before each commit. The sp .pre-commit-config.yaml. To activate this plugin, please run the following command in terminal and root directory: ```bash - pip install pre-commit + pip3 install pre-commit pre-commit install ```