aboutsummaryrefslogtreecommitdiff
path: root/vim/plugin/spellfile_local.vim
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2019-06-10 14:08:30 +1200
committerTom Ryder <tom@sanctum.geek.nz>2019-06-10 14:08:30 +1200
commita1e19c71f391679214fc932ad57b6c369f6ca369 (patch)
treea062f2c0df761559dd08c454622d50aa70814caa /vim/plugin/spellfile_local.vim
parentMerge branch 'release/v5.30.0' (diff)
parentBump VERSION (diff)
downloaddotfiles-5.31.0.tar.gz (sig)
dotfiles-5.31.0.zip
Merge branch 'release/v5.31.0'v5.31.0
* release/v5.31.0: Add an idea about spell files Move local spellfile out into ad-hoc plugin Add uncommented code for spellfile extension Correct a badly copy-pasted sentence Add a command prefix Add an idea Add an issue Change a word in a comment Expand on why I hate i_CTRL-C
Diffstat (limited to 'vim/plugin/spellfile_local.vim')
-rw-r--r--vim/plugin/spellfile_local.vim26
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