blob: 418da06a67317b70bb7d783eceb761db3fefb413 [file] [log] [blame]
Bram Moolenaar071d4272004-06-13 20:20:40 +00001" Vim filetype plugin file
2" Language: html
Bram Moolenaar5c736222010-01-06 20:54:52 +01003" Maintainer: Dan Sharp <dwsharp at users dot sourceforge dot net>
4" Last Changed: 20 Jan 2009
5" URL: http://dwsharp.users.sourceforge.net/vim/ftplugin
Bram Moolenaar071d4272004-06-13 20:20:40 +00006
7if exists("b:did_ftplugin") | finish | endif
8let b:did_ftplugin = 1
9
10" Make sure the continuation lines below do not cause problems in
11" compatibility mode.
12let s:save_cpo = &cpo
13set cpo-=C
14
Bram Moolenaara7241f52008-06-24 20:39:31 +000015setlocal matchpairs+=<:>
Bram Moolenaare37d50a2008-08-06 17:06:04 +000016setlocal commentstring=<!--%s-->
17setlocal comments=s:<!--,m:\ \ \ \ ,e:-->
18
19if exists("g:ft_html_autocomment") && (g:ft_html_autocomment == 1)
20 setlocal formatoptions-=t formatoptions+=croql
21endif
22
Bram Moolenaar071d4272004-06-13 20:20:40 +000023
Bram Moolenaarf193fff2006-04-27 00:02:13 +000024if exists('&omnifunc')
Bram Moolenaara7241f52008-06-24 20:39:31 +000025 " Distinguish between HTML versions
26 " To use with other HTML versions add another
27 " elseif condition to match proper DOCTYPE
28 setlocal omnifunc=htmlcomplete#CompleteTags
Bram Moolenaarf75a9632005-09-13 21:20:47 +000029
Bram Moolenaara7241f52008-06-24 20:39:31 +000030 if &filetype == 'xhtml'
31 let b:html_omni_flavor = 'xhtml10s'
32 else
33 let b:html_omni_flavor = 'html401t'
34 endif
35 let i = 1
36 let line = ""
37 while i < 10 && i < line("$")
38 let line = getline(i)
39 if line =~ '<!DOCTYPE.*\<DTD '
40 break
41 endif
42 let i += 1
43 endwhile
44 if line =~ '<!DOCTYPE.*\<DTD ' " doctype line found above
45 if line =~ ' HTML 3\.2'
46 let b:html_omni_flavor = 'html32'
47 elseif line =~ ' XHTML 1\.1'
48 let b:html_omni_flavor = 'xhtml11'
49 else " two-step detection with strict/frameset/transitional
50 if line =~ ' XHTML 1\.0'
51 let b:html_omni_flavor = 'xhtml10'
52 elseif line =~ ' HTML 4\.01'
53 let b:html_omni_flavor = 'html401'
54 elseif line =~ ' HTML 4.0\>'
55 let b:html_omni_flavor = 'html40'
56 endif
57 if line =~ '\<Transitional\>'
58 let b:html_omni_flavor .= 't'
59 elseif line =~ '\<Frameset\>'
60 let b:html_omni_flavor .= 'f'
61 else
62 let b:html_omni_flavor .= 's'
63 endif
64 endif
65 endif
Bram Moolenaarf193fff2006-04-27 00:02:13 +000066endif
Bram Moolenaar4a85b412006-04-23 22:40:29 +000067
Bram Moolenaar071d4272004-06-13 20:20:40 +000068" HTML: thanks to Johannes Zellner and Benji Fisher.
69if exists("loaded_matchit")
70 let b:match_ignorecase = 1
Bram Moolenaar071d4272004-06-13 20:20:40 +000071 let b:match_words = '<:>,' .
72 \ '<\@<=[ou]l\>[^>]*\%(>\|$\):<\@<=li\>:<\@<=/[ou]l>,' .
73 \ '<\@<=dl\>[^>]*\%(>\|$\):<\@<=d[td]\>:<\@<=/dl>,' .
74 \ '<\@<=\([^/][^ \t>]*\)[^>]*\%(>\|$\):<\@<=/\1>'
75endif
76
77" Change the :browse e filter to primarily show HTML-related files.
78if has("gui_win32")
Bram Moolenaar8299df92004-07-10 09:47:34 +000079 let b:browsefilter="HTML Files (*.html,*.htm)\t*.htm;*.html\n" .
Bram Moolenaar071d4272004-06-13 20:20:40 +000080 \ "JavaScript Files (*.js)\t*.js\n" .
81 \ "Cascading StyleSheets (*.css)\t*.css\n" .
82 \ "All Files (*.*)\t*.*\n"
83endif
84
85" Undo the stuff we changed.
Bram Moolenaare37d50a2008-08-06 17:06:04 +000086let b:undo_ftplugin = "setlocal commentstring< matchpairs< omnifunc< comments< formatoptions<" .
Bram Moolenaar071d4272004-06-13 20:20:40 +000087 \ " | unlet! b:match_ignorecase b:match_skip b:match_words b:browsefilter"
88
89" Restore the saved compatibility options.
90let &cpo = s:save_cpo
Bram Moolenaar84f72352012-03-11 15:57:40 +010091unlet s:save_cpo