vim:xdg: Fix E474 when &spl has multiple languages

Escape comma to not get

    E474: Invalid argument
This commit is contained in:
2025-05-20 11:44:37 +02:00
parent 2aeb664692
commit d7289e1d69

View File

@@ -46,15 +46,16 @@ 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: `silent!` needed, as this throws `E523: not allowed here` when
" rereading the modeline
" TODO: Check if executed from sandbox/modeline before executing instead
" of suppressing the error
au OptionSet spelllang silent! let &spellfile =
\ $XDG_DATA_HOME . '/vim/spell/' . escape(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'
\ $XDG_DATA_HOME . '/vim/spell/' . escape(&spelllang, ',') . '.utf-8.add'
augroup end
set runtimepath-=~/.vim runtimepath^=$XDG_CONFIG_HOME/vim