aboutsummaryrefslogtreecommitdiff
path: root/after/ftplugin/html/spelllang.vim
blob: 8f44384651ad0a9717648d1d6c0ffc2e26e103b6 (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
27
28
29
30
31
32
33
" html/spelllang.vim: Attempt to detect 'spelllang' from HTML buffers

" Don't load if running compatible or too old
if &compatible || v:version < 802
  finish
endif

" Don't load if already loaded
if exists('b:did_ftplugin_html_spelllang')
  finish
endif

" Flag as loaded
let b:did_ftplugin_html_spelllang = 1
let b:undo_ftplugin .= '|unlet b:did_ftplugin_html_spelllang'

" Set up hooks for divining 'spelllang' from lang= attributes
augroup html_spelllang
  if exists('##TextChanged')
    autocmd TextChanged *
          \ if &modified
          \|  call html#spelllang#Set()
          \|endif
  else
    autocmd InsertLeave *
          \ if &modified
          \|  call html#spelllang#Set()
          \|endif
  endif
augroup END
call html#spelllang#Set()
let b:undo_ftplugin .= '|execute ''autocmd! html_spelllang'''
      \ . '|augroup! html_spelllang'