aboutsummaryrefslogtreecommitdiff
path: root/after/ftplugin/html/spelllang.vim
diff options
context:
space:
mode:
Diffstat (limited to 'after/ftplugin/html/spelllang.vim')
-rw-r--r--after/ftplugin/html/spelllang.vim33
1 files changed, 33 insertions, 0 deletions
diff --git a/after/ftplugin/html/spelllang.vim b/after/ftplugin/html/spelllang.vim
new file mode 100644
index 0000000..8f44384
--- /dev/null
+++ b/after/ftplugin/html/spelllang.vim
@@ -0,0 +1,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'