Re: [PATCH v4] Add .editorconfig file for basic formatting

From: Íñigo Huguet
Date: Wed Jun 14 2023 - 07:35:02 EST


On Fri, Jun 9, 2023 at 12:49 PM Miguel Ojeda
<miguel.ojeda.sandonis@xxxxxxxxx> wrote:
>
> On Fri, Jun 9, 2023 at 10:49 AM Íñigo Huguet <ihuguet@xxxxxxxxxx> wrote:
> >
> > This is a valid option, indeed, but In my opinion we are overlooking this.
> >
> > Adding an .editorconfig will not silently reconfigure the editors of
> > everyone because for most editors you need to install a plugin to use
> > it. In my opinion, that's enough "opt-in". Here is the list of editors
> > that have built-in support, and those that need a plugin install. I
> > don't think that those with built-in support are widely used for
> > kernel development, and many of them allow to disable the feature.
>
> It is true that some of the big ones (Emacs, Vim, VS Code...) do not,
> but e.g. NeoVim and Kate (`KTextEditor`) both seem to support it, and
> those are used by some kernel developers. In particular, NeoVim says
> it enables it by default, if I am reading correctly.
>
> But perhaps those two behave as we want.

As I can see, NeoVim allows to disable it, which is good enough for
me, but Kate doesn't.

>
> > I see this as the exact same case as adding a .clang-format file, as
> > we already have. Some editors, either built-in or via plugin,
> > automatically reformat code when this file is present. And it's far
> > more "intrusive" than editorconfig.
>
> I do not recall any complaints about code getting reformatted
> automatically -- which editors are you referring to? (i.e. that
> natively reformat the code, in its default configuration).

Maybe not in default configuration, but people might have it enabled
in their editors anyway, so suddenly appearing a .clangformat in the
repo could cause it. My point is that this is a very similar case.

> In any case, it was a slightly more constrained case: `clang-format`
> (and LLVM/Clang) needed to be installed with a new enough version,
> which may not have been too common back then, and it ""only"" applied
> to C code.
>
> Cheers,
> Miguel
>


--
Íñigo Huguet