git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH v2 1/2] Add project-wide .vimrc configuration

From
Felipe Contreras <felipe.contreras@gmail.com>
Date
Dec 10, 2020, 01:55 UTC
Message-ID
<CAMP44s19FKYT5LNUxbGZP3czFmhe9t5B-FAfH+V2btNvMNW31g@mail.gmail.com>
In-Reply-To
<X9EI8c9yeX136ewm@coredump.intra.peff.net>
On Wed, Dec 9, 2020 at 11:27 AM Jeff King <peff@peff.net> wrote:
Show 13 quoted lines
>
> On Wed, Dec 09, 2020 at 12:55:36AM -0600, Felipe Contreras wrote:
>
> > +augroup git
> > +     au BufRead,BufNewFile */Documentation/*.txt set filetype=asciidoc
> > +
> > +     au FileType c setl noexpandtab tabstop=8 shiftwidth=0 cino=(s,:0,l1,t0
>
> I had to read up on a few of these settings, and I'm still slightly
> puzzled:
>
>   - I generally leave shiftwidth=8, but reading the documentation says
>     that 0 is equivalent to "1 tabstop". So that should be equivalent.
Yes. It is.

If you read the help of tabstop [1] it says there are four main ways of using tab, and we are using the fourth one: "always set 'tabstop' and 'shiftwidth' to the same value, and 'noexpandtab'."

Other projects use a different tabstop, and expandtab (mode 2), however, I have *never* found a use case where it made sense to have a different shiftwidth than tabstop. And it gets tedious to *always* do ts=X sw=X, when you can just do sw=0 in your ~/.vimrc, and ts=X per project.

>   - I've been using "(0" for years for my git work (which indents to
>     align new lines with the unclosed parenthesis). I'm not quite sure
>     what "(s" means. The documentation says "1s" would be "one
>     shiftwidth". Is just "s" the same?

Yes. If you read CodingGuidelines it says there are two schools of thought when it comes to splitting long logical lines. The first example is "(s", the second one is "(0".

The reason why I prefer "(s" is that this is more commonly used in the Linux kernel. However, it's not quite the same in vim (when there's more than one parenthesis). I've planned to contact vim developers about that, but I haven't yet. Just for that reason it might make sense to use "(0" for the project.

Show 25 quoted lines
>   - I also have ":0", which doesn't indent case labels. Matches our
>     style.
>
>   - I didn't have "l" set myself. I never noticed because it only
>     matters if you open a case with an extra brace, which is relatively
>     rare. For non-vim folks, it is preferring:
>
>         switch (foo) {
>         case 0: {
>                 break;
>         }
>
>     to:
>
>         switch (foo) {
>         case 0: {
>                         break;
>                 }
>
>     which seems consistent with our style. So I think that is worth
>     doing.
>
>   - t0 is specifying not to indent function return types when they
>     appear on a separate line. But our style is not to put those return
>     types on a separate line, anyway. Do we need this?

Right. I recall at some point it was annoying me that types were auto indented magically at wrong times. Testing "ts" that doesn't seem to happen anymore, but it also doesn't seem to be working at all.

Do you see some difference from "t0" and "ts" with:
  void
  main(void) { }
Cheers.
[1] https://vimhelp.org/options.txt.html#%27tabstop%27
-- 
Felipe Contreras
Previous: Jeff KingNext: Jeff King
Message 7 of 22 in “vim: configuration and sharness syntax”
  1. 0/2 vim: configuration and sharness syntaxFelipe Contreras, Dec 9, 2020
  2. 1/2 Add project-wide .vimrc configurationFelipe Contreras, Dec 9, 2020
  3. Christian BrabandtDec 9, 2020
  4. Felipe ContrerasDec 9, 2020
  5. Christian BrabandtDec 9, 2020
  6. Jeff KingDec 9, 2020
  7. Felipe ContrerasDec 10, 2020
  8. Jeff KingDec 10, 2020
  9. Felipe ContrerasDec 11, 2020
  10. brian m. carlsonDec 10, 2020
  11. Felipe ContrerasDec 11, 2020
  12. brian m. carlsonDec 11, 2020
  13. Felipe ContrerasDec 11, 2020
  14. Jeff KingDec 15, 2020
  15. Felipe ContrerasDec 15, 2020
  16. Jeff KingDec 15, 2020
  17. Felipe ContrerasDec 15, 2020
  18. 2/2 contrib: vim: add sharness syntax fileFelipe Contreras, Dec 9, 2020
  19. Eric SunshineDec 9, 2020
  20. Felipe ContrerasDec 9, 2020
  21. Jeff KingDec 9, 2020
  22. Felipe ContrerasDec 10, 2020

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.