Skip to content
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

Option -sort-includes #112

Open
robindegen opened this issue Jan 15, 2016 · 5 comments
Open

Option -sort-includes #112

robindegen opened this issue Jan 15, 2016 · 5 comments

Comments

@robindegen
Copy link

Does this plugin run clang formatter with -sort-includes? If so, could an option be added to disable this? When using clang formatter through this plugin, all my headers get shuffled around causing the code to break. I don't have this issue when running clang-format manually on my files.

@tonyarnold
Copy link
Collaborator

Yes, that's a good idea. In the meantime, you can always refer to Clang-Format Style Options to see how to enable/disable features in the clang-format binary itself.

@tonyarnold
Copy link
Collaborator

To answer whether it does this… it doesn't specify it, but perhaps this is the default in the upstream binary?

@robindegen
Copy link
Author

It's a bit of a mistery to me what's actually going on here. The "official" clang format plugin for visual studio has explicit mention of a -sort-includes parameter given:
https://github.com/llvm-mirror/clang/blob/master/tools/clang-format-vs/ClangFormat/ClangFormatPackage.cs#L259

I can't seem to find that in the sources here (maybe i'm not looking well enough?). I wonder if behavior is different between platforms, or if it's just a matter of which version you use.

@tonyarnold
Copy link
Collaborator

This is just an Xcode plugin that calls through to the clangformat binary. If you've got a more recent version installed with support for sorting includes, and your configuration specifies it, it will be used (I believe the option appeared in Clang 3.8).

This plugin is not clang format, so there wouldn't be any mention of a specific config option here.

@robindegen
Copy link
Author

It was my understanding however that it's disabled by default on the command-line. I'm trying to figure out what's causing it to get enabled. My configuration file has no mention of this.

I found this from chromium:
https://codereview.chromium.org/1616263006

Where they mention that header sorting is disabled if the Chromium style is used, I guess possible through BasedOnStyle: Chromium in the config.

There seems to be a lot of scattered information about this topic all over the place with no clear consensus about the actual default behavior of this.

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

No branches or pull requests

2 participants