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