blob: 4797f4b4604182857911b841d6c79ba23fcbe548 [file] [log] [blame]
Bram Moolenaar071d4272004-06-13 20:20:40 +00001" Vim filetype plugin file
2" Language: html
3" Maintainer: Dan Sharp <dwsharp at hotmail dot com>
Bram Moolenaara7241f52008-06-24 20:39:31 +00004" Last Changed: 2007 Nov 20
Bram Moolenaar071d4272004-06-13 20:20:40 +00005" URL: http://mywebpage.netscape.com/sharppeople/vim/ftplugin
6
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
15setlocal commentstring=<!--%s-->
Bram Moolenaara7241f52008-06-24 20:39:31 +000016setlocal matchpairs+=<:>
Bram Moolenaar071d4272004-06-13 20:20:40 +000017
Bram Moolenaarf193fff2006-04-27 00:02:13 +000018if exists('&omnifunc')
Bram Moolenaara7241f52008-06-24 20:39:31 +000019 " Distinguish between HTML versions
20 " To use with other HTML versions add another
21 " elseif condition to match proper DOCTYPE
22 setlocal omnifunc=htmlcomplete#CompleteTags
Bram Moolenaarf75a9632005-09-13 21:20:47 +000023
Bram Moolenaara7241f52008-06-24 20:39:31 +000024 if &filetype == 'xhtml'
25 let b:html_omni_flavor = 'xhtml10s'
26 else
27 let b:html_omni_flavor = 'html401t'
28 endif
29 let i = 1
30 let line = ""
31 while i < 10 && i < line("$")
32 let line = getline(i)
33 if line =~ '<!DOCTYPE.*\<DTD '
34 break
35 endif
36 let i += 1
37 endwhile
38 if line =~ '<!DOCTYPE.*\<DTD ' " doctype line found above
39 if line =~ ' HTML 3\.2'
40 let b:html_omni_flavor = 'html32'
41 elseif line =~ ' XHTML 1\.1'
42 let b:html_omni_flavor = 'xhtml11'
43 else " two-step detection with strict/frameset/transitional
44 if line =~ ' XHTML 1\.0'
45 let b:html_omni_flavor = 'xhtml10'
46 elseif line =~ ' HTML 4\.01'
47 let b:html_omni_flavor = 'html401'
48 elseif line =~ ' HTML 4.0\>'
49 let b:html_omni_flavor = 'html40'
50 endif
51 if line =~ '\<Transitional\>'
52 let b:html_omni_flavor .= 't'
53 elseif line =~ '\<Frameset\>'
54 let b:html_omni_flavor .= 'f'
55 else
56 let b:html_omni_flavor .= 's'
57 endif
58 endif
59 endif
Bram Moolenaarf193fff2006-04-27 00:02:13 +000060endif
Bram Moolenaar4a85b412006-04-23 22:40:29 +000061
Bram Moolenaar071d4272004-06-13 20:20:40 +000062" HTML: thanks to Johannes Zellner and Benji Fisher.
63if exists("loaded_matchit")
64 let b:match_ignorecase = 1
Bram Moolenaar071d4272004-06-13 20:20:40 +000065 let b:match_words = '<:>,' .
66 \ '<\@<=[ou]l\>[^>]*\%(>\|$\):<\@<=li\>:<\@<=/[ou]l>,' .
67 \ '<\@<=dl\>[^>]*\%(>\|$\):<\@<=d[td]\>:<\@<=/dl>,' .
68 \ '<\@<=\([^/][^ \t>]*\)[^>]*\%(>\|$\):<\@<=/\1>'
69endif
70
71" Change the :browse e filter to primarily show HTML-related files.
72if has("gui_win32")
Bram Moolenaar8299df92004-07-10 09:47:34 +000073 let b:browsefilter="HTML Files (*.html,*.htm)\t*.htm;*.html\n" .
Bram Moolenaar071d4272004-06-13 20:20:40 +000074 \ "JavaScript Files (*.js)\t*.js\n" .
75 \ "Cascading StyleSheets (*.css)\t*.css\n" .
76 \ "All Files (*.*)\t*.*\n"
77endif
78
79" Undo the stuff we changed.
Bram Moolenaara7241f52008-06-24 20:39:31 +000080let b:undo_ftplugin = "setlocal commentstring< matchpairs< omnifunc<"
Bram Moolenaar071d4272004-06-13 20:20:40 +000081 \ " | unlet! b:match_ignorecase b:match_skip b:match_words b:browsefilter"
82
83" Restore the saved compatibility options.
84let &cpo = s:save_cpo