main/vim: default /etc/vim/vimrc prevents user syntax file overrides from running
Package Information
- Package name: vim
- Package version: 9.1.0414-r0
- Alpine version: 3.20.0
- Alpine architecture: x86_64
Summary
While in the process of migrating away from Neovim (largely due to the issues
discussed in #16132 (closed)), I noticed that the provided /etc/vim/vimrc
file causes
some undesirable (and unintuitive) behavior. Specifically, the syntax on
line
causes syntax files to be sourced immediately, rather than obeying the order of
'runtimepath'
. This can be verified using :scriptnames
.
By convention, syntax files set b:current_syntax
when they are sourced, and
syntax files that are sourced later will exit early if they see the variable has
already been set. Most runtime files follow a similar scheme.
Normally, a user would be able to override syntax files by putting them
somewhere in ~/.vim
or another directory early in 'runtimepath'
. These files
would set b:current_syntax
and any built-in syntax files for the same filetype
would exit early. However, due to the syntax on
line in /etc/vim/vimrc
, the
built-in syntax files are given higher priority instead, and any user overrides
do not run.
Unfortunately, because /etc/vim/vimrc.local
is sourced afterwards, setting
syntax off
there and re-enabling it in your personal vimrc does not work
either. The only solution would be to run Vim with the -u
option or something
similar to skip /etc/vim/vimrc
altogether, but this is quite brittle and has a
tendency to break things.
Removing the line in question from /etc/vim/vimrc
fixes the issue.