annotate runtime/indent/xml.vim @ 20596:4ec94bcaef86

Added tag v8.2.0851 for changeset 3609e842f8229ebc52cbb5e172eabcf75be81e2b
author Bram Moolenaar <Bram@vim.org>
date Sat, 30 May 2020 20:00:04 +0200
parents 8dde7ced3344
children 29c5f168c6fd
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
18456
6d11fc4aa683 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 17571
diff changeset
1 " Language: XML
6d11fc4aa683 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 17571
diff changeset
2 " Maintainer: Christian Brabandt <cb@256bit.org>
6d11fc4aa683 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 17571
diff changeset
3 " Repository: https://github.com/chrisbra/vim-xml-ftplugin
6d11fc4aa683 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 17571
diff changeset
4 " Previous Maintainer: Johannes Zellner <johannes@zellner.org>
18790
8dde7ced3344 Update a few runtime files
Bram Moolenaar <Bram@vim.org>
parents: 18456
diff changeset
5 " Last Changed: 2019 Dec 02
15194
8b334e4cb97f Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14999
diff changeset
6 " Last Change:
18790
8dde7ced3344 Update a few runtime files
Bram Moolenaar <Bram@vim.org>
parents: 18456
diff changeset
7 " 20191202 - Handle docbk filetype
17571
2704c4e3e20a Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 16086
diff changeset
8 " 20190726 - Correctly handle non-tagged data
16086
bd7461db24b3 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 15729
diff changeset
9 " 20190204 - correctly handle wrap tags
bd7461db24b3 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 15729
diff changeset
10 " https://github.com/chrisbra/vim-xml-ftplugin/issues/5
15729
fe57e4f0eac1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 15194
diff changeset
11 " 20190128 - Make sure to find previous tag
fe57e4f0eac1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 15194
diff changeset
12 " https://github.com/chrisbra/vim-xml-ftplugin/issues/4
15194
8b334e4cb97f Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14999
diff changeset
13 " 20181116 - Fix indentation when tags start with a colon or an underscore
8b334e4cb97f Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14999
diff changeset
14 " https://github.com/vim/vim/pull/926
8b334e4cb97f Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14999
diff changeset
15 " 20181022 - Do not overwrite indentkeys setting
8b334e4cb97f Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14999
diff changeset
16 " https://github.com/chrisbra/vim-xml-ftplugin/issues/1
8b334e4cb97f Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14999
diff changeset
17 " 20180724 - Correctly indent xml comments https://github.com/vim/vim/issues/3200
8b334e4cb97f Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14999
diff changeset
18 "
8b334e4cb97f Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14999
diff changeset
19 " Notes:
8b334e4cb97f Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14999
diff changeset
20 " 1) does not indent pure non-xml code (e.g. embedded scripts)
8b334e4cb97f Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14999
diff changeset
21 " 2) will be confused by unbalanced tags in comments
8b334e4cb97f Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14999
diff changeset
22 " or CDATA sections.
8b334e4cb97f Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14999
diff changeset
23 " 2009-05-26 patch by Nikolai Weibull
8b334e4cb97f Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14999
diff changeset
24 " TODO: implement pre-like tags, see xml_indent_open / xml_indent_close
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
25
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
26 " Only load this indent file when no other was loaded.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
27 if exists("b:did_indent")
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
28 finish
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
29 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
30 let b:did_indent = 1
3526
dd6c2497c997 Fix more 'cpo' issues in runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2034
diff changeset
31 let s:keepcpo= &cpo
dd6c2497c997 Fix more 'cpo' issues in runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2034
diff changeset
32 set cpo&vim
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
33
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
34 " [-- local settings (must come before aborting the script) --]
15194
8b334e4cb97f Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14999
diff changeset
35 " Attention: Parameter use_syntax_check is used by the docbk.vim indent script
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
36 setlocal indentexpr=XmlIndentGet(v:lnum,1)
14999
2b30a2b4bde2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 14421
diff changeset
37 setlocal indentkeys=o,O,*<Return>,<>>,<<>,/,{,},!^F
17571
2704c4e3e20a Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 16086
diff changeset
38 " autoindent: used when the indentexpr returns -1
2704c4e3e20a Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 16086
diff changeset
39 setlocal autoindent
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
40
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
41 if !exists('b:xml_indent_open')
15194
8b334e4cb97f Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14999
diff changeset
42 let b:xml_indent_open = '.\{-}<[:A-Z_a-z]'
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
43 " pre tag, e.g. <address>
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
44 " let b:xml_indent_open = '.\{-}<[/]\@!\(address\)\@!'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
45 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
46
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
47 if !exists('b:xml_indent_close')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
48 let b:xml_indent_close = '.\{-}</'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
49 " end pre tag, e.g. </address>
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
50 " let b:xml_indent_close = '.\{-}</\(address\)\@!'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
51 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
52
3713
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3526
diff changeset
53 let &cpo = s:keepcpo
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3526
diff changeset
54 unlet s:keepcpo
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3526
diff changeset
55
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
56 " [-- finish, if the function already exists --]
3713
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3526
diff changeset
57 if exists('*XmlIndentGet')
15194
8b334e4cb97f Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14999
diff changeset
58 finish
3713
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3526
diff changeset
59 endif
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3526
diff changeset
60
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3526
diff changeset
61 let s:keepcpo= &cpo
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3526
diff changeset
62 set cpo&vim
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
63
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
64 fun! <SID>XmlIndentWithPattern(line, pat)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
65 let s = substitute('x'.a:line, a:pat, "\1", 'g')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
66 return strlen(substitute(s, "[^\1].*$", '', ''))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
67 endfun
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
68
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
69 " [-- check if it's xml --]
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
70 fun! <SID>XmlIndentSynCheck(lnum)
15194
8b334e4cb97f Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14999
diff changeset
71 if &syntax != ''
8b334e4cb97f Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14999
diff changeset
72 let syn1 = synIDattr(synID(a:lnum, 1, 1), 'name')
8b334e4cb97f Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14999
diff changeset
73 let syn2 = synIDattr(synID(a:lnum, strlen(getline(a:lnum)) - 1, 1), 'name')
8b334e4cb97f Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14999
diff changeset
74 if syn1 != '' && syn1 !~ 'xml' && syn2 != '' && syn2 !~ 'xml'
8b334e4cb97f Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14999
diff changeset
75 " don't indent pure non-xml code
8b334e4cb97f Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14999
diff changeset
76 return 0
8b334e4cb97f Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14999
diff changeset
77 endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
78 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
79 return 1
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
80 endfun
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
81
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
82 " [-- return the sum of indents of a:lnum --]
16086
bd7461db24b3 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 15729
diff changeset
83 fun! <SID>XmlIndentSum(line, style, add)
bd7461db24b3 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 15729
diff changeset
84 if <SID>IsXMLContinuation(a:line) && a:style == 0
bd7461db24b3 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 15729
diff changeset
85 " no complete tag, add one additional indent level
bd7461db24b3 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 15729
diff changeset
86 " but only for the current line
bd7461db24b3 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 15729
diff changeset
87 return a:add + shiftwidth()
bd7461db24b3 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 15729
diff changeset
88 elseif <SID>HasNoTagEnd(a:line)
bd7461db24b3 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 15729
diff changeset
89 " no complete tag, return initial indent
bd7461db24b3 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 15729
diff changeset
90 return a:add
bd7461db24b3 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 15729
diff changeset
91 endif
bd7461db24b3 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 15729
diff changeset
92 if a:style == match(a:line, '^\s*</')
15194
8b334e4cb97f Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14999
diff changeset
93 return (shiftwidth() *
16086
bd7461db24b3 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 15729
diff changeset
94 \ (<SID>XmlIndentWithPattern(a:line, b:xml_indent_open)
bd7461db24b3 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 15729
diff changeset
95 \ - <SID>XmlIndentWithPattern(a:line, b:xml_indent_close)
bd7461db24b3 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 15729
diff changeset
96 \ - <SID>XmlIndentWithPattern(a:line, '.\{-}/>'))) + a:add
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
97 else
15194
8b334e4cb97f Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14999
diff changeset
98 return a:add
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
99 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
100 endfun
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
101
15194
8b334e4cb97f Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14999
diff changeset
102 " Main indent function
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
103 fun! XmlIndentGet(lnum, use_syntax_check)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
104 " Find a non-empty line above the current line.
16086
bd7461db24b3 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 15729
diff changeset
105 if prevnonblank(a:lnum - 1) == 0
bd7461db24b3 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 15729
diff changeset
106 " Hit the start of the file, use zero indent.
15194
8b334e4cb97f Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14999
diff changeset
107 return 0
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
108 endif
15729
fe57e4f0eac1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 15194
diff changeset
109 " Find previous line with a tag (regardless whether open or closed,
17571
2704c4e3e20a Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 16086
diff changeset
110 " but always restrict the match to a line before the current one
16086
bd7461db24b3 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 15729
diff changeset
111 " Note: xml declaration: <?xml version="1.0"?>
bd7461db24b3 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 15729
diff changeset
112 " won't be found, as it is not a legal tag name
17571
2704c4e3e20a Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 16086
diff changeset
113 let ptag_pattern = '\%(.\{-}<[/:A-Z_a-z]\)'. '\%(\&\%<'. a:lnum .'l\)'
16086
bd7461db24b3 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 15729
diff changeset
114 let ptag = search(ptag_pattern, 'bnW')
bd7461db24b3 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 15729
diff changeset
115 " no previous tag
bd7461db24b3 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 15729
diff changeset
116 if ptag == 0
bd7461db24b3 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 15729
diff changeset
117 return 0
bd7461db24b3 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 15729
diff changeset
118 endif
15729
fe57e4f0eac1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 15194
diff changeset
119
17571
2704c4e3e20a Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 16086
diff changeset
120 let pline = getline(ptag)
2704c4e3e20a Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 16086
diff changeset
121 let pind = indent(ptag)
2704c4e3e20a Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 16086
diff changeset
122
2704c4e3e20a Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 16086
diff changeset
123 let syn_name_start = '' " Syntax element at start of line (excluding whitespace)
2704c4e3e20a Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 16086
diff changeset
124 let syn_name_end = '' " Syntax element at end of line
2704c4e3e20a Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 16086
diff changeset
125 let curline = getline(a:lnum)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
126 if a:use_syntax_check
16086
bd7461db24b3 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 15729
diff changeset
127 let check_lnum = <SID>XmlIndentSynCheck(ptag)
15194
8b334e4cb97f Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14999
diff changeset
128 let check_alnum = <SID>XmlIndentSynCheck(a:lnum)
8b334e4cb97f Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14999
diff changeset
129 if check_lnum == 0 || check_alnum == 0
8b334e4cb97f Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14999
diff changeset
130 return indent(a:lnum)
8b334e4cb97f Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14999
diff changeset
131 endif
17571
2704c4e3e20a Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 16086
diff changeset
132 let syn_name_end = synIDattr(synID(a:lnum, strlen(curline) - 1, 1), 'name')
2704c4e3e20a Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 16086
diff changeset
133 let syn_name_start = synIDattr(synID(a:lnum, match(curline, '\S') + 1, 1), 'name')
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
134 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
135
17571
2704c4e3e20a Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 16086
diff changeset
136 if syn_name_end =~ 'Comment' && syn_name_start =~ 'Comment'
2704c4e3e20a Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 16086
diff changeset
137 return <SID>XmlIndentComment(a:lnum)
18790
8dde7ced3344 Update a few runtime files
Bram Moolenaar <Bram@vim.org>
parents: 18456
diff changeset
138 elseif empty(syn_name_start) && empty(syn_name_end) && a:use_syntax_check
17571
2704c4e3e20a Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 16086
diff changeset
139 " non-xml tag content: use indent from 'autoindent'
2704c4e3e20a Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 16086
diff changeset
140 return pind + shiftwidth()
2704c4e3e20a Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 16086
diff changeset
141 endif
2704c4e3e20a Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 16086
diff changeset
142
15194
8b334e4cb97f Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14999
diff changeset
143 " Get indent from previous tag line
16086
bd7461db24b3 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 15729
diff changeset
144 let ind = <SID>XmlIndentSum(pline, -1, pind)
15194
8b334e4cb97f Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14999
diff changeset
145 " Determine indent from current line
17571
2704c4e3e20a Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 16086
diff changeset
146 let ind = <SID>XmlIndentSum(curline, 0, ind)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
147 return ind
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
148 endfun
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
149
16086
bd7461db24b3 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 15729
diff changeset
150 func! <SID>IsXMLContinuation(line)
bd7461db24b3 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 15729
diff changeset
151 " Checks, whether or not the line matches a start-of-tag
18790
8dde7ced3344 Update a few runtime files
Bram Moolenaar <Bram@vim.org>
parents: 18456
diff changeset
152 return a:line !~ '^\s*<' && &ft is# 'xml'
16086
bd7461db24b3 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 15729
diff changeset
153 endfunc
bd7461db24b3 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 15729
diff changeset
154
bd7461db24b3 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 15729
diff changeset
155 func! <SID>HasNoTagEnd(line)
bd7461db24b3 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 15729
diff changeset
156 " Checks whether or not the line matches '>' (so finishes a tag)
bd7461db24b3 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 15729
diff changeset
157 return a:line !~ '>\s*$'
bd7461db24b3 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 15729
diff changeset
158 endfunc
bd7461db24b3 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 15729
diff changeset
159
15194
8b334e4cb97f Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14999
diff changeset
160 " return indent for a commented line,
17571
2704c4e3e20a Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 16086
diff changeset
161 " the middle part might be indented one additional level
15194
8b334e4cb97f Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14999
diff changeset
162 func! <SID>XmlIndentComment(lnum)
16086
bd7461db24b3 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 15729
diff changeset
163 let ptagopen = search(b:xml_indent_open, 'bnW')
bd7461db24b3 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 15729
diff changeset
164 let ptagclose = search(b:xml_indent_close, 'bnW')
15194
8b334e4cb97f Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14999
diff changeset
165 if getline(a:lnum) =~ '<!--'
8b334e4cb97f Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14999
diff changeset
166 " if previous tag was a closing tag, do not add
8b334e4cb97f Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14999
diff changeset
167 " one additional level of indent
8b334e4cb97f Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14999
diff changeset
168 if ptagclose > ptagopen && a:lnum > ptagclose
8b334e4cb97f Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14999
diff changeset
169 return indent(ptagclose)
8b334e4cb97f Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14999
diff changeset
170 else
8b334e4cb97f Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14999
diff changeset
171 " start of comment, add one indentation level
8b334e4cb97f Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14999
diff changeset
172 return indent(ptagopen) + shiftwidth()
8b334e4cb97f Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14999
diff changeset
173 endif
8b334e4cb97f Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14999
diff changeset
174 elseif getline(a:lnum) =~ '-->'
8b334e4cb97f Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14999
diff changeset
175 " end of comment, same as start of comment
16086
bd7461db24b3 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 15729
diff changeset
176 return indent(search('<!--', 'bnW'))
15194
8b334e4cb97f Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14999
diff changeset
177 else
8b334e4cb97f Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14999
diff changeset
178 " middle part of comment, add one additional level
16086
bd7461db24b3 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 15729
diff changeset
179 return indent(search('<!--', 'bnW')) + shiftwidth()
15194
8b334e4cb97f Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14999
diff changeset
180 endif
8b334e4cb97f Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14999
diff changeset
181 endfunc
8b334e4cb97f Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14999
diff changeset
182
3526
dd6c2497c997 Fix more 'cpo' issues in runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2034
diff changeset
183 let &cpo = s:keepcpo
dd6c2497c997 Fix more 'cpo' issues in runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2034
diff changeset
184 unlet s:keepcpo
dd6c2497c997 Fix more 'cpo' issues in runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2034
diff changeset
185
15194
8b334e4cb97f Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14999
diff changeset
186 " vim:ts=4 et sts=-1 sw=0