ClangFormat-Xcode
ClangFormat-Xcode copied to clipboard
Bundled clang-format issue with long Objecttive-C lines
I'm using a custom clang_format equivalent to -style="{BasedOnStyle: google, ContinuationIndentWidth: 4, ColumnLimit: 100, DerivePointerAlignment: false, PointerAlignment: Right, UseTab: Never}"
Using ClangFormat-Xcode with the bundled clang-format turns
-(BOOL)reallyLongFunctionName012345678901234567890123456789012345678:(ReallyLongTypeName012345678901234 *)vc{return NO;}
into
- (BOOL)reallyLongFunctionName012345678901234567890123456789012345678:
(ReallyLongTypeName012345678901234 *)vc{
return NO;
}
(there's an 4 extra spaces in front of (ReallyLongTypeName012345678901234 *)) Using the system version of clang-format (version 3.7.0) installed from homebrew does the right spacing:
echo "-(BOOL)reallyLongFunctionName012345678901234567890123456789012345678:(ReallyLongTypeName012345678901234 *)vc{return NO;}" | clang-format -style="{BasedOnStyle: google, ContinuationIndentWidth: 4, ColumnLimit: 100, DerivePointerAlignment: false, PointerAlignment: Right, UseTab: Never}"
returns
- (BOOL)reallyLongFunctionName012345678901234567890123456789012345678:
(ReallyLongTypeName012345678901234 *)vc {
return NO;
}
I'm seeing this too, see my Stack Overflow question here: http://stackoverflow.com/questions/30110479/clang-format-stop-breaking-long-methods-up Solution may be to revert the version of clang format included until this bug is fixed.
I'll see if I can track down what's happening before reverting. It looks like someone has changed some pretty fundamental stuff with Objective-C formatting without testing properly.
I'm not sure if this is related to OP's issue, but I'm having the same issue as @jshier. Setting ColumnLimit to 0 was fine a while ago (not sure if it was really introduced with clang-format 3.7), but now this setting behaves differently. I don't want my methods with multiple parameters to break into multiple lines (that line up with the colons.
What I actually don't understand (maybe this has to do something with Alcatraz?): I'm unable to revert to an older version so I'm stuck with this error for now. I'm replacing the folder at ~/Library/Application Support/Alcatraz/Plug-ins/ClangFormat. Isn't that sufficient? Is that the wrong location?
@MuscleRumble I believe Alcatraz silently upgrades your plugins when you open Xcode.
You should try putting the older version of the clang-format binary in your path, and telling ClangFormat-Xcode to use the system bundled version of clang-format.
Alriiight! Thanks! That works! :)
any update on this issue?
any update?
+1
Any word on this? Does a bug need to be filed upstream?
Yeah, if you're game to compile from source the TOT Clang 3.8.0 version of clang-format seems better. ColumnLimit: 0
is broken as hell, but setting it to a really high number works well (it didn't before).