Add clang format file
AbandonedPublic

Authored by davidedmundson on Sep 28 2019, 2:35 PM.

Details

Reviewers
None
Summary

Kate have just clang-formatted all their code, a few
other proejcts have too (see T11214). I think we can move
forward.

We need to bikeshed on the exact formatting.

We had a version proposed, but being similar to Kate makes
a lot of sense too.

This is the same clang format file as Kate without the column limit
and with sorted includes which KWin people wanted.

If I upload a big diff to phab to see the result the web UI
will have a meltdown.

Instead download this patch (for any repo) and run
find . -name \*.h -print -o -name \*.cpp -print | xargs clang-format -i from the root of the source directory

Diff Detail

Repository
R120 Plasma Workspace
Branch
clang_format
Lint
No Linters Available
Unit
No Unit Test Coverage
Build Status
Buildable 17127
Build 17145: arc lint + arc unit
davidedmundson created this revision.Sep 28 2019, 2:35 PM
Restricted Application added a project: Plasma. · View Herald TranscriptSep 28 2019, 2:35 PM
Restricted Application added a subscriber: plasma-devel. · View Herald Transcript
davidedmundson requested review of this revision.Sep 28 2019, 2:35 PM
davidedmundson edited the summary of this revision. (Show Details)Sep 28 2019, 2:37 PM
davidedmundson edited projects, added KWin; removed Plasma.
Restricted Application edited projects, added Plasma; removed KWin. · View Herald TranscriptSep 28 2019, 2:37 PM

See D24568 for the draft of an ECM module that applies the Kate/KTextEditor/Artikulate style.
Is the same file as here, with sorting of includes, but with column limit.

zzag added a subscriber: zzag.Oct 11 2019, 7:05 PM
zzag added inline comments.
.clang-format
55–56

I'd object to aligning trailing comments because a single line change may affect many other unrelated lines.

However, if this .clang-format file serves just as a sample and projects are allowed to tweak it, then it's fine.

83

The Frameworks coding says not to indent case lables.

zzag added inline comments.Oct 11 2019, 7:08 PM
.clang-format
83

s/coding/coding style/

This is just a base file for discussion.
Stuff like the mentioned case indentation can be adjusted to be frameworks conform.
For the alignment of comments, I am not sure, it makes the stuff a lot more readable in many cases and after the initial re-format you don't have a lot of jitter normally.

davidedmundson abandoned this revision.Oct 12 2019, 11:00 AM

Lets do all this discussion on D24568

However, as this CC's the plasma team I would urge people again to follow up on that thread as I do intend on running it across all plasma repos.

cullmann added inline comments.Oct 12 2019, 4:04 PM
.clang-format
83

Fixed that in D24568

zzag added a comment.Oct 14 2019, 8:23 AM

For the alignment of comments, I am not sure, it makes the stuff a lot more readable in many cases and after the initial re-format you don't have a lot of jitter normally.

As I said my concern is that aligning trailing comments (as well consecutive assignments) will mess git history up. Unfortunately, there's no right and wrong, we have to look at such things case by case.

There will anyways be one "big" change in the history, but normally git will be able to handle that well by ignoring space changes for blame or diff.
I don't think without the aligning the change will be much smaller.