aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJustin M. Keyes <justinkz@gmail.com>2019-11-10 12:35:45 -0800
committerJustin M. Keyes <justinkz@gmail.com>2019-11-10 12:35:45 -0800
commitb9c9283f729c60d98634587190eb14c6bbf428e5 (patch)
tree7bd9fb5832c3cf8ca6e2c2aeac7bec4b157612ea
parent06a020af09976e1a9db4da3ece547db32f4153e1 (diff)
downloadrneovim-b9c9283f729c60d98634587190eb14c6bbf428e5.tar.gz
rneovim-b9c9283f729c60d98634587190eb14c6bbf428e5.tar.bz2
rneovim-b9c9283f729c60d98634587190eb14c6bbf428e5.zip
spellfile.vim: improve error message for missing spellfile
Problem: If spellfile is missing, then "set spell" in modeline/sandbox fails with a non-obvious error. Solution: Check for sandbox early and give a meaningful error. Fixes #11359 Test case: # test.latex has `% vim: set spelllang=hu:` # no spell file for `hu` yet! nvim -u NORC --cmd 'autocmd FileType tex setlocal spell' --cmd 'set modeline' test.latex Before: No spell file for "hu" in utf-8 Download it? Downloading hu.utf-8.spl... Error detected while processing /usr/local/share/nvim/runtime/autoload/netrw.vim: line 583: E12: Command not allowed from exrc/vimrc in current dir or tag search: au WinEnter *^Iif &ft == "netrw"|call s:NetrwInsureWinVars()|endif Error detected while processing function spellfile#LoadFile[60]..spellfile#Nread[13]..netrw#NetRead[4]..<SNR>67_NetrwOptionsSave: line 66: E171: Missing :endif Error detected while processing function spellfile#LoadFile[60]..spellfile#Nread: line 13: E171: Missing :endif Error detected while processing function spellfile#LoadFile: line 60: E171: Missing :endif Error detected while processing modelines: line 1: E12: Command not allowed from exrc/vimrc in current dir or tag search After: Error detected while processing function spellfile#LoadFile: line 5: E605: Exception not caught: Cannot download spellfile in sandbox/modeline. Try ":set spell" from the cmdline. Error detected while processing modelines: line 1: E12: Command not allowed from exrc/vimrc in current dir or tag search
-rw-r--r--runtime/autoload/spellfile.vim7
1 files changed, 7 insertions, 0 deletions
diff --git a/runtime/autoload/spellfile.vim b/runtime/autoload/spellfile.vim
index c0ef51cdfe..d098902305 100644
--- a/runtime/autoload/spellfile.vim
+++ b/runtime/autoload/spellfile.vim
@@ -13,6 +13,13 @@ let s:spellfile_URL = '' " Start with nothing so that s:donedict is reset.
" This function is used for the spellfile plugin.
function! spellfile#LoadFile(lang)
+ " Check for sandbox/modeline. #11359
+ try
+ :!
+ catch /\<E12\>/
+ throw 'Cannot download spellfile in sandbox/modeline. Try ":set spell" from the cmdline.'
+ endtry
+
" If the netrw plugin isn't loaded we silently skip everything.
if !exists(":Nread")
if &verbose