1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
if exists('loaded_spellfile_local') || $MYVIM ==# ''
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
nnoremap <buffer> zG 2zg
endfunction
command! AddLocalSpellFile
\ call AddLocalSpellFile()
augroup spellfile_local
autocmd BufRead *
\ AddLocalSpellfile
augroup END
|