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 to change behaviour when no .clang-format is found #94

Closed
Ashton-W opened this issue Jul 29, 2015 · 9 comments
Closed

Option to change behaviour when no .clang-format is found #94

Ashton-W opened this issue Jul 29, 2015 · 9 comments

Comments

@Ashton-W
Copy link

I dislike the default behaviour of clang-format, in that if there is no configuration it defaults to formatting with LLVM style. This is annoying if you use 'format on save', this message is also shown: "Can't find usable .clang-format, using LLVM style".

Can we get an option to default to no-format if no config is found?

@tonyarnold
Copy link
Collaborator

Sure we could look into that.

Why not just configure it, though? Add a .clang-format to the projects you work on, and then add one to your home directory (containing the no-format instructions if you want). The clang-format tool will walk back up the tree from it's PWD looking for a config and use the first one that it finds.

@Ashton-W
Copy link
Author

Hi Tony,

I am using the method of having a .clang-format in my home directory. This works for me, but it makes it harder to get my whole team onboard the format train when it requires so much config - having this in the plugin would be simpler for first setup or people unfamiliar with clang-format the tool.

Somewhat related, the plugin will show the message for system headers you accidentally try and save - they won't pickup your ~/.clang-format as they are under /Library

I was thinking of adding this myself when I had time. Glad to have feedback

@tonyarnold
Copy link
Collaborator

Go for it! Contributions are always welcome — I think my concern here is that users installing the plugin expect it to do something (anything) when they run it on first install — even if it's not correct.

Format on save isn't enabled by default, is it? It seems to me that a change like this might disadvantage new users.

@travisjeffery
Copy link
Owner

you can check the .clang-format file into the root of your project's git repo and then everyone would automatically have it.

@tonyarnold
Copy link
Collaborator

@travisjeffery I think @Ashton-W is concerned about users who install the plugin then go to edit another project (outside of his control) without a configuration file. They'll see the error mentioned.

@travisjeffery
Copy link
Owner

This works for me, but it makes it harder to get my whole team onboard the format train when it requires so much config

sure. seemed he was mostly concerned about the projects his team was working on ^. supposedly they'd be the same projects. ¯_(ツ)_/¯

i'm -1 on making no formatting the default too. i think that would just confuse a lot of people that it wasn't working. just disable the plugin if you're working on another project/don't want to use it.

@Ashton-W
Copy link
Author

I was thinking this would be another option under 'format on save', so only projects with a .clang-format get formatting.
I don't think many users actually intend to format all source files they save as LLVM style unless specified.

@travisjeffery
Copy link
Owner

i don't many would want it use llvm as is either, but a lot people don't want the default color scheme in vim as their color scheme as the default. neither do they want the default cover photo on fb/twitter as their cover photo but it lets them know it's there and working and that they can change it. i simply don't want to add a piece of configuration needed for people to start formatting and see that it's working. either way they'll probably configure it anyway but at least this way the default shows that it's working.

best case clang would support an option that would disable formatting. maybe there is one but i think their docs are down currently.

@Ashton-W
Copy link
Author

I think we agree that we shouldn't change the default behaviour. Instead add something users can opt-in to.

This would be the same as creating ~/.clang-format with the contents DisableFormat: true, but instead of users requiring more external config, we provide an easier option (that also avoids needing a .clang-format at root /).

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

No branches or pull requests

3 participants