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