From 1e75ff9b46748ec7fb8757efa233744cc8edb79d Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Mon, 10 Jun 2019 14:07:20 +1200 Subject: Move local spellfile out into ad-hoc plugin At some point I'll package this up properly as a little distribution, once I'm a bit more confident it's working correctly. So far, it's pretty neat. --- vim/plugin/spellfile_local.vim | 26 ++++++++++++++++++++++++++ vim/vimrc | 22 ---------------------- 2 files changed, 26 insertions(+), 22 deletions(-) create mode 100644 vim/plugin/spellfile_local.vim diff --git a/vim/plugin/spellfile_local.vim b/vim/plugin/spellfile_local.vim new file mode 100644 index 00000000..583df986 --- /dev/null +++ b/vim/plugin/spellfile_local.vim @@ -0,0 +1,26 @@ +if exists('loaded_spellfile_local') + finish +endif +let loaded_spellfile_local = 1 + +EnsureDir $MYVIM/cache/spell + +let spellfile = join([ + \ substitute(v:lang, '_.*', '', ''), + \ &encoding + \ ], '.') . '.add' +execute 'set spellfile=$MYVIM/cache/spell/'.spellfile + +EnsureDir $MYVIM/cache/spell/local + +function! AddLocalSpellfile() abort + let spellfile = join([ + \ substitute(expand('%:p'), '[^0-9A-Za-z_.-]', '%', 'g'), + \ substitute(v:lang, '_.*', '', ''), + \ &encoding + \ ], '.') . '.add' + setlocal spellfile< + execute 'setlocal spellfile+=$MYVIM/cache/spell/local/'.spellfile +endfunction! +autocmd vimrc BufRead * + \ call AddLocalSpellfile() | nnoremap zG 2zg diff --git a/vim/vimrc b/vim/vimrc index 737b9fd6..95ca61ae 100644 --- a/vim/vimrc +++ b/vim/vimrc @@ -902,28 +902,6 @@ if $MYVIM !=# '' && $MYVIM !~# '[*?[|;&<>\r\n]' set thesaurus^=$MYVIM/ref/thesaurus.txt endif -EnsureDir $MYVIM/cache/spell - -let spellfile = join([ - \ substitute(v:lang, '_.*', '', ''), - \ &encoding - \ ], '.') . '.add' -execute 'set spellfile=$MYVIM/cache/spell/'.spellfile - -EnsureDir $MYVIM/cache/spell/local - -function! AddLocalSpellfile() abort - let spellfile = join([ - \ substitute(expand('%:p'), '[^0-9A-Za-z_.-]', '%', 'g'), - \ substitute(v:lang, '_.*', '', ''), - \ &encoding - \ ], '.') . '.add' - setlocal spellfile< - execute 'setlocal spellfile+=$MYVIM/cache/spell/local/'.spellfile -ndfunction! -autocmd vimrc BufRead * - \ call AddLocalSpellfile() | nnoremap zG 2zg - " Use all of the filetype detection, plugin, and indent support available. " I define my own filetype.vim and scripts.vim files for filetype detection, " in a similar but not identical form to the stock runtime files. I also -- cgit v1.2.3