tpope / vim-git

Vim Git runtime files
http://www.vim.org/scripts/script.php?script_id=1654
589 stars 78 forks source link

Line in commit message that starts with a number confuses the auto indentation #83

Closed ericonr closed 2 years ago

ericonr commented 2 years ago

Originally in https://github.com/neovim/neovim/issues/18396

Steps to reproduce:

The commit message in question:

fpga_spi: guarantee board_diagnostic_t alignment

fpga_spi.c reads from this struct by aliasing it to an uint32_t pointer
and using that to iterate through it. That means it should be aligned to
4 bytes, to so the reads don't generate faults, and that its size should
be a multiple of 4, otherwise we'd have to deal with defining incomplete
reads for the last element.

The commit body is changed to:

fpga_spi.c reads from this struct by aliasing it to an uint32_t pointer
and using that to iterate through it. That means it should be aligned to
4 bytes, to so the reads don't generate faults, and that its size should
  be a multiple of 4, otherwise we'd have to deal with defining
  incomplete reads for the last element.

Per https://github.com/neovim/neovim/issues/18396#issuecomment-1116741530 , this might not be possible to fix (or even considered a bug):

This is because the ftplugin for gitcommit sets formatoptions+=n and formatlistpat

But I'd like to bring it up to confirm.

tpope commented 2 years ago

Vim's default 'formatlistpat' does this. You can change it in your vimrc to achieve the desired effect:

set formatlistpat=^\\s*\\d\\+[\\]:.)}]\\s\\+

I'm on the fence about whether ftplugin/gitcommit.vim should itself change this. The problem isn't "the default 'formatlistpat' is bad for gitcommit files" but rather "the default 'formatlistpat' is bad for almost all files." I suppose we can try it on master for a bit and see if anyone complains.

ericonr commented 2 years ago

Thanks you!