travisjeffery / ClangFormat-Xcode

Xcode plug-in to to use clang-format from in Xcode and consistently format your code with Clang
https://twitter.com/travisjeffery
MIT License
2.89k stars 288 forks source link

In some code case, ClangFormat wouldn't working well. #83

Closed zizicici closed 9 years ago

zizicici commented 9 years ago

clang.format:

BasedOnStyle: LLVM
IndentWidth: 4
BreakBeforeBraces: Attach
AllowShortIfStatementsOnASingleLine: true
IndentCaseLabels: true
ObjCBlockIndentWidth: 4
ObjCSpaceAfterProperty: true
ColumnLimit: 0
AlignTrailingComments: true
SpaceAfterCStyleCast: true
SpacesInParentheses: false
SpacesInSquareBrackets: false

if code style is like:

    [instance method:blabla success:^(){}];

after clang.format:

    [instance method:blabla
             success:^(){
             }];

if code style is like:

    [instance method:blabla success:^(){} error:^(){}];

after clang.format:

    [instance method:blabla
        success:^() {
        }
        error:^(){
        }];
tonyarnold commented 9 years ago

Hi @beimen — you need to report bugs with the way code is formatted directly to the Clang/LLVM bug tracker — the developers of the clang-format tool (not this Xcode plugin) do not read the issues here.

zizicici commented 9 years ago

@tonyarnold , Thanks.

KingOfBrian commented 9 years ago

I just noticed your bug got dup'd to mine for this issue. I have a patch for clang-format which works, but isn't merged in yet. Would be good to get any input on it. It also fixes 18426, a bug you logged @tonyarnold. I'm working on convincing him that Xcode style block formatting is worth supporting in clang-format. So thanks for logging the bug @beimen -- it helps!

http://reviews.llvm.org/D9237

Also, if you have any opinions config file switch names that'd be great too. I'm terrible at naming some times.

tonyarnold commented 9 years ago

I hit the same resistance when submitting previous patches, @KingOfBrian — thanks for seeing it out. I'm very keen to see your patch merged — I don't want Google formatting inside my blocks! Why would I want anything other than what I'd already defined for non-closure code? :P