Quuxplusone / LLVMBugzillaTest

0 stars 0 forks source link

.editorconfig #50070

Open Quuxplusone opened 3 years ago

Quuxplusone commented 3 years ago
Bugzilla Link PR51101
Status NEW
Importance P enhancement
Reported by NN (nn1436401@gmail.com)
Reported on 2021-07-14 22:13:41 -0700
Last modified on 2021-07-16 03:07:42 -0700
Version trunk
Hardware PC Windows NT
CC dblaikie@gmail.com, djasper@google.com, klimek@google.com, llvm-bugs@lists.llvm.org, mydeveloperday@gmail.com
Fixed by commit(s)
Attachments
Blocks
Blocked by
See also
.editorconfig ( https://editorconfig.org/ ) is the standard way to define code
formatting and analysis rules.

The main advantage of editorconfig file is filtering options which are
unavailable in Clang Format YAML.

The conversion from YAML to editorconfig can be done straight-forward, for
example:

.clang-format

Language: Cpp
AccessModifierOffset: -4
AlignAfterOpenBracket: Align

.editorconfig

[*.cpp]
clang_format_cpp_access_modifier_offset = -4
clang_format_cpp_align_after_open_bracket = align

# Can specify different rule for a different filter
[tests/*.cpp]
clang_format_cpp_access_modifier_offset = 8
Quuxplusone commented 3 years ago
Here are C++ formatting rules that Visual Studio understands:
https://docs.microsoft.com/en-us/visualstudio/ide/cpp-editorconfig-properties?view=vs-2019
Quuxplusone commented 3 years ago

Here are C++ formatting rules understood by ReSharper C++:

https://www.jetbrains.com/help/resharper/EditorConfig_CPP_CppBlankLinesPageScheme.html

Quuxplusone commented 3 years ago

To be clear, the feature request is that you would like clang-format to support parsing .editorconfig files directly as an alternative to .clang-format files?

Quuxplusone commented 3 years ago
Yes.
It solves few issues with the current approach:
Well known file.
All editors today understand editorconfig but not clang-format.
By understand I mean highlighting or visual editing.

Filtering rules: Today you must do it externally by calling or not calling
clang-format for needed files.

Forward compatibility: Today if you specify option from future clang-format
fails.
Editorconfig format requires you to not fail in such case.
Quuxplusone commented 3 years ago

I think generally as an idea this is pretty good, I guess perhaps to begin with it might be nice to have a .editorconfig to .clang-format converter

That is something that could be developed as a standalone. (great little starter project for someone!)

There are likely aspects of .editorconfig which clang-format doesn't support

But probably it would be good to take a deeper look at where these is overlap and where there isn't

its might open up new avenues for new functionality to be added to clang-format.