Skip to content

Clang format#885

Open
versable wants to merge 2 commits intoTry:masterfrom
versable:clang-format
Open

Clang format#885
versable wants to merge 2 commits intoTry:masterfrom
versable:clang-format

Conversation

@versable
Copy link
Contributor

Hey @Try ,

it would be wise to offload the code style to a formatter/linter. Here is a WIP implementation with mainwindow.cpp as a test case for automatic formatting.

@Try
Copy link
Owner

Try commented Jan 25, 2026

Afaik current code-style is not represented in clang-format, would it be possible to format other things, while ignoring brackets { } ?

@versable
Copy link
Contributor Author

@Try I'll look into it.

@Try
Copy link
Owner

Try commented Feb 4, 2026

Linking to prior art: #304

@LordKobra
Copy link
Contributor

LordKobra commented Mar 26, 2026

Regarding brackets. The current style is called "Ratliff" and is quite unconventional (i find i a little confusing, because the closing bracket stays indented). Usually either K&R or Allman brackets are used.
https://en.wikipedia.org/wiki/Indentation_style

But if you really want to keep this bracket style, clang-format does have BS_Custom style, where you can manually define the brackets the way you want.
https://clang.llvm.org/docs/ClangFormatStyleOptions.html

Edit: So i tried to get it to work, but sadly it is not possible, because IndentBraces doesn't properly apply to all braces.

BreakBeforeBraces: Custom
BraceWrapping:
  AfterFunction: false
  AfterClass: false
  AfterStruct: false
  AfterEnum: false
  AfterUnion: false
  BeforeElse: false
  BeforeCatch: false
  IndentBraces: true

So the only way to indent braces at the moment is to use Whitesmiths brace style, which in turn disables customization for the opening bracket.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants