Parser intellij-java-google-style.xml to .editorconfig file
Hi, I'd like to use an .editorconfig file with the same configuration of intellij-java-google-style.xml
I'd like to know if this .editorconfig configured with this style already exist, or if not, could we do this translation from xml to .editorconfig?
If you have IntelliJ it looks like you can export configuration via "File->Settings->Editor->Code Style" (see https://stackoverflow.com/questions/35915970/how-to-export-all-my-intellij-code-styles-to-a-editorconfig-file)
I'm in the process of trying to get an .editorconfig for the C++ style guide by using CLion to import eclipse-cpp-google-style.xml and then export again 🤞
@jacobq It is unavailable in CLion 2020.2

:cry: :cry: :cry: :cry: :cry: :cry: :cry: :cry: :cry:
@jacobq It is unavailable in CLion 2020.2
I can't remember if I even got it to work before or not (see https://github.com/google/styleguide/issues/411), but in any case support for importing from an Eclipse style file is an open issue filed a long time ago (please consider voting for it):
https://youtrack.jetbrains.com/issue/CPP-368
It would be nice if there were also a intellij-cpp-google-style.xml file here, but my guess is that no one is assigned to this task nor has anyone cared enough to volunteer. I suppose one of us could start by taking the "Google" presets that CLion ships with then exporting the resulting XML and submitting a PR.
See also:
- https://youtrack.jetbrains.com/issue/CPP-9177
- https://youtrack.jetbrains.com/issue/CPP-15439
I just use Intellij IDEA to write protobuf files and need cpp code style. I think user shoud not write cpp by Intellj IDEA but use CLion with nice full supports.
I try to do something else to go around this issue and solve my problem of code format consistency.
- Add
.editorconfigto simulate Google cpp code style on.proto. - Add
.clang-formatused by an Intellij IDEA plugin described below to config ClangFormat. - Install ClangFormat to your PC. In Ubuntu, just
sudo apt install clang-format. - In Intellij IDEA, a plugin named ClangFormatIJ need to be installed. This plugin use
clang-formatin thePATHand.clang-formatconfig file in the root directory of project. - Use
Reformat Code with clang-formatto every file you edit. There is no default keymap of the command. You can bind one or just useSearch Everywhere, typeclangand get it in theActionpart. - Deselect the
Reformat codein the commit config from unexpected code formatting. - Run the following shell before committing your code:
git diff -U0 --no-color HEAD^ | clang-format-diff -style Google -i -p1.I strongly suggest you execute both steps to ensure there is no diff about format.
If you have IntelliJ it looks like you can export configuration via "File->Settings->Editor->Code Style" (see https://stackoverflow.com/questions/35915970/how-to-export-all-my-intellij-code-styles-to-a-editorconfig-file)
I'm in the process of trying to get an
.editorconfigfor the C++ style guide by using CLion to importeclipse-cpp-google-style.xmland then export again crossed_fingers
While it works, it does generate a bunch of things that look like IntelliJ specific config which might not work with other editors
ij_continuation_indent_size = 4
ij_formatter_off_tag = @formatter:off
ij_formatter_on_tag = @formatter:on
ij_formatter_tags_enabled = false
ij_smart_tabs = false
ij_visual_guides = none
ij_wrap_on_typing = false