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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user