-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Format of .clang-format file? #571
Comments
The clang-format documentation is unfortunately not very good, particularly in regards to examples and explanations of usage: http://releases.llvm.org/3.8.0/tools/clang/docs/ClangFormatStyleOptions.html . The .clang-format file is not supposed to contain JSON. You can call the binary itself to output a sample, e.g. clang-format -style=llvm -dump-config > .clang-format. Our extension doesn't expose the clang-format errors unfortunately. You could try to get errors via calling the .exe itself. It seems you want to use something like
|
I'm not sure what is going wrong then, because if I put the above snippet into ~/.clang-format, it simply fails. If the file contains the contents that I originally posted it works. e.g.
fails, but
works. It looks like the extension reads the file and uses it as if the content was inserted directly into "clang-format.style" from the settings file? |
Oh, I found that we have a bug logged with the .clang-format file not working on Linux/Mac. I can't get the .clang-format to work at all on Linux, even with the inline formatting. |
Sorry - I should have added some platform specifics. It does work for me on Linux (without the flags), but that last bracket needs to be on the same line. 8-) |
That is strange. I can't repro the behavior you're describing, and I debugged the code on Linux and we're failing to recognize the .clang-format file completely and it's using the hard-coded "Visual Studio" style. I assume fixing this issue would also fix your scenario, even though I can't repro the symptom. It won't be fixed in the next update, but we have a bunch of Linux-only bugs we'll hopefully be able to fix in the update after the next one. |
OK. At the moment I'm using a separate clang-format extension with formatting disabled in C/C++. Seems to work OK, but it would be cool have it all in the one extension. If you need further details of my set up, let me know. |
{ this may works. |
We now print clang-format errors to the Output window to help you diagnose issues with the file format. If you are still having problems with this, let us know. |
Is there any documentation for the format of the .clang-format file when the "file" settings is used?
From experimentation, the only way I can get the .clang-format file to work is if it's contents are in the same format as suggested in the settings comments.
For example:
Note - the closing brace needs to be on the same line as the last statement. or it doesn't work.
Is this expected? If I use a standard clang-format file (non-JSON), it doesn't work.
I would like to be able to specify a custom format for BreakBeforeBraces, but I don't know how to then specify the BraceWrapping sub flags. I've tried several combinations of JSON and flags names, but it simply fails to format the file.
Is there a way to get any diagnostic information?
The text was updated successfully, but these errors were encountered: