Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a quick way to rebuild spell files from wordlists?

Tags:

vim

Is there any way to tell vim to update spell files for all languages listed in 'spelllang' to pick up wordlist changes from outside of vim?

I've started checking a wordlist file into git since I'm tired of adding the same words on multiple computers. I don't want to add the spell file to the git repo since merges would be ugly every time, but whenever I open vim, any recent updates are ignored until I do something from inside vim that rebuilds the spell file, such as zg to add a word to the dictionary.

like image 894
Mu Mind Avatar asked Dec 02 '14 01:12

Mu Mind


3 Answers

I've solved this by adding the *.spl to the .gitignore file and then in the vimrc (which is also synced with GIT, add:

for d in glob('~/.vim/spell/*.add', 1, 1)
    if filereadable(d) && (!filereadable(d . '.spl') || getftime(d) > getftime(d . '.spl'))
        exec 'mkspell! ' . fnameescape(d)
    endif
endfor

source: https://vi.stackexchange.com/questions/5050/how-to-share-vim-spellchecking-additions-between-multiple-machines

This will cause vim to rebuild the .spl file each time the .add file has been updated when vim is started.

like image 138
Paul in 't Hout Avatar answered Oct 26 '22 08:10

Paul in 't Hout


I've created a Vim plugin for this. It finds the path to the spell folders automatically and then calls mkspell on any word lists it finds at startup to regenerate the spell files. It also creates .gitignore and .gitattributes files in the spell directories to exclude binary spell files and to use Git's union merge driver to avoid conflicts when merging spell files from two different machines. Thanks to Sato Katsura for the mkspell example.

https://github.com/micarmst/vim-spellsync

like image 22
micarmst Avatar answered Oct 26 '22 08:10

micarmst


If you only have a single spell file, just put this in your .vimrc:

exec 'silent mkspell! ' . &spellfile . '.spl'
like image 42
cmcginty Avatar answered Oct 26 '22 09:10

cmcginty