Runtime files update
[MacVim.git] / runtime / ftplugin / html.vim
blob4797f4b4604182857911b841d6c79ba23fcbe548
1 " Vim filetype plugin file
2 " Language:     html
3 " Maintainer:   Dan Sharp <dwsharp at hotmail dot com>
4 " Last Changed: 2007 Nov 20
5 " URL:          http://mywebpage.netscape.com/sharppeople/vim/ftplugin
7 if exists("b:did_ftplugin") | finish | endif
8 let b:did_ftplugin = 1
10 " Make sure the continuation lines below do not cause problems in
11 " compatibility mode.
12 let s:save_cpo = &cpo
13 set cpo-=C
15 setlocal commentstring=<!--%s-->
16 setlocal matchpairs+=<:>
18 if exists('&omnifunc')
19     " 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
24     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
60 endif
62 " HTML:  thanks to Johannes Zellner and Benji Fisher.
63 if exists("loaded_matchit")
64     let b:match_ignorecase = 1
65     let b:match_words = '<:>,' .
66     \ '<\@<=[ou]l\>[^>]*\%(>\|$\):<\@<=li\>:<\@<=/[ou]l>,' .
67     \ '<\@<=dl\>[^>]*\%(>\|$\):<\@<=d[td]\>:<\@<=/dl>,' .
68     \ '<\@<=\([^/][^ \t>]*\)[^>]*\%(>\|$\):<\@<=/\1>'
69 endif
71 " Change the :browse e filter to primarily show HTML-related files.
72 if has("gui_win32")
73     let  b:browsefilter="HTML Files (*.html,*.htm)\t*.htm;*.html\n" .
74                 \       "JavaScript Files (*.js)\t*.js\n" .
75                 \       "Cascading StyleSheets (*.css)\t*.css\n" .
76                 \       "All Files (*.*)\t*.*\n"
77 endif
79 " Undo the stuff we changed.
80 let b:undo_ftplugin = "setlocal commentstring< matchpairs< omnifunc<"
81     \   " | unlet! b:match_ignorecase b:match_skip b:match_words b:browsefilter"
83 " Restore the saved compatibility options.
84 let &cpo = s:save_cpo