From: "Mickaël Salaün" <mic@digikod.net>
To: "Íñigo Huguet" <ihuguet@redhat.com>, ojeda@kernel.org, danny@kdrag0n.dev
Cc: masahiroy@kernel.org, jgg@nvidia.com,
linux-kernel@vger.kernel.org, corbet@lwn.net, joe@perches.com,
linux@rasmusvillemoes.dk, willy@infradead.org,
mailhol.vincent@wanadoo.fr
Subject: Re: [PATCH v4] Add .editorconfig file for basic formatting
Date: Fri, 2 Jun 2023 17:37:31 +0200 [thread overview]
Message-ID: <d8afcd26-af64-b062-8e40-b59eff9b4180@digikod.net> (raw)
In-Reply-To: <20230601075333.14021-1-ihuguet@redhat.com>
Looks good to me, thanks!
Acked-by: Mickaël Salaün <mic@digikod.net>
It would be nice to have a script to check files and output a diff if
they are not in line with this configuration. That could also be used to
measure how many files are compliant with these rules, and add this
stats in the commit message.
For some reasons, maintainers may want to exclude some files from these
constraints. It would be useful to add some documentation explaining how
to do it.
On 01/06/2023 09:53, Íñigo Huguet wrote:
> EditorConfig is a specification to define the most basic code formatting
> stuff, and it's supported by many editors and IDEs, either directly or
> via plugins, including VSCode/VSCodium, Vim, emacs and more.
>
> It allows to define formatting style related to indentation, charset,
> end of lines and trailing whitespaces. It also allows to apply different
> formats for different files based on wildcards, so for example it is
> possible to apply different configs to *.{c,h}, *.py and *.rs.
>
> In linux project, defining a .editorconfig might help to those people
> that work on different projects with different indentation styles, so
> they cannot define a global style. Now they will directly see the
> correct indentation on every fresh clone of the project.
>
> See https://editorconfig.org
>
> Co-developed-by: Danny Lin <danny@kdrag0n.dev>
> Signed-off-by: Danny Lin <danny@kdrag0n.dev>
> Signed-off-by: Íñigo Huguet <ihuguet@redhat.com>
> ---
> v2:
> - added special rule for patch files so it doesn't remove
> trailing whitespaces, making them unusable.
> v3:
> - moved all rules from [*] section to all the individual
> sections so they doesn't affect to unexpected files.
> - added some extensions and files from a patch from Danny
> Lin that didn't get to be merged:
> https://lore.kernel.org/lkml/20200703073143.423557-1-danny@kdrag0n.dev/
> However, the following file types hasn't been added
> because they don't have a clear common style:
> rst,pl,cocci,tc,bconf,svg,xsl,manual pages
> v4:
> - Analyzed with a script the styles used by different file types
> - Added rules for awd, dts, dtsi, dtso, s, S
> - Removed rules for rb and pm that has very few files in the tree
> - Removed rules for tools/perf/scripts/*/bin/*
> - Changed rules for py to better match the 2 styles that are present in
> the tree: 4 spaces by default and tabs for files in subdirectories
> tools/{perf,power,rcu,testing/kunit}
> ---
> .editorconfig | 32 ++++++++++++++++++++++++++
> .gitignore | 1 +
> Documentation/process/4.Coding.rst | 4 ++++
> Documentation/process/coding-style.rst | 4 ++++
> 4 files changed, 41 insertions(+)
> create mode 100644 .editorconfig
>
> diff --git a/.editorconfig b/.editorconfig
> new file mode 100644
> index 000000000000..854773350cc5
> --- /dev/null
> +++ b/.editorconfig
> @@ -0,0 +1,32 @@
> +# SPDX-License-Identifier: GPL-2.0-only
> +
> +root = true
> +
> +[{*.{awk,c,dts,dtsi,dtso,h,mk,s,S},Kconfig,Makefile,Makefile.*}]
> +charset = utf-8
> +end_of_line = lf
> +trim_trailing_whitespace = true
> +insert_final_newline = true
> +indent_style = tab
> +indent_size = 8
> +
> +[*.{json,py,rs}]
> +charset = utf-8
> +end_of_line = lf
> +trim_trailing_whitespace = true
> +insert_final_newline = true
> +indent_style = space
> +indent_size = 4
> +
> +# this must be below the general *.py to overwrite it
> +[tools/{perf,power,rcu,testing/kunit}/**.py,]
> +indent_style = tab
> +indent_size = 8
> +
> +[*.yaml]
> +charset = utf-8
> +end_of_line = lf
> +trim_trailing_whitespace = unset
> +insert_final_newline = true
> +indent_style = space
> +indent_size = 2
> diff --git a/.gitignore b/.gitignore
> index 70ec6037fa7a..e4b3fe1d029b 100644
> --- a/.gitignore
> +++ b/.gitignore
> @@ -100,6 +100,7 @@ modules.order
> #
> !.clang-format
> !.cocciconfig
> +!.editorconfig
> !.get_maintainer.ignore
> !.gitattributes
> !.gitignore
> diff --git a/Documentation/process/4.Coding.rst b/Documentation/process/4.Coding.rst
> index 1f0d81f44e14..c2046dec0c2f 100644
> --- a/Documentation/process/4.Coding.rst
> +++ b/Documentation/process/4.Coding.rst
> @@ -66,6 +66,10 @@ for aligning variables/macros, for reflowing text and other similar tasks.
> See the file :ref:`Documentation/process/clang-format.rst <clangformat>`
> for more details.
>
> +Some basic editor settings, such as indentation and line endings, will be
> +set automatically if you are using an editor that is compatible with
> +EditorConfig. See the official EditorConfig website for more information:
> +https://editorconfig.org/
>
> Abstraction layers
> ******************
> diff --git a/Documentation/process/coding-style.rst b/Documentation/process/coding-style.rst
> index 007e49ef6cec..ec96462fa8be 100644
> --- a/Documentation/process/coding-style.rst
> +++ b/Documentation/process/coding-style.rst
> @@ -735,6 +735,10 @@ for aligning variables/macros, for reflowing text and other similar tasks.
> See the file :ref:`Documentation/process/clang-format.rst <clangformat>`
> for more details.
>
> +Some basic editor settings, such as indentation and line endings, will be
> +set automatically if you are using an editor that is compatible with
> +EditorConfig. See the official EditorConfig website for more information:
> +https://editorconfig.org/
>
> 10) Kconfig configuration files
> -------------------------------
next prev parent reply other threads:[~2023-06-02 15:38 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-06-01 7:53 Íñigo Huguet
2023-06-02 15:37 ` Mickaël Salaün [this message]
2023-06-04 20:49 ` Miguel Ojeda
2023-06-09 7:50 ` Jonathan Corbet
2023-06-09 8:23 ` Miguel Ojeda
2023-06-09 8:49 ` Íñigo Huguet
2023-06-09 8:50 ` Íñigo Huguet
2023-06-09 10:49 ` Miguel Ojeda
2023-06-14 11:33 ` Íñigo Huguet
2023-06-09 13:23 ` Mickaël Salaün
2023-06-14 11:40 ` Íñigo Huguet
2023-06-14 12:08 ` Rasmus Villemoes
2023-06-14 12:53 ` Vincent MAILHOL
2023-06-14 13:04 ` Íñigo Huguet
2023-06-15 2:40 ` Vincent MAILHOL
2023-06-15 6:35 ` Íñigo Huguet
2023-10-11 7:36 ` Vincent MAILHOL
2023-10-23 2:28 ` Jonathan Corbet
2023-10-23 6:18 ` Vincent MAILHOL
2023-10-23 6:26 ` Íñigo Huguet
2023-12-11 17:50 ` Masahiro Yamada
2024-06-02 15:30 ` Mateusz Guzik
2024-06-02 16:28 ` Miguel Ojeda
2024-06-02 18:17 ` Joe Perches
2024-06-03 12:18 ` Jason Gunthorpe
2024-06-03 12:52 ` Mateusz Guzik
2024-06-03 13:38 ` Miguel Ojeda
2024-06-03 15:09 ` Mateusz Guzik
2024-06-11 6:44 ` Greg KH
2024-01-23 20:03 ` andy.shevchenko
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=d8afcd26-af64-b062-8e40-b59eff9b4180@digikod.net \
--to=mic@digikod.net \
--cc=corbet@lwn.net \
--cc=danny@kdrag0n.dev \
--cc=ihuguet@redhat.com \
--cc=jgg@nvidia.com \
--cc=joe@perches.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@rasmusvillemoes.dk \
--cc=mailhol.vincent@wanadoo.fr \
--cc=masahiroy@kernel.org \
--cc=ojeda@kernel.org \
--cc=willy@infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®