xml.vim 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. " Vim filetype plugin file
  2. " Language: xml
  3. " Maintainer: Christian Brabandt <cb@256bit.org>
  4. " Last Changed: May 08th, 2018
  5. " Repository: https://github.com/chrisbra/vim-xml-ftplugin
  6. " Previous Maintainer: Dan Sharp <dwsharp at users dot sourceforge dot net>
  7. " URL: http://dwsharp.users.sourceforge.net/vim/ftplugin
  8. if exists("b:did_ftplugin") | finish | endif
  9. 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&vim
  14. setlocal commentstring=<!--%s-->
  15. " Remove the middlepart from the comments section, as this causes problems:
  16. " https://groups.google.com/d/msg/vim_dev/x4GT-nqa0Kg/jvtRnEbtAnMJ
  17. setlocal comments=s:<!--,e:-->
  18. setlocal formatoptions-=t
  19. setlocal formatoptions+=croql
  20. setlocal formatexpr=xmlformat#Format()
  21. " XML: thanks to Johannes Zellner and Akbar Ibrahim
  22. " - case sensitive
  23. " - don't match empty tags <fred/>
  24. " - match <!--, --> style comments (but not --, --)
  25. " - match <!, > inlined dtd's. This is not perfect, as it
  26. " gets confused for example by
  27. " <!ENTITY gt ">">
  28. if exists("loaded_matchit")
  29. let b:match_ignorecase=0
  30. let b:match_words =
  31. \ '<:>,' .
  32. \ '<\@<=!\[CDATA\[:]]>,'.
  33. \ '<\@<=!--:-->,'.
  34. \ '<\@<=?\k\+:?>,'.
  35. \ '<\@<=\([^ \t>/]\+\)\%(\s\+[^>]*\%([^/]>\|$\)\|>\|$\):<\@<=/\1>,'.
  36. \ '<\@<=\%([^ \t>/]\+\)\%(\s\+[^/>]*\|$\):/>'
  37. endif
  38. " For Omni completion, by Mikolaj Machowski.
  39. if exists('&ofu')
  40. setlocal ofu=xmlcomplete#CompleteTags
  41. endif
  42. command! -nargs=+ XMLns call xmlcomplete#CreateConnection(<f-args>)
  43. command! -nargs=? XMLent call xmlcomplete#CreateEntConnection(<f-args>)
  44. " Change the :browse e filter to primarily show xml-related files.
  45. if (has("gui_win32") || has("gui_gtk")) && !exists("b:browsefilter")
  46. let b:browsefilter="XML Files (*.xml)\t*.xml\n" .
  47. \ "DTD Files (*.dtd)\t*.dtd\n" .
  48. \ "XSD Files (*.xsd)\t*.xsd\n" .
  49. \ "All Files (*.*)\t*.*\n"
  50. endif
  51. " Undo the stuff we changed.
  52. let b:undo_ftplugin = "setlocal commentstring< comments< formatoptions< formatexpr< " .
  53. \ " | unlet! b:match_ignorecase b:match_words b:browsefilter"
  54. " Restore the saved compatibility options.
  55. let &cpo = s:save_cpo
  56. unlet s:save_cpo