[yast-devel] consistent indentation with https://editorconfig.org/
Hi, some time ago I started using a new code editor[1], and I found that unlike my other editor[2] it has difficulties in divinating the indentation styles of various code bases. Fortunately, a reasonable standard has emerged that lets a code base declare how to indent, in a way that editors can easily understand: https://editorconfig.org/ Here's a declaration I've been using for our Ruby code: # top-most EditorConfig file root = true # 2 space indentation [*.rb] indent_style = space indent_size = 2 And here's the one from libstorage-ng, capturing the not-quite-trivial rules of "the Tab key indents 4 columns, but compress 8 spaces into Tab characters" # https://EditorConfig.org -*- ini -*- # This is a unified way to tell all your editors # about the proper indentation style in this repo. # # Emacs: https://github.com/editorconfig/editorconfig-emacs#readme # Vim: https://github.com/editorconfig/editorconfig-vim#readme # VS Code: https://marketplace.visualstudio.com/items?itemName=EditorConfig.EditorConfi... # don't continue looking in upper directories, this is the top level root = true [*.{h,cc}] indent_style = tab indent_size = 4 tab_width = 8 I've added it to a couple of repos so far, where I needed it. 1. Should we improve these declarations? (Add trim_trailing_whitespace[3], insert_final_newline) 2. Should we add a master copy to yast-devtools? (It would need to be copied manually, but it would serve as the representation of the current best practice) [1]: https://en.wikipedia.org/wiki/Visual_Studio_Code [2]: https://en.wikipedia.org/wiki/GNU_Emacs [3]: https://github.com/yast/yast-packager/pull/441#discussion_r294163050 thanks to Lada for prompting this -- Martin Vidner, YaST Team http://en.opensuse.org/User:Mvidner
Thanks Martin for the info. I think is a good idea to have our own ".editorconfig" at some place. Maybe we could add it to yast-devtools and deploy the file in the user home? Regarding the rules, I would add both: trim_trailing_whitespace and insert_final_newline. I see none case where they could be a problem. And for the special libstorage-ng rules, I would keep them only in the libstorage-ng repository. They are quite particular. In fact, I have been reviewing some C++ style guides (there are quite some) and almost all of them avoid to use tabs. So, in our default ".editorconfig" I would use other rules for cpp files. On 6/17/19 12:19 PM, Martin Vidner wrote:
Hi,
some time ago I started using a new code editor[1], and I found that unlike my other editor[2] it has difficulties in divinating the indentation styles of various code bases.
Fortunately, a reasonable standard has emerged that lets a code base declare how to indent, in a way that editors can easily understand:
Here's a declaration I've been using for our Ruby code:
# top-most EditorConfig file root = true
# 2 space indentation [*.rb] indent_style = space indent_size = 2
And here's the one from libstorage-ng, capturing the not-quite-trivial rules of "the Tab key indents 4 columns, but compress 8 spaces into Tab characters"
# https://EditorConfig.org -*- ini -*- # This is a unified way to tell all your editors # about the proper indentation style in this repo. # # Emacs: https://github.com/editorconfig/editorconfig-emacs#readme # Vim: https://github.com/editorconfig/editorconfig-vim#readme # VS Code: https://marketplace.visualstudio.com/items?itemName=EditorConfig.EditorConfi...
# don't continue looking in upper directories, this is the top level root = true
[*.{h,cc}] indent_style = tab indent_size = 4 tab_width = 8
I've added it to a couple of repos so far, where I needed it.
1. Should we improve these declarations? (Add trim_trailing_whitespace[3], insert_final_newline) 2. Should we add a master copy to yast-devtools? (It would need to be copied manually, but it would serve as the representation of the current best practice)
[1]: https://en.wikipedia.org/wiki/Visual_Studio_Code [2]: https://en.wikipedia.org/wiki/GNU_Emacs [3]: https://github.com/yast/yast-packager/pull/441#discussion_r294163050 thanks to Lada for prompting this
-- To unsubscribe, e-mail: yast-devel+unsubscribe@opensuse.org To contact the owner, e-mail: yast-devel+owner@opensuse.org
Dne 21. 06. 19 v 15:31 José Iván López González napsal(a):
Regarding the rules, I would add both: trim_trailing_whitespace and insert_final_newline. I see none case where they could be a problem.
The GFM (GitHub Flavored Markdown) allows using two (or more) trailing spaces as a hard line break. IIRC I have used that in some *.md file. On the other hand GFM allows using a trailing backslash (\) for that so it should be easy to replace it if needed. See https://github.github.com/gfm/#hard-line-breaks fore more details. -- Ladislav Slezák YaST Developer SUSE LINUX, s.r.o. Corso IIa Křižíkova 148/34 18600 Praha 8 -- To unsubscribe, e-mail: yast-devel+unsubscribe@opensuse.org To contact the owner, e-mail: yast-devel+owner@opensuse.org
participants (3)
-
José Iván López González
-
Ladislav Slezak
-
Martin Vidner