From bbe0e8333eca4d3f74b774491be8bf5716c9f27b Mon Sep 17 00:00:00 2001
From: cnlohr <lohr85@gmail.com>
Date: Thu, 6 Jul 2023 16:33:24 -0400
Subject: [PATCH] Add clang-format and move platformio add_include.

---
 .clang-format                            | 48 ++++++++++++++++++++++++
 add_include.py => .github/add_include.py |  0
 platformio.ini                           |  2 +-
 3 files changed, 49 insertions(+), 1 deletion(-)
 create mode 100644 .clang-format
 rename add_include.py => .github/add_include.py (100%)

diff --git a/.clang-format b/.clang-format
new file mode 100644
index 0000000..40de38f
--- /dev/null
+++ b/.clang-format
@@ -0,0 +1,48 @@
+# Basic style rules by Charles Lohr
+# Additions and modifications by Sam Ellicott
+#
+# For information about the definitions of rules
+# See: https://clang.llvm.org/docs/ClangFormatStyleOptions.html
+
+BasedOnStyle: Microsoft
+AccessModifierOffset: -4
+
+# Basic general rules
+ColumnLimit: '120'
+TabWidth: 4
+UseTab: AlignWithSpaces 
+BreakBeforeBraces: Allman
+PointerAlignment: Right
+MaxEmptyLinesToKeep: 2
+IndentCaseLabels: true
+
+# Allignment rules
+AlignAfterOpenBracket: DontAlign
+AlignTrailingComments: false
+AlignConsecutiveAssignments: false
+AlignConsecutiveMacros: false
+AlignEscapedNewlines: Left
+AlignOperands: AlignAfterOperator
+
+# Rules for brackets/parentheses
+SpaceInEmptyParentheses: false
+SpacesInAngles: true
+SpacesInCStyleCastParentheses: false
+SpacesInContainerLiterals: true
+SpacesInParentheses: true
+SpacesInSquareBrackets: false
+
+# Short statement rules
+AllowShortBlocksOnASingleLine: Never 
+AllowShortIfStatementsOnASingleLine: WithoutElse 
+AllowShortCaseLabelsOnASingleLine: true
+AllowShortLoopsOnASingleLine: true
+
+# Other Rules
+FixNamespaceComments: true
+AllowAllParametersOfDeclarationOnNextLine: false
+AlwaysBreakTemplateDeclarations: 'Yes'
+BreakBeforeBinaryOperators: None
+BreakConstructorInitializers: BeforeComma
+ExperimentalAutoDetectBinPacking: false
+NamespaceIndentation: None
diff --git a/add_include.py b/.github/add_include.py
similarity index 100%
rename from add_include.py
rename to .github/add_include.py
diff --git a/platformio.ini b/platformio.ini
index 2da7e04..b20948c 100644
--- a/platformio.ini
+++ b/platformio.ini
@@ -17,7 +17,7 @@ extends = fun_base
 board_build.ldscript = ch32v003fun/ch32v003fun.ld
 build_flags = -flto -Ich32v003fun -I/usr/include/newlib -lgcc -Iextralibs
 ; dynamically add "examples/$PIOENV" to the include path
-extra_scripts = add_include.py
+extra_scripts = .github/add_include.py
 build_src_filter = +<ch32v003fun>
 extra_libs_srcs = +<extralibs>
 
-- 
GitLab