I have this in my Vim configuration file:

set spell
set spelllang=fr

When I start Vim, I get an error:

Warning: Cannot find word list "fr.utf-8.spl" or "fr.ascii.spl"
Press ENTER or type command to continue

Notice that Vim does not offer to download the missing spellfiles. It is only when I manually type :set spelllang=fr, does Vim offer to download the missing spellfile(s):

Cannot find spell file for "fr" in utf-8
Do you want me to try downloading it?
(Y)es, [N]o:

Is there a way to make Vim prompt the user to download missing spellfiles when starting Vim, instead of making it necesaary to manually type :set spelllang=... to make Vim ask?

(Vim version: 8.1.2269 on Ubuntu 20.04).

  • I wonder if this question got to HNQ due to the reading of "spellfiles" as "spellbooks" by the visitors :) – Ruslan Jan 25 at 22:05

Well, the point is SpellFileMissing event is captured by a plugin, but all plugins are loaded after your vimrc has been processed.

In principle, we can delay options setting until :h VimEnter

if !v:vim_did_enter
    autocmd VimEnter * ++once ++nested set spell spelllang=fr

But, in fact, it's much cleaner and simpler only set spelllang=fr in your vimrc, but not set spell. You can switch it on later manually or per ftplugin(s) as needed.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.