diff options
author | Tom Ryder <tom@sanctum.geek.nz> | 2019-06-10 14:05:01 +1200 |
---|---|---|
committer | Tom Ryder <tom@sanctum.geek.nz> | 2019-06-10 14:05:14 +1200 |
commit | c0bab95ec716a6b68b11539c205623ed11d8c450 (patch) | |
tree | 1b1c41e87ee671b58edd47c349c4bbc732b00804 | |
parent | Correct a badly copy-pasted sentence (diff) | |
download | dotfiles-c0bab95ec716a6b68b11539c205623ed11d8c450.tar.gz dotfiles-c0bab95ec716a6b68b11539c205623ed11d8c450.zip |
Add uncommented code for spellfile extension
-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 |