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' let &spellfile = $XDG_DATA_HOME . '/vim/spell/' . &spelllang . '.utf-8.add'
augroup xdg_spellfile augroup xdg_spellfile
au! au!
" TODO: This throws `E523: not allowed here` on `:e` as the modeline is " NOTE: `silent!` needed, as this throws `E523: not allowed here` when
" reread. Suppress or better check for sandbox/modeline before " rereading the modeline
" executing " TODO: Check if executed from sandbox/modeline before executing instead
au OptionSet spelllang let &spellfile = " of suppressing the error
\ $XDG_DATA_HOME . '/vim/spell/' . v:option_new . '.utf-8.add' 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 " NOTE: Changing &spellfile is not allowed from a modeline, so we need to
" update it manually after the modeline was read " update it manually after the modeline was read
au BufWinEnter * let &spellfile = 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 augroup end
set runtimepath-=~/.vim runtimepath^=$XDG_CONFIG_HOME/vim set runtimepath-=~/.vim runtimepath^=$XDG_CONFIG_HOME/vim