blob: b81c3980d2199a4ede6e5aa46b5b4bf366be3f3f [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)
Bram Moolenaard47d5222018-12-09 20:43:55 +01006" Repository: https://github.com/chrisbra/vim-xml-ftplugin
Bram Moolenaar1588bc82022-03-08 21:35:07 +00007" Previous Maintainer: Dan Sharp
Bram Moolenaar7db25fe2018-05-13 00:02:36 +02008" URL: http://dwsharp.users.sourceforge.net/vim/ftplugin
Bram Moolenaar071d4272004-06-13 20:20:40 +00009
10if exists("b:did_ftplugin") | finish | endif
11let b:did_ftplugin = 1
12
13" Make sure the continuation lines below do not cause problems in
14" compatibility mode.
15let s:save_cpo = &cpo
Bram Moolenaar7db25fe2018-05-13 00:02:36 +020016set cpo&vim
Bram Moolenaar071d4272004-06-13 20:20:40 +000017
18setlocal commentstring=<!--%s-->
Bram Moolenaar7db25fe2018-05-13 00:02:36 +020019" Remove the middlepart from the comments section, as this causes problems:
20" https://groups.google.com/d/msg/vim_dev/x4GT-nqa0Kg/jvtRnEbtAnMJ
21setlocal comments=s:<!--,e:-->
Bram Moolenaare37d50a2008-08-06 17:06:04 +000022
23setlocal formatoptions-=t
Bram Moolenaar7db25fe2018-05-13 00:02:36 +020024setlocal formatoptions+=croql
25setlocal formatexpr=xmlformat#Format()
Bram Moolenaar071d4272004-06-13 20:20:40 +000026
27" XML: thanks to Johannes Zellner and Akbar Ibrahim
28" - case sensitive
29" - don't match empty tags <fred/>
30" - match <!--, --> style comments (but not --, --)
31" - match <!, > inlined dtd's. This is not perfect, as it
32" gets confused for example by
33" <!ENTITY gt ">">
34if exists("loaded_matchit")
35 let b:match_ignorecase=0
36 let b:match_words =
37 \ '<:>,' .
38 \ '<\@<=!\[CDATA\[:]]>,'.
39 \ '<\@<=!--:-->,'.
40 \ '<\@<=?\k\+:?>,'.
41 \ '<\@<=\([^ \t>/]\+\)\%(\s\+[^>]*\%([^/]>\|$\)\|>\|$\):<\@<=/\1>,'.
42 \ '<\@<=\%([^ \t>/]\+\)\%(\s\+[^/>]*\|$\):/>'
43endif
44
Bram Moolenaara5792f52005-11-23 21:25:05 +000045" For Omni completion, by Mikolaj Machowski.
46if exists('&ofu')
47 setlocal ofu=xmlcomplete#CompleteTags
48endif
49command! -nargs=+ XMLns call xmlcomplete#CreateConnection(<f-args>)
50command! -nargs=? XMLent call xmlcomplete#CreateEntConnection(<f-args>)
51
Bram Moolenaar071d4272004-06-13 20:20:40 +000052" Change the :browse e filter to primarily show xml-related files.
Bram Moolenaar7db25fe2018-05-13 00:02:36 +020053if (has("gui_win32") || has("gui_gtk")) && !exists("b:browsefilter")
Bram Moolenaar071d4272004-06-13 20:20:40 +000054 let b:browsefilter="XML Files (*.xml)\t*.xml\n" .
Bram Moolenaar7db25fe2018-05-13 00:02:36 +020055 \ "DTD Files (*.dtd)\t*.dtd\n" .
Doug Kearns93197fd2024-01-14 20:59:02 +010056 \ "XSD Files (*.xsd)\t*.xsd\n"
57 if has("win32")
58 let b:browsefilter .= "All Files (*.*)\t*\n"
59 else
60 let b:browsefilter .= "All Files (*)\t*\n"
61 endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000062endif
63
64" Undo the stuff we changed.
Bram Moolenaar7db25fe2018-05-13 00:02:36 +020065let b:undo_ftplugin = "setlocal commentstring< comments< formatoptions< formatexpr< " .
66 \ " | unlet! b:match_ignorecase b:match_words b:browsefilter"
Bram Moolenaar071d4272004-06-13 20:20:40 +000067
68" Restore the saved compatibility options.
69let &cpo = s:save_cpo
Bram Moolenaar84f72352012-03-11 15:57:40 +010070unlet s:save_cpo