On Sat, Aug 10, 2024 at 11:40:46PM +0200, Thomas Klausner wrote: > Hi! > > We have a project to make a clang-format configuration file for > NetBSD. It's still listed in the wiki: > > https://wiki.netbsd.org/projects/project/clang-format/ > > even though there was a successful GSoC project on this topic: > > http://blog.netbsd.org/tnf/entry/gsoc_2019_report_adding_netbsd1 > > but it looks like upstream changes in llvm, and I didn't find an > actual clang-format config file. > > Does anyone have a current best-effort clang-format configuration > file?
I didn't get a reply. Here's what I've come up with so far (using clang 18 from pkgsrc). Thomas
# 80 characters line length ColumnLimit: 80 # if comments get too long, fmt them. ReflowComments: true # default indentation level IndentWidth: 8 # also for struct initializers BracedInitializerIndentWidth: 8 # prefer using tabs to spaces when indenting UseTab: ForContinuationAndIndentation # indent 1 space more per #if-level PPIndentWidth: 1 # and put the space after the hash but before the keyword (i.e., "# if") IndentPPDirectives: AfterHash # backslashes at end-of-line are aligned, but as far left as possible AlignEscapedNewlines: Left # not supported in clang-format 18, would include the last line (without backslash) in the offset consideration #AlignEscapedNewlines: LeftWithLastLine # # if function arguments get too long, start new line indented by 4 AlignAfterOpenBracket: DontAlign ContinuationIndentWidth: 4 # but keep first parameters on the first line AllowAllParametersOfDeclarationOnNextLine: False AllowAllArgumentsOnNextLine: false # for struct's etc. use 8 characters indent as well ConstructorInitializerIndentWidth: 8 # newline before "{" except for functions BreakBeforeBraces: WebKit # for functions, add newline after return type AlwaysBreakAfterReturnType: TopLevelDefinitions # align structure elements to the right AlignArrayOfStructures: Right