diff --git a/.config/vim/xdg.vim b/.config/vim/xdg.vim index 46303a8..211f061 100644 --- a/.config/vim/xdg.vim +++ b/.config/vim/xdg.vim @@ -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