diff options
-rw-r--r-- | IDEAS.md | 4 | ||||
-rw-r--r-- | vim/vimrc | 22 |
2 files changed, 22 insertions, 4 deletions
@@ -33,7 +33,3 @@ Ideas some point * I'd like a Git hook that pre-fills out "Version X.Y.Z" if making an annotated tag named `vX.Y.Z`. -* I'd like to make the zG command in Vim a bit more useful by maintaining - a per-file cache of added words, indexed by path, mapping it to 2zg or 3zg - rather like Steve Losh does. I wouldn't think it would be too hard; - 'spellfile' is a buffer-local option. @@ -902,6 +902,28 @@ 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 <buffer> 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 |