Mailinglist Archive: yast-devel (48 mails)

< Previous Next >
[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.EditorConfig

# 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
< Previous Next >