-
Notifications
You must be signed in to change notification settings - Fork 79
DRAFT: First pass at a clang formatter #1500
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Changes from all commits
88fc726
3523ffd
fec348b
f111422
95baba7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,47 @@ | ||||||
| --- | ||||||
| ### Run using: | ||||||
| ### find ./src/libs/ascent/ -regex '.*\.\(c\|cpp\|h\|hpp\)' -exec clang-format -i {} + | ||||||
|
|
||||||
|
|
||||||
| ############################# | ||||||
| ### Alignment and Spacing ### | ||||||
| ############################# | ||||||
|
|
||||||
| # Basic spacing and line length limits | ||||||
| ColumnLimit: 79 | ||||||
| PenaltyExcessCharacter: 1000000 # Allows for strings to overflow past column | ||||||
| AlignArrayOfStructures: Left # Aligns columns of structures so they all line up clearly | ||||||
| AlignConsecutiveAssignments: false # Don't bother lining up `=` symbols in consecutive lines | ||||||
| AlignConsecutiveDeclarations: false # Don't bother lining up `=` symbols in consecutive lines | ||||||
|
|
||||||
| # For lines that get wrapped, this forces one parameter per line and aligns them | ||||||
| BinPackParameters: false # One param per line if wrapped | ||||||
| BinPackArguments: false # One argument per line if wrapped | ||||||
| AlignAfterOpenBracket: Align # Align wrapped args/params under the first | ||||||
| AllowAllParametersOfDeclarationOnNextLine: false | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
I think this should be true. Sometimes namespace::method() names get so long that it is useful to put parameter declarations on the following lines.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What I don't like is that when you make that change you get: rather than when it is false it gives:
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does it let you put the arguments on multiple lines when set to
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It does, but it seems to prioritize grouping things in a way I don't love. When there are enough arguments or the named are long enough both true and false will wrap the arguments onto their own lines |
||||||
|
|
||||||
| # Indentation | ||||||
| IndentWidth: 4 | ||||||
| UseTab: Never | ||||||
| IndentPPDirectives: BeforeHash # don't indent things like `#ifdef` and `#define` unless nested | ||||||
|
|
||||||
|
|
||||||
| ################# | ||||||
| ### {} Braces ### | ||||||
| ################# | ||||||
| BreakBeforeBraces: Allman # Braces get their own lines | ||||||
| SpaceBeforeParens: ControlStatements | ||||||
| AllowShortFunctionsOnASingleLine: Empty | ||||||
|
|
||||||
| ################ | ||||||
| ### Includes ### | ||||||
| ################ | ||||||
| SortIncludes: false # Don't auto-sort #includes | ||||||
| IncludeBlocks: Preserve # Keeps include groups separate | ||||||
|
|
||||||
|
|
||||||
| ################## | ||||||
| ### Namespaces ### | ||||||
| ################## | ||||||
| AccessModifierOffset: -4 # Access modifiers (public:, private:, protected:) should be inset | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
🙃
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmm. I don't know that I agree with this. That change would make header files significantly harder to read.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I blame Livchat again. I like the
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. LivChat really does hallucinate a lot on this topic unfortunately. It is especially disappointing when I ask for a setting to change something and it makes up something only for that setting to not really exist :(. |
||||||
| ... | ||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
does this enforce this
versus this?
or does it just relax the restriction so users can do whatever?
Also, as far as I know,
AlignConsecutiveDeclarationsis not for lining up=symbols, it is aligning declarations like this:There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AlignConsecutiveDeclarationswill turninto
And
AlignConsecutiveAssignmentsapplies to assignments both in declarations and notinto
It does not relax the requirement.
I personally don't want these to be set to true. You end up with a lot of changes like:
becoming
Which looks wonky to me personally
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It does look like the default behavior is to not align things