blob: 3d723315df8869f0750e409b15b73eb92c425a86 [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 Moolenaarf193fff2006-04-27 00:02:13 +00004" Last Changed: 2006 Apr 26
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-->
16
Bram Moolenaarf193fff2006-04-27 00:02:13 +000017if exists('&omnifunc')
18" Distinguish between HTML versions
19" To use with other HTML versions add another
20" elseif condition to match proper DOCTYPE
Bram Moolenaarf75a9632005-09-13 21:20:47 +000021setlocal omnifunc=htmlcomplete#CompleteTags
22
Bram Moolenaar4a85b412006-04-23 22:40:29 +000023if &filetype == 'xhtml'
24 let b:html_omni_flavor = 'xhtml10s'
25else
26 let b:html_omni_flavor = 'html401t'
27endif
Bram Moolenaar4a85b412006-04-23 22:40:29 +000028let i = 1
29while i < 10 && i < line("$")
30 let line = getline(i)
31 if line =~ '<!DOCTYPE.*\<DTD HTML 3\.2'
32 let b:html_omni_flavor = 'html32'
33 break
34 elseif line =~ '<!DOCTYPE.*\<DTD HTML 4\.0 Transitional'
35 let b:html_omni_flavor = 'html40t'
36 break
37 elseif line =~ '<!DOCTYPE.*\<DTD HTML 4\.0 Frameset'
38 let b:html_omni_flavor = 'html40f'
39 break
40 elseif line =~ '<!DOCTYPE.*\<DTD HTML 4\.0'
41 let b:html_omni_flavor = 'html40s'
42 break
43 elseif line =~ '<!DOCTYPE.*\<DTD HTML 4\.01 Transitional'
44 let b:html_omni_flavor = 'html401t'
45 break
46 elseif line =~ '<!DOCTYPE.*\<DTD HTML 4\.01 Frameset'
47 let b:html_omni_flavor = 'html401f'
48 break
49 elseif line =~ '<!DOCTYPE.*\<DTD HTML 4\.01'
50 let b:html_omni_flavor = 'html401s'
51 break
52 elseif line =~ '<!DOCTYPE.*\<DTD XHTML 1\.0 Transitional'
53 let b:html_omni_flavor = 'xhtml10t'
54 break
55 elseif line =~ '<!DOCTYPE.*\<DTD XHTML 1\.0 Frameset'
56 let b:html_omni_flavor = 'xhtml10f'
57 break
58 elseif line =~ '<!DOCTYPE.*\<DTD XHTML 1\.0 Strict'
59 let b:html_omni_flavor = 'xhtml10s'
60 break
61 elseif line =~ '<!DOCTYPE.*\<DTD XHTML 1\.1'
62 let b:html_omni_flavor = 'xhtml11'
63 break
64 endif
65 let i += 1
66endwhile
Bram Moolenaarf193fff2006-04-27 00:02:13 +000067endif
Bram Moolenaar4a85b412006-04-23 22:40:29 +000068
Bram Moolenaar071d4272004-06-13 20:20:40 +000069" HTML: thanks to Johannes Zellner and Benji Fisher.
70if exists("loaded_matchit")
71 let b:match_ignorecase = 1
72 let b:match_skip = 's:Comment'
73 let b:match_words = '<:>,' .
74 \ '<\@<=[ou]l\>[^>]*\%(>\|$\):<\@<=li\>:<\@<=/[ou]l>,' .
75 \ '<\@<=dl\>[^>]*\%(>\|$\):<\@<=d[td]\>:<\@<=/dl>,' .
76 \ '<\@<=\([^/][^ \t>]*\)[^>]*\%(>\|$\):<\@<=/\1>'
77endif
78
79" Change the :browse e filter to primarily show HTML-related files.
80if has("gui_win32")
Bram Moolenaar8299df92004-07-10 09:47:34 +000081 let b:browsefilter="HTML Files (*.html,*.htm)\t*.htm;*.html\n" .
Bram Moolenaar071d4272004-06-13 20:20:40 +000082 \ "JavaScript Files (*.js)\t*.js\n" .
83 \ "Cascading StyleSheets (*.css)\t*.css\n" .
84 \ "All Files (*.*)\t*.*\n"
85endif
86
87" Undo the stuff we changed.
88let b:undo_ftplugin = "setlocal commentstring<"
89 \ " | unlet! b:match_ignorecase b:match_skip b:match_words b:browsefilter"
90
91" Restore the saved compatibility options.
92let &cpo = s:save_cpo