Added .vscode adn .clang-format

This commit is contained in:
Eduard Iten 2025-07-09 08:45:26 +02:00
parent a4a0c7bb05
commit 067afdc237
3 changed files with 152 additions and 2 deletions

144
.clang-format Normal file
View File

@ -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: '^<zephyr/.*\.h>'
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

2
.gitignore vendored
View File

@ -17,7 +17,7 @@ cmake_install.cmake
*.bak
*.orig
.DS_Store
.vscode/
#.vscode/
.idea/
# Doxygen output

6
.vscode/settings.json vendored Normal file
View File

@ -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"
}