aboutsummaryrefslogtreecommitdiff
path: root/vim/plugin/spellfile_local.vim
blob: 583df98631ebeb30941c0f098bdb91d30570166e (plain) (blame)
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
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