aboutsummaryrefslogblamecommitdiff
path: root/vim/plugin/spellfile_local.vim
blob: bb6421f2ac8f2a8d2579827e62c467add9030f9e (plain) (tree)
1
2
3
4
5
6
                                   



                              
                            






                                                     
                                  
 
                                   






                                                                   
                          
                          
           

                          
                                


                       
                           
           
if exists('loaded_spellfile_local')
  finish
endif
let loaded_spellfile_local = 1

Establish $MYVIM/cache/spell

let spellfile = join([
      \ substitute(v:lang, '_.*', '', ''),
      \ &encoding
      \ ], '.') . '.add'
execute 'set spellfile=$MYVIM/cache/spell/'.spellfile

Establish $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
  xnoremap <buffer> zG 2zg
endfunction

command! AddLocalSpellFile
      \ call AddLocalSpellFile()

augroup spellfile_local
  autocmd BufRead *
        \ AddLocalSpellFile
augroup END