diff --git a/.clang-format b/.clang-format new file mode 100644 index 000000000..65fb6179c --- /dev/null +++ b/.clang-format @@ -0,0 +1,105 @@ +Language: Cpp +BasedOnStyle: Microsoft + +# Indentation +IndentWidth: 2 # 2 spaces per indent +AccessModifierOffset: -2 +IndentAccessModifiers: false # Align access modifiers to braces +NamespaceIndentation: All # Indent namspace contents +ConstructorInitializerIndentWidth: 2 + +# Comments which match this regex will be unformatted (and therefore can be longer or have more whitespace than other comments) +CommentPragmas: '^\*\*' + + +# Alignment +AlignConsecutiveAssignments: + Enabled: true + AcrossEmptyLines: false + AcrossComments: true + AlignCompound: true + PadOperators: true +AlignConsecutiveBitFields: + Enabled: true + AcrossEmptyLines: false + AcrossComments: true +AlignConsecutiveDeclarations: + Enabled: true + AcrossEmptyLines: false + AcrossComments: true + # For future versions of clang-format + # AlignFunctionDeclarations: false + # AlignFunctionPointers: false +AlignConsecutiveMacros: + Enabled: true + AcrossEmptyLines: false + AcrossComments: true + +# Newlines +ColumnLimit: 0 +BreakBeforeBraces: Allman # Braces on their own lines +SeparateDefinitionBlocks: Always # Separate definitions (functions etc.) with an empty line +AlwaysBreakTemplateDeclarations: true # Put template on their own lines +AllowShortBlocksOnASingleLine: Never +# On a newer version of clang-format, replace with BinPackArguments: OnePerLine +BinPackArguments: false # Don't allow multiple function arguments on the same line unless they all fit +BinPackParameters: false # Same but for parameters +PackConstructorInitializers: NextLine +AllowShortFunctionsOnASingleLine: None +BreakBeforeBinaryOperators: NonAssignment # Put binary operators after a line break, rather than before +AllowShortIfStatementsOnASingleLine: Never + +# Spaces +SpaceBeforeParens: ControlStatementsExceptControlMacros +SpaceAfterCStyleCast: true +PointerAlignment: Left + +# Includes +IncludeBlocks: Regroup # Regroup includes based on config +IncludeCategories: + - Regex: '(^"|\.hpp)' # 'local' includes + Priority: 3 + SortPriority: 0 + CaseSensitive: false + - Regex: '\/' # Library includes + Priority: 2 + SortPriority: 0 + CaseSensitive: false + - Regex: '.*' # Everything else + Priority: 1 + SortPriority: 0 + CaseSensitive: false + +# AccessModifierOffset: 0 +# AlignConsecutiveMacros: true +# IndentWidth: 2 +# ConstructorInitializerIndentWidth: 2 +# ColumnLimit: 0 +# AlignAfterOpenBracket: Align +# Standard: c++11 +# IndentAccessModifiers: true +# IndentCaseBlocks: true +# IndentCaseLabels: true +# IndentGotoLabels: true +# IndentExternBlock: Indent +# UseTab: Never +# ReflowComments: true +# QualifierAlignment: Left +# ReferenceAlignment: Pointer +# PointerAlignment: Left +# InsertBraces: true +# NamespaceIndentation: All +# LineEnding: LF +# AlwaysBreakTemplateDeclarations: true +# BinPackArguments: false +# BinPackParameters: false +# AllowShortFunctionsOnASingleLine: None +# AllowAllArgumentsOnNextLine: false +# IncludeBlocks: Regroup +# IncludeCategories: +# - Regex: '^<(resolve|tests)/' +# Priority: 1 +# - Regex: '^<[[:alnum:].]+>' +# Priority: -1 +# - Regex: '.*' +# Priority: 0 diff --git a/.github/workflows/.clang-format b/.github/workflows/.clang-format deleted file mode 100644 index b8cef3e95..000000000 --- a/.github/workflows/.clang-format +++ /dev/null @@ -1,9 +0,0 @@ -# Documentation about the style options and their meaning -# https://releases.llvm.org/12.0.0/tools/clang/docs/ClangFormatStyleOptions.html - -Language: Cpp -AccessModifierOffset: 0 -AlignConsecutiveMacros: true -BreakBeforeBraces: Linux -ColumnLimit: 150 -ConstructorInitializerIndentWidth: 2 diff --git a/CMakeLists.txt b/CMakeLists.txt index 9d4da16fa..21b77e930 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -59,10 +59,6 @@ set(CMAKE_INSTALL_RPATH ${CMAKE_INSTALL_PREFIX}/lib) # Add CMake sources from `cmake` dir list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake) -# Including clang-format cmake files to do automatic checking of formating -# TODO: Set up clang-format -#include(./cmake/clang-format) - # This will create target `doxygen` for building documentation locally. # For now, this target is intended only for developers who want to test # different documentation configurations. To have Doxygen configuration