EditorConfig is a pretty simple format that is supported by a bunch of
common code editors (including Visual Studio). This file allows setting
some of the editor settings to match LLVM coding style guidelines which
will hopefully make it so contributors using those editors write code
closer to LLVM style without fighting their editors.
Details
- Reviewers
phosek compnerd aaron.ballman MaskRay rnk
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
Just to add some extra context. Adding this to the root of the repo will get these settings set for Visual Studio, so anyone contributing to any LLVM sub-project using Visual Studio will have their editor obey these settings unless they specifically disable the default-on option to follow the project's coding style.
.editorconfig | ||
---|---|---|
10 | Does it have some key not to add empty trailing lines? ;-) |
.editorconfig | ||
---|---|---|
10 | The insert_final_newline adds that line, which is generally what we want because strict C states that all files should end with a newline. Both GCC and Clang have warnings for that. |
This seems useful as it does apply to a lot of editors. If it were Visual Studio alone I would be unsure whether this passed the bar :)
A lot of .py files use 4 space indentation, will indent_size = 2 be problematic?
For CMake files I don't know a commonly used indentation. Will indent_size = 2 be problematic?
Consider whether indent_size = 2 should only be applied to C/C++ files.
.editorconfig | ||
---|---|---|
10 | Remove the trailing blank line. | |
10 | Do we need end_of_line = lf? |
.editorconfig | ||
---|---|---|
10 |
But there are *two* newlines at the end of the file now. |
Do we want to add .editorconfig to .gitignore so users are free to modify their local copy for additional options supported by their editor without accidentally committing the changes for everyone else? Or is that a bad idea?
.editorconfig | ||
---|---|---|
9 | Do these settings apply to the whole file when it is saved, or only to the modifications in the file as they're being made? I ask because of trim_trailing_whitespace specifically -- I have a text editor that does that automatically already when saving a file and I have to configure it to *not* do that because of how often it ends up making unrelated changes in a file when saving; especially our older test cases in Clang. |
.editorconfig | ||
---|---|---|
9 |
That's a really good point. The documentation on https://editorconfig.org doesn't specify, so it might be editor dependent, but probably impacts the whole file. | |
10 |
We could. I think at some point I'd like to get LLVM & Clang building and passing tests with autocrlf enabled at which point that would become a potential problem. |
.editorconfig | ||
---|---|---|
9 |
If these impact the whole file, that's... troublesome for the trailing whitespace and the indentation fields because both of those will likely lead to unrelated edits in files. Perhaps we should see what supported editors do currently? If they all mostly agree and don't modify the whole file, maybe we can get away with it?
Can we opt specific files out of autocrlf (Clang has a handful of test cases that are line ending sensitive)? |
We have a mix here. Some python files are 2 and some are 4. I think having the editor formalize on 2 really just means that we set the same default as for C/C++ source, and I think that's probably good.
For CMake files I don't know a commonly used indentation. Will indent_size = 2 be problematic?
For CMake we definitely prefer 2-space indent, if there is CMake code differing from that it probably has more to do with unintentional editor wonkiness than anything else.
Consider whether indent_size = 2 should only be applied to C/C++ files.
.editorconfig | ||
---|---|---|
9 |
We can, and we already do in some cases. We have a couple .gitattributes files around the repo that specify specific line ending behaviors for certain files. Clang has a lot of tests that are line ending sensitive, and my to-do list includes reviewing those to see which ones _should_ be line ending sensitive and if we can address them. Last year (or maybe it was earlier this year) I made a bunch of tests not line-ending sensitive by making column and file-offset values fuzzy-matched. |
LGTM. I think this is good but this patch needs more opinions and ideally some manual verification.
Does it have some key not to add empty trailing lines? ;-)