html.vim 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. " Vim filetype plugin file
  2. " Language: HTML
  3. " Maintainer: Doug Kearns <dougkearns@gmail.com>
  4. " Previous Maintainer: Dan Sharp
  5. " Last Change: 2024 Jan 14
  6. if exists("b:did_ftplugin")
  7. finish
  8. endif
  9. let b:did_ftplugin = 1
  10. let s:save_cpo = &cpo
  11. set cpo-=C
  12. setlocal matchpairs+=<:>
  13. setlocal commentstring=<!--%s-->
  14. setlocal comments=s:<!--,m:\ \ \ \ ,e:-->
  15. let b:undo_ftplugin = "setlocal comments< commentstring< matchpairs<"
  16. if get(g:, "ft_html_autocomment", 0)
  17. setlocal formatoptions-=t formatoptions+=croql
  18. let b:undo_ftplugin ..= " | setlocal formatoptions<"
  19. endif
  20. if exists('&omnifunc')
  21. setlocal omnifunc=htmlcomplete#CompleteTags
  22. call htmlcomplete#DetectOmniFlavor()
  23. let b:undo_ftplugin ..= " | setlocal omnifunc<"
  24. endif
  25. " HTML: thanks to Johannes Zellner and Benji Fisher.
  26. if exists("loaded_matchit") && !exists("b:match_words")
  27. let b:match_ignorecase = 1
  28. let b:match_words = '<!--:-->,' ..
  29. \ '<:>,' ..
  30. \ '<\@<=[ou]l\>[^>]*\%(>\|$\):<\@<=li\>:<\@<=/[ou]l>,' ..
  31. \ '<\@<=dl\>[^>]*\%(>\|$\):<\@<=d[td]\>:<\@<=/dl>,' ..
  32. \ '<\@<=\([^/!][^ \t>]*\)[^>]*\%(>\|$\):<\@<=/\1>'
  33. let b:html_set_match_words = 1
  34. let b:undo_ftplugin ..= " | unlet! b:match_ignorecase b:match_words b:html_set_match_words"
  35. endif
  36. " Change the :browse e filter to primarily show HTML-related files.
  37. if (has("gui_win32") || has("gui_gtk")) && !exists("b:browsefilter")
  38. let b:browsefilter = "HTML Files (*.html, *.htm)\t*.html;*.htm\n" ..
  39. \ "JavaScript Files (*.js)\t*.js\n" ..
  40. \ "Cascading StyleSheets (*.css)\t*.css\n"
  41. if has("win32")
  42. let b:browsefilter ..= "All Files (*.*)\t*\n"
  43. else
  44. let b:browsefilter ..= "All Files (*)\t*\n"
  45. endif
  46. let b:html_set_browsefilter = 1
  47. let b:undo_ftplugin ..= " | unlet! b:browsefilter b:html_set_browsefilter"
  48. endif
  49. let &cpo = s:save_cpo
  50. unlet s:save_cpo