From 157646f54cd010c8c884998319954006260f960e Mon Sep 17 00:00:00 2001 From: NRK Date: Fri, 10 Feb 2023 11:51:53 +0600 Subject: etc changes related to code-style docs * Add a "Code Style" section in CONTRIBUTING * Move .clang-format to etc/ * Add a short comment on clang-format and editorconfig file --- .clang-format | 79 --------------------------------------------------- .editorconfig | 2 ++ etc/.clang-format | 82 +++++++++++++++++++++++++++++++++++++++++++++++++++++ etc/CONTRIBUTING.md | 17 ++++++++++- 4 files changed, 100 insertions(+), 80 deletions(-) delete mode 100644 .clang-format create mode 100644 etc/.clang-format diff --git a/.clang-format b/.clang-format deleted file mode 100644 index 18bcf9c..0000000 --- a/.clang-format +++ /dev/null @@ -1,79 +0,0 @@ ---- - -Standard: c++03 - -ColumnLimit: 0 - -AccessModifierOffset: -8 -ConstructorInitializerIndentWidth: 8 -ContinuationIndentWidth: 8 -IndentCaseLabels: false -IndentGotoLabels: false -IndentPPDirectives: None -IndentWidth: 8 -IndentWrappedFunctionNames: false -NamespaceIndentation: None -TabWidth: 8 -UseTab: AlignWithSpaces - -AlignAfterOpenBracket: true -AlignConsecutiveAssignments: false -AlignConsecutiveDeclarations: false -AlignEscapedNewlines: false -AlignOperands: true -AlignTrailingComments: false -DerivePointerAlignment: true -PointerAlignment: true - -AllowAllParametersOfDeclarationOnNextLine: false -AllowShortBlocksOnASingleLine: true -AllowShortCaseLabelsOnASingleLine: false -AllowShortFunctionsOnASingleLine: None -AllowShortIfStatementsOnASingleLine: false -AllowShortLoopsOnASingleLine: false - -AlwaysBreakAfterDefinitionReturnType: None -AlwaysBreakAfterReturnType: None -AlwaysBreakBeforeMultilineStrings: false -AlwaysBreakTemplateDeclarations: false - -BinPackArguments: true -BinPackParameters: true - -BreakBeforeBraces: Custom -BraceWrapping: - AfterControlStatement: MultiLine - AfterEnum: false - AfterExternBlock: false - AfterFunction: true - AfterStruct: false - AfterUnion: false - BeforeElse: false - IndentBraces: false - SplitEmptyFunction: true - -BreakBeforeBinaryOperators: None -BreakBeforeInheritanceComma: false -BreakBeforeTernaryOperators: false -BreakConstructorInitializers: BeforeComma -BreakConstructorInitializersBeforeComma: false -BreakStringLiterals: true - -Cpp11BracedListStyle: false -MaxEmptyLinesToKeep: 1 - -ReflowComments: false - -SortIncludes: true - -SpaceAfterCStyleCast: false -SpaceBeforeAssignmentOperators: true -SpaceBeforeParens: ControlStatements -SpaceInEmptyParentheses: false -SpacesBeforeTrailingComments: 1 -SpacesInAngles: false -SpacesInCStyleCastParentheses: false -SpacesInParentheses: false -SpacesInSquareBrackets: false - -... diff --git a/.editorconfig b/.editorconfig index 72b2e5e..cbc0f4b 100644 --- a/.editorconfig +++ b/.editorconfig @@ -1,4 +1,6 @@ # EditorConfig +# See this if your editor doesn't have built-in editorconfig support: +# https://editorconfig.org/#download # apply to all files [*] diff --git a/etc/.clang-format b/etc/.clang-format new file mode 100644 index 0000000..a29be62 --- /dev/null +++ b/etc/.clang-format @@ -0,0 +1,82 @@ +# clang-format doesn't dictate the project's code style and can mess up a +# couple edge cases. However it comes quite close and can be used for fixing +# most style issues automatically on new changes via `git-clang-format`. +--- + +Standard: c++03 + +ColumnLimit: 0 + +AccessModifierOffset: -8 +ConstructorInitializerIndentWidth: 8 +ContinuationIndentWidth: 8 +IndentCaseLabels: false +IndentGotoLabels: false +IndentPPDirectives: None +IndentWidth: 8 +IndentWrappedFunctionNames: false +NamespaceIndentation: None +TabWidth: 8 +UseTab: AlignWithSpaces + +AlignAfterOpenBracket: true +AlignConsecutiveAssignments: false +AlignConsecutiveDeclarations: false +AlignEscapedNewlines: false +AlignOperands: true +AlignTrailingComments: false +DerivePointerAlignment: true +PointerAlignment: true + +AllowAllParametersOfDeclarationOnNextLine: false +AllowShortBlocksOnASingleLine: true +AllowShortCaseLabelsOnASingleLine: false +AllowShortFunctionsOnASingleLine: None +AllowShortIfStatementsOnASingleLine: false +AllowShortLoopsOnASingleLine: false + +AlwaysBreakAfterDefinitionReturnType: None +AlwaysBreakAfterReturnType: None +AlwaysBreakBeforeMultilineStrings: false +AlwaysBreakTemplateDeclarations: false + +BinPackArguments: true +BinPackParameters: true + +BreakBeforeBraces: Custom +BraceWrapping: + AfterControlStatement: MultiLine + AfterEnum: false + AfterExternBlock: false + AfterFunction: true + AfterStruct: false + AfterUnion: false + BeforeElse: false + IndentBraces: false + SplitEmptyFunction: true + +BreakBeforeBinaryOperators: None +BreakBeforeInheritanceComma: false +BreakBeforeTernaryOperators: false +BreakConstructorInitializers: BeforeComma +BreakConstructorInitializersBeforeComma: false +BreakStringLiterals: true + +Cpp11BracedListStyle: false +MaxEmptyLinesToKeep: 1 + +ReflowComments: false + +SortIncludes: true + +SpaceAfterCStyleCast: false +SpaceBeforeAssignmentOperators: true +SpaceBeforeParens: ControlStatements +SpaceInEmptyParentheses: false +SpacesBeforeTrailingComments: 1 +SpacesInAngles: false +SpacesInCStyleCastParentheses: false +SpacesInParentheses: false +SpacesInSquareBrackets: false + +... diff --git a/etc/CONTRIBUTING.md b/etc/CONTRIBUTING.md index 8d9680f..aa96068 100644 --- a/etc/CONTRIBUTING.md +++ b/etc/CONTRIBUTING.md @@ -23,7 +23,7 @@ Contribution Guideline When contributing, make sure: * Your contribution falls under nsxiv's scope and aim - * You follow the existing code style (see [.editorconfig](../.editorconfig)) + * You follow the existing code style (see the "Code Style" section below) * You open the pull request from a new branch, not from master * To avoid using force pushes, especially for bigger patches. Only use them when there's merge conflicts. @@ -44,6 +44,21 @@ to work on. You can also filter the issues via label: (Intermediate/Experienced) Issues where we require some help. +Code Style +---------- + +`nsxiv` mostly follows the [suckless code-style][sl], with a few exceptions. +If your editor supports [.editorconfig](../.editorconfig) then you'll already be +off to a good start without needing much manual intervention. Additionally we +provide a [clang-format](./.clang-format) configuration for reference, which you +may use via [`git-clang-format`][cf] to format the changes you've made (please +do not run it globally on the entire code-base since clang-format gets a decent +amount of edge cases wrong). + +[sl]: https://suckless.org/coding_style/ +[cf]: https://clang.llvm.org/docs/ClangFormat.html#git-integration + + Development workflow for maintainers ------------------------------------ -- cgit v1.2.3-54-g00ecf