dot.clang-format revision 1.1 1 1.1 wiz # $NetBSD: dot.clang-format,v 1.1 2024/08/23 09:06:37 wiz Exp $
2 1.1 wiz #
3 1.1 wiz # This is a base for using clang-format with NetBSD sources.
4 1.1 wiz #
5 1.1 wiz # /usr/share/misc/style has more details, some of which cannot be
6 1.1 wiz # captured here.
7 1.1 wiz #
8 1.1 wiz # To use it, rename it to .clang-format and put it in the directory
9 1.1 wiz # you're editing, or call clang-format with the --style argument:
10 1.1 wiz #
11 1.1 wiz # clang-format --style=file:/usr/share/misc/dot.clang-format [...] file.c
12 1.1 wiz #
13 1.1 wiz # 80 characters line length
14 1.1 wiz ColumnLimit: 80
15 1.1 wiz # if comments get too long, fmt them.
16 1.1 wiz ReflowComments: true
17 1.1 wiz # default indentation level
18 1.1 wiz IndentWidth: 8
19 1.1 wiz # also for struct initializers
20 1.1 wiz BracedInitializerIndentWidth: 8
21 1.1 wiz # prefer using tabs to spaces when indenting
22 1.1 wiz UseTab: ForContinuationAndIndentation
23 1.1 wiz # indent 1 space more per #if-level
24 1.1 wiz PPIndentWidth: 1
25 1.1 wiz # and put the space after the hash but before the keyword (i.e., "# if")
26 1.1 wiz IndentPPDirectives: AfterHash
27 1.1 wiz # backslashes at end-of-line are aligned, but as far left as possible
28 1.1 wiz AlignEscapedNewlines: Left
29 1.1 wiz # not supported in clang-format 18, would include the last line (without backslash) in the offset consideration
30 1.1 wiz #AlignEscapedNewlines: LeftWithLastLine
31 1.1 wiz #
32 1.1 wiz # if function arguments get too long, start new line indented by 4
33 1.1 wiz AlignAfterOpenBracket: DontAlign
34 1.1 wiz ContinuationIndentWidth: 4
35 1.1 wiz # but keep first parameters on the first line
36 1.1 wiz AllowAllParametersOfDeclarationOnNextLine: False
37 1.1 wiz AllowAllArgumentsOnNextLine: false
38 1.1 wiz # for struct's etc. use 8 characters indent as well
39 1.1 wiz ConstructorInitializerIndentWidth: 8
40 1.1 wiz # attach "{", except for functions
41 1.1 wiz BreakBeforeBraces: WebKit
42 1.1 wiz # for functions, add newline after return type
43 1.1 wiz AlwaysBreakAfterReturnType: TopLevelDefinitions
44 1.1 wiz # align structure elements to the right
45 1.1 wiz AlignArrayOfStructures: Right
46