From 067afdc2377ad9bdf921cb0ca2ff2a645d8954a5 Mon Sep 17 00:00:00 2001 From: Eduard Iten Date: Wed, 9 Jul 2025 08:45:26 +0200 Subject: [PATCH] Added .vscode adn .clang-format --- .clang-format | 144 ++++++++++++++++++++++++++++++++++++++++++ .gitignore | 4 +- .vscode/settings.json | 6 ++ 3 files changed, 152 insertions(+), 2 deletions(-) create mode 100644 .clang-format create mode 100644 .vscode/settings.json diff --git a/.clang-format b/.clang-format new file mode 100644 index 0000000..e45a924 --- /dev/null +++ b/.clang-format @@ -0,0 +1,144 @@ +# Zephyr Project .clang-format configuration +# Based on Linux kernel style with Zephyr-specific adaptations + +# Use LLVM as the base style and customize from there +BasedOnStyle: LLVM + +# Language settings +Language: Cpp +Standard: c11 + +# Indentation settings +IndentWidth: 8 +TabWidth: 8 +UseTab: ForIndentation + +# Line length +ColumnLimit: 100 + +# Brace settings +BreakBeforeBraces: Linux +BraceWrapping: + AfterClass: true + AfterControlStatement: false + AfterEnum: true + AfterFunction: true + AfterNamespace: true + AfterStruct: true + AfterUnion: true + BeforeCatch: true + BeforeElse: false + IndentBraces: false + SplitEmptyFunction: true + SplitEmptyRecord: true + SplitEmptyNamespace: true + +# Always add braces for control statements (Zephyr requirement) +RemoveBracesLLVM: false + +# Control statement settings +SpaceBeforeParens: ControlStatements +SpacesInParentheses: false + +# Function settings +AllowShortFunctionsOnASingleLine: None +AllowShortBlocksOnASingleLine: Empty +AllowShortIfStatementsOnASingleLine: Never +AllowShortLoopsOnASingleLine: false +AllowShortCaseLabelsOnASingleLine: false + +# Pointer and reference alignment +PointerAlignment: Right +ReferenceAlignment: Right + +# Spacing settings +SpaceAfterCStyleCast: false +SpaceAfterLogicalNot: false +SpaceBeforeAssignmentOperators: true +SpaceBeforeCpp11BracedList: false +SpaceBeforeCtorInitializerColon: true +SpaceBeforeInheritanceColon: true +SpaceBeforeRangeBasedForLoopColon: true +SpaceInEmptyParentheses: false +SpacesBeforeTrailingComments: 1 +SpacesInAngles: false +SpacesInCStyleCastParentheses: false +SpacesInContainerLiterals: false +SpacesInParentheses: false +SpacesInSquareBrackets: false + +# Alignment settings +AlignAfterOpenBracket: DontAlign +AlignConsecutiveAssignments: false +AlignConsecutiveDeclarations: false +AlignEscapedNewlines: Right +AlignOperands: false +AlignTrailingComments: false + +# Breaking settings +AlwaysBreakAfterDefinitionReturnType: None +AlwaysBreakAfterReturnType: None +AlwaysBreakBeforeMultilineStrings: false +AlwaysBreakTemplateDeclarations: false +BinPackArguments: false +BinPackParameters: false +BreakBeforeBinaryOperators: None +BreakBeforeTernaryOperators: true +BreakConstructorInitializersBeforeComma: false +BreakAfterJavaFieldAnnotations: false +BreakStringLiterals: true + +# Penalties (used for line breaking decisions) +PenaltyBreakAssignment: 2 +PenaltyBreakBeforeFirstCallParameter: 19 +PenaltyBreakComment: 300 +PenaltyBreakFirstLessLess: 120 +PenaltyBreakString: 1000 +PenaltyExcessCharacter: 1000000 +PenaltyReturnTypeOnItsOwnLine: 60 + +# Comment settings +ReflowComments: true +CommentPragmas: '^ IWYU pragma:' + +# Sorting settings +SortIncludes: true +SortUsingDeclarations: true + +# Preprocessor settings +IndentPPDirectives: None +MacroBlockBegin: '' +MacroBlockEnd: '' + +# Misc settings +CompactNamespaces: false +ConstructorInitializerAllOnOneLineOrOnePerLine: false +ConstructorInitializerIndentWidth: 4 +ContinuationIndentWidth: 4 +Cpp11BracedListStyle: true +DerivePointerAlignment: false +DisableFormat: false +ExperimentalAutoDetectBinPacking: false +FixNamespaceComments: true +ForEachMacros: ['LISTIFY', 'FOR_EACH', 'FOR_EACH_FIXED_ARG', 'FOR_EACH_IDX', 'FOR_EACH_IDX_FIXED_ARG', 'FOR_EACH_NONEMPTY_TERM', 'Z_FOR_EACH', 'Z_FOR_EACH_FIXED_ARG', 'Z_FOR_EACH_IDX', 'Z_FOR_EACH_IDX_FIXED_ARG'] +IncludeBlocks: Preserve +IncludeCategories: + - Regex: '^' + Priority: 1 + - Regex: '^<.*\.h>' + Priority: 2 + - Regex: '^<.*' + Priority: 3 + - Regex: '.*' + Priority: 4 +IndentCaseLabels: false +IndentWrappedFunctionNames: false +JavaScriptQuotes: Leave +JavaScriptWrapImports: true +KeepEmptyLinesAtTheStartOfBlocks: false +MaxEmptyLinesToKeep: 1 +NamespaceIndentation: None +ObjCBinPackProtocolList: Auto +ObjCBlockIndentWidth: 2 +ObjCSpaceAfterProperty: false +ObjCSpaceBeforeProtocolList: true diff --git a/.gitignore b/.gitignore index 454a207..fa37e0c 100644 --- a/.gitignore +++ b/.gitignore @@ -17,7 +17,7 @@ cmake_install.cmake *.bak *.orig .DS_Store -.vscode/ +#.vscode/ .idea/ # Doxygen output @@ -33,4 +33,4 @@ virtualenv/ *.bin *.hex *.elf -*.map \ No newline at end of file +*.map diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..beae3a5 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,6 @@ +{ + "C_Cpp.default.compileCommands": "${workspaceFolder}/build/compile_commands.json", + "C_Cpp.default.cppStandard": "c++17", + "C_Cpp.default.cStandard": "c11", + "C_Cpp.default.intelliSenseMode": "linux-gcc-x64" +}