blob: 573a6ba4417f46c200c6a84204c0019dc9a74359 [file] [log] [blame]
Bram Moolenaar071d4272004-06-13 20:20:40 +00001" Vim filetype plugin file
2" Language: xml
Bram Moolenaar7db25fe2018-05-13 00:02:36 +02003" 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
Bram Moolenaar071d4272004-06-13 20:20:40 +00008
9if exists("b:did_ftplugin") | finish | endif
10let b:did_ftplugin = 1
11
12" Make sure the continuation lines below do not cause problems in
13" compatibility mode.
14let s:save_cpo = &cpo
Bram Moolenaar7db25fe2018-05-13 00:02:36 +020015set cpo&vim
Bram Moolenaar071d4272004-06-13 20:20:40 +000016
17setlocal commentstring=<!--%s-->
Bram Moolenaar7db25fe2018-05-13 00:02:36 +020018" Remove the middlepart from the comments section, as this causes problems:
19" https://groups.google.com/d/msg/vim_dev/x4GT-nqa0Kg/jvtRnEbtAnMJ
20setlocal comments=s:<!--,e:-->
Bram Moolenaare37d50a2008-08-06 17:06:04 +000021
22setlocal formatoptions-=t
Bram Moolenaar7db25fe2018-05-13 00:02:36 +020023setlocal formatoptions+=croql
24setlocal formatexpr=xmlformat#Format()
Bram Moolenaar071d4272004-06-13 20:20:40 +000025
26" XML: thanks to Johannes Zellner and Akbar Ibrahim
27" - case sensitive
28" - don't match empty tags <fred/>
29" - match <!--, --> style comments (but not --, --)
30" - match <!, > inlined dtd's. This is not perfect, as it
31" gets confused for example by
32" <!ENTITY gt ">">
33if exists("loaded_matchit")
34 let b:match_ignorecase=0
35 let b:match_words =
36 \ '<:>,' .
37 \ '<\@<=!\[CDATA\[:]]>,'.
38 \ '<\@<=!--:-->,'.
39 \ '<\@<=?\k\+:?>,'.
40 \ '<\@<=\([^ \t>/]\+\)\%(\s\+[^>]*\%([^/]>\|$\)\|>\|$\):<\@<=/\1>,'.
41 \ '<\@<=\%([^ \t>/]\+\)\%(\s\+[^/>]*\|$\):/>'
42endif
43
Bram Moolenaara5792f52005-11-23 21:25:05 +000044" For Omni completion, by Mikolaj Machowski.
45if exists('&ofu')
46 setlocal ofu=xmlcomplete#CompleteTags
47endif
48command! -nargs=+ XMLns call xmlcomplete#CreateConnection(<f-args>)
49command! -nargs=? XMLent call xmlcomplete#CreateEntConnection(<f-args>)
50
Bram Moolenaar071d4272004-06-13 20:20:40 +000051" Change the :browse e filter to primarily show xml-related files.
Bram Moolenaar7db25fe2018-05-13 00:02:36 +020052if (has("gui_win32") || has("gui_gtk")) && !exists("b:browsefilter")
Bram Moolenaar071d4272004-06-13 20:20:40 +000053 let b:browsefilter="XML Files (*.xml)\t*.xml\n" .
Bram Moolenaar7db25fe2018-05-13 00:02:36 +020054 \ "DTD Files (*.dtd)\t*.dtd\n" .
55 \ "XSD Files (*.xsd)\t*.xsd\n" .
56 \ "All Files (*.*)\t*.*\n"
Bram Moolenaar071d4272004-06-13 20:20:40 +000057endif
58
59" Undo the stuff we changed.
Bram Moolenaar7db25fe2018-05-13 00:02:36 +020060let b:undo_ftplugin = "setlocal commentstring< comments< formatoptions< formatexpr< " .
61 \ " | unlet! b:match_ignorecase b:match_words b:browsefilter"
Bram Moolenaar071d4272004-06-13 20:20:40 +000062
63" Restore the saved compatibility options.
64let &cpo = s:save_cpo
Bram Moolenaar84f72352012-03-11 15:57:40 +010065unlet s:save_cpo