diff options
author | Tom Ryder <tom@sanctum.geek.nz> | 2019-06-10 14:07:20 +1200 |
---|---|---|
committer | Tom Ryder <tom@sanctum.geek.nz> | 2019-06-10 14:07:20 +1200 |
commit | 1e75ff9b46748ec7fb8757efa233744cc8edb79d (patch) | |
tree | ee14d2044f2ffb499d1cf2bf65ada5a4d7031565 /vim/plugin/spellfile_local.vim | |
parent | Add uncommented code for spellfile extension (diff) | |
download | dotfiles-1e75ff9b46748ec7fb8757efa233744cc8edb79d.tar.gz dotfiles-1e75ff9b46748ec7fb8757efa233744cc8edb79d.zip |
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.
Diffstat (limited to 'vim/plugin/spellfile_local.vim')
-rw-r--r-- | vim/plugin/spellfile_local.vim | 26 |
1 files changed, 26 insertions, 0 deletions
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 <buffer> zG 2zg |