blob: 83c528eff23e7c5965f3c3552b7a104fc3f57303 [file] [log] [blame]
Bram Moolenaar071d4272004-06-13 20:20:40 +00001" Vim filetype plugin file
Bram Moolenaard47d5222018-12-09 20:43:55 +01002" Language: xml
3" Maintainer: Christian Brabandt <cb@256bit.org>
4" Last Changed: Dec 07th, 2018
Doug Kearns93197fd2024-01-14 20:59:02 +01005" 2024 Jan 14 by Vim Project (browsefilter)
Riley Bruins0a083062024-06-03 20:40:45 +02006" 2024 May 23 by Riley Bruins <ribru17@gmail.com> ('commentstring')
Bram Moolenaard47d5222018-12-09 20:43:55 +01007" Repository: https://github.com/chrisbra/vim-xml-ftplugin
Bram Moolenaar1588bc82022-03-08 21:35:07 +00008" Previous Maintainer: Dan Sharp
Bram Moolenaar7db25fe2018-05-13 00:02:36 +02009" URL: http://dwsharp.users.sourceforge.net/vim/ftplugin
Bram Moolenaar071d4272004-06-13 20:20:40 +000010
11if exists("b:did_ftplugin") | finish | endif
12let b:did_ftplugin = 1
13
14" Make sure the continuation lines below do not cause problems in
15" compatibility mode.
16let s:save_cpo = &cpo
Bram Moolenaar7db25fe2018-05-13 00:02:36 +020017set cpo&vim
Bram Moolenaar071d4272004-06-13 20:20:40 +000018
Riley Bruins0a083062024-06-03 20:40:45 +020019setlocal commentstring=<!--\ %s\ -->
Bram Moolenaar7db25fe2018-05-13 00:02:36 +020020" Remove the middlepart from the comments section, as this causes problems:
21" https://groups.google.com/d/msg/vim_dev/x4GT-nqa0Kg/jvtRnEbtAnMJ
22setlocal comments=s:<!--,e:-->
Bram Moolenaare37d50a2008-08-06 17:06:04 +000023
24setlocal formatoptions-=t
Bram Moolenaar7db25fe2018-05-13 00:02:36 +020025setlocal formatoptions+=croql
26setlocal formatexpr=xmlformat#Format()
Bram Moolenaar071d4272004-06-13 20:20:40 +000027
28" XML: thanks to Johannes Zellner and Akbar Ibrahim
29" - case sensitive
30" - don't match empty tags <fred/>
31" - match <!--, --> style comments (but not --, --)
32" - match <!, > inlined dtd's. This is not perfect, as it
33" gets confused for example by
34" <!ENTITY gt ">">
35if exists("loaded_matchit")
36 let b:match_ignorecase=0
37 let b:match_words =
38 \ '<:>,' .
39 \ '<\@<=!\[CDATA\[:]]>,'.
40 \ '<\@<=!--:-->,'.
41 \ '<\@<=?\k\+:?>,'.
42 \ '<\@<=\([^ \t>/]\+\)\%(\s\+[^>]*\%([^/]>\|$\)\|>\|$\):<\@<=/\1>,'.
43 \ '<\@<=\%([^ \t>/]\+\)\%(\s\+[^/>]*\|$\):/>'
44endif
45
Bram Moolenaara5792f52005-11-23 21:25:05 +000046" For Omni completion, by Mikolaj Machowski.
47if exists('&ofu')
48 setlocal ofu=xmlcomplete#CompleteTags
49endif
50command! -nargs=+ XMLns call xmlcomplete#CreateConnection(<f-args>)
51command! -nargs=? XMLent call xmlcomplete#CreateEntConnection(<f-args>)
52
Bram Moolenaar071d4272004-06-13 20:20:40 +000053" Change the :browse e filter to primarily show xml-related files.
Bram Moolenaar7db25fe2018-05-13 00:02:36 +020054if (has("gui_win32") || has("gui_gtk")) && !exists("b:browsefilter")
Bram Moolenaar071d4272004-06-13 20:20:40 +000055 let b:browsefilter="XML Files (*.xml)\t*.xml\n" .
Bram Moolenaar7db25fe2018-05-13 00:02:36 +020056 \ "DTD Files (*.dtd)\t*.dtd\n" .
Doug Kearns93197fd2024-01-14 20:59:02 +010057 \ "XSD Files (*.xsd)\t*.xsd\n"
58 if has("win32")
59 let b:browsefilter .= "All Files (*.*)\t*\n"
60 else
61 let b:browsefilter .= "All Files (*)\t*\n"
62 endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000063endif
64
65" Undo the stuff we changed.
Bram Moolenaar7db25fe2018-05-13 00:02:36 +020066let b:undo_ftplugin = "setlocal commentstring< comments< formatoptions< formatexpr< " .
67 \ " | unlet! b:match_ignorecase b:match_words b:browsefilter"
Bram Moolenaar071d4272004-06-13 20:20:40 +000068
69" Restore the saved compatibility options.
70let &cpo = s:save_cpo
Bram Moolenaar84f72352012-03-11 15:57:40 +010071unlet s:save_cpo