annotate runtime/indent/xml.vim @ 17410:5f5c552c1acb

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