vim:xdg: Fix updating spellfile through modeline

Setting `&spellfile` from the modeline is not allowed and will result in
an `E523: not allowed here` error. Fix the updating of the file by
additionally having an autocommand on BufWinEnter (i.e. after the
modeline was read).

TODO: Also get rid of the error message when rereading the modeline (:e)
This commit is contained in:
2024-10-19 17:57:47 +02:00
parent d142200a6c
commit f4d3a4364b

View File

@@ -46,8 +46,15 @@ endif
let &spellfile = $XDG_DATA_HOME . '/vim/spell/' . &spelllang . '.utf-8.add'
augroup xdg_spellfile
au!
" TODO: This throws `E523: not allowed here` on `:e` as the modeline is
" reread. Suppress or better check for sandbox/modeline before
" executing
au OptionSet spelllang let &spellfile =
\ $XDG_DATA_HOME . '/vim/spell/' . v:option_new . '.utf-8.add'
" NOTE: Changing &spellfile is not allowed from a modeline, so we need to
" update it manually after the modeline was read
au BufWinEnter * let &spellfile =
\ $XDG_DATA_HOME . '/vim/spell/' . &spelllang . '.utf-8.add'
augroup end
set runtimepath-=~/.vim runtimepath^=$XDG_CONFIG_HOME/vim