Add a .clang-format file
authorAndreas Schneider <asn@samba.org>
Tue, 19 Jul 2022 13:38:27 +0000 (15:38 +0200)
committerRalph Boehme <slow@samba.org>
Wed, 20 Jul 2022 18:23:49 +0000 (18:23 +0000)
How to use:

Install 'git-format-clang' which is part of the clang suite (Fedora:
git-clang-format, openSUSE: clang-tools).

Now do your changes and stage them with `git add`. Once they are staged
format the code using `git clang-format` before you commit.

Now the formatting changed can be viewed with `git diff` against the
staged changes.

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
Autobuild-User(master): Ralph Böhme <slow@samba.org>
Autobuild-Date(master): Wed Jul 20 18:23:49 UTC 2022 on sn-devel-184

.clang-format [new file with mode: 0644]
README.Coding.md

diff --git a/.clang-format b/.clang-format
new file mode 100644 (file)
index 0000000..5385807
--- /dev/null
@@ -0,0 +1,26 @@
+# https://clang.llvm.org/docs/ClangFormatStyleOptions.html
+BasedOnStyle: LLVM
+IndentWidth: 8
+ContinuationIndentWidth: 8
+UseTab: true
+BreakBeforeBraces: Custom
+BraceWrapping:
+    AfterEnum: false
+    AfterFunction: true
+    AfterStruct: false
+    AfterUnion: false
+    AfterExternBlock: true
+    BeforeElse: false
+    BeforeWhile: false
+AllowShortIfStatementsOnASingleLine: false
+ColumnLimit: 80
+IndentCaseLabels: false
+AlignAfterOpenBracket: Align
+BinPackParameters: false
+BinPackArguments: false
+AllowAllParametersOfDeclarationOnNextLine: false
+AllowAllArgumentsOnNextLine: false
+AllowShortFunctionsOnASingleLine: Empty
+AlwaysBreakAfterReturnType: None
+AlignEscapedNewlines: Left
+SortIncludes: false
index b87580f5f85e20240f5f715dd6534f8935edce32..09a13283e050c3017d9922047c718ce536ec188a 100644 (file)
@@ -88,20 +88,16 @@ displaying trailing whitespace:
   autocmd BufNewFile,BufRead *.c,*.h exec 'match Todo /\%>' . &textwidth . 'v.\+/'
 ```
 
-### clang-format
+### How to use clang-format
 
-```
-BasedOnStyle: LLVM
-IndentWidth: 8
-UseTab: true
-BreakBeforeBraces: Linux
-AllowShortIfStatementsOnASingleLine: false
-IndentCaseLabels: false
-BinPackParameters: false
-BinPackArguments: false
-SortIncludes: false
-```
+Install 'git-format-clang' which is part of the clang suite (Fedora:
+git-clang-format, openSUSE: clang-tools).
+
+Now do your changes and stage them with `git add`. Once they are staged
+format the code using `git clang-format` before you commit.
 
+Now the formatting changed can be viewed with `git diff` against the
+staged changes.
 
 ## FAQ & Statement Reference