On Thu, Jan 27, 2022 at 02:22:40AM +0200, Nir Soffer wrote:
This project uses non standard 2 spaces indent in some parts (lib,
copy,
info) and tabs in others (e.g. golang/*.go). This can be solved by local
configuration or adding metadata comments to files, but there is a
better solution - editorconfig[1].
Add .editorconfig file that use 2 spaces indent by default, and tabs for
the Go sources. This is not complete yet, but good enough for the areas
I usually touch.
People that do not use an editorconfig plugin are not affected by this
change. People that want to use it can install a plugin[2][3] and
improve the configuration as needed.
[1]
https://editorconfig.org/
[2]
https://github.com/editorconfig/editorconfig-vim#readme
[3]
https://github.com/editorconfig/editorconfig-emacs#readme
Signed-off-by: Nir Soffer <nsoffer(a)redhat.com>
---
.editorconfig | 19 +++++++++++++++++++
Makefile.am | 1 +
2 files changed, 20 insertions(+)
create mode 100644 .editorconfig
diff --git a/.editorconfig b/.editorconfig
new file mode 100644
index 00000000..30e5f655
--- /dev/null
+++ b/.editorconfig
@@ -0,0 +1,19 @@
+#
https://editorconfig.org/
+
+root = true
+
+[*]
+indent_style = space
+indent_size = 2
+insert_final_newline = true
+trim_trailing_whitespace = true
+charset = utf-8
+
+[{*.go,go.mod,go.sum}]
+# Match gofmt style
+indent_style = tab
+indent_size = 4
+
+[{Makefile,Makefile.in,Makefile.am}]
+# Make requires tabs.
+indent_style = tab
diff --git a/Makefile.am b/Makefile.am
index 45316b6d..a76ee379 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -14,20 +14,21 @@
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
include $(top_srcdir)/common-rules.mk
ACLOCAL_AMFLAGS = -I m4
EXTRA_DIST = \
.dir-locals.el \
+ .editorconfig \
.gitattributes \
.gitignore \
html/pod.css \
scripts/git.orderfile \
SECURITY \
$(NULL)
CLEANFILES += m4/*~
SUBDIRS = \
ACK
Rich.
--
Richard Jones, Virtualization Group, Red Hat
http://people.redhat.com/~rjones
Read my programming and virtualization blog:
http://rwmj.wordpress.com
virt-top is 'top' for virtual machines. Tiny program with many
powerful monitoring features, net stats, disk stats, logging, etc.
http://people.redhat.com/~rjones/virt-top