4869
|
1 " Vim indent script for HTML
|
|
2 " General: "{{{
|
|
3 " File: html.vim (Vimscript #2075)
|
|
4 " Author: Andy Wokula <anwoku@yahoo.de>
|
6009
|
5 " Last Change: 2014 Jun 19
|
4911
|
6 " Rev Days: 13
|
|
7 " Version: 0.9
|
4869
|
8 " Vim Version: Vim7
|
|
9 " Description:
|
|
10 " Improved version of the distributed html indent script, faster on a
|
|
11 " range of lines.
|
|
12 "
|
|
13 " Credits:
|
|
14 " indent/html.vim (2006 Jun 05) from J. Zellner
|
|
15 " indent/css.vim (2006 Dec 20) from N. Weibull
|
|
16 "
|
|
17 " History:
|
4911
|
18 " 2012 Oct 21 (v0.9) added support for shiftwidth()
|
|
19 " 2011 Sep 09 (v0.8) added HTML5 tags (thx to J. Zuckerman)
|
|
20 " 2008 Apr 28 (v0.6) revised customization
|
|
21 " 2008 Mar 09 (v0.5) fixed 'indk' issue (thx to C.J. Robinson)
|
4869
|
22 " }}}
|
7
|
23
|
4869
|
24 " Init Folklore, check user settings (2nd time ++) "{{{
|
7
|
25 if exists("b:did_indent")
|
|
26 finish
|
|
27 endif
|
|
28 let b:did_indent = 1
|
|
29
|
4869
|
30 setlocal indentexpr=HtmlIndent()
|
|
31 setlocal indentkeys=o,O,<Return>,<>>,{,},!^F
|
7
|
32
|
6009
|
33 " Needed for % to work when finding start of a tag.
|
|
34 setlocal matchpairs+=<:>
|
|
35
|
4869
|
36 let b:indent = {"lnum": -1}
|
|
37 let b:undo_indent = "set inde< indk<| unlet b:indent"
|
7
|
38
|
4869
|
39 " Load Once:
|
|
40 if exists("*HtmlIndent")
|
|
41 call HtmlIndent_CheckUserSettings()
|
|
42 finish
|
7
|
43 endif
|
|
44
|
4911
|
45 " Patch 7.3.694
|
|
46 if exists('*shiftwidth')
|
|
47 let s:ShiftWidth = function('shiftwidth')
|
|
48 else
|
|
49 func! s:ShiftWidth()
|
|
50 return &shiftwidth
|
|
51 endfunc
|
|
52 endif
|
|
53
|
867
|
54 let s:cpo_save = &cpo
|
7
|
55 set cpo-=C
|
4869
|
56 "}}}
|
7
|
57
|
4869
|
58 func! HtmlIndent_CheckUserSettings() "{{{
|
|
59 if exists("g:html_indent_inctags")
|
|
60 call s:AddITags(split(g:html_indent_inctags, ","))
|
7
|
61 endif
|
4869
|
62 if exists("g:html_indent_autotags")
|
|
63 call s:RemoveITags(split(g:html_indent_autotags, ","))
|
7
|
64 endif
|
|
65
|
4869
|
66 let indone = {"zero": 0
|
|
67 \,"auto": "indent(prevnonblank(v:lnum-1))"
|
4911
|
68 \,"inc": "b:indent.blocktagind + s:ShiftWidth()"}
|
4869
|
69 if exists("g:html_indent_script1")
|
|
70 let s:js1indent = get(indone, g:html_indent_script1, indone.zero)
|
|
71 endif
|
|
72 if exists("g:html_indent_style1")
|
|
73 let s:css1indent = get(indone, g:html_indent_style1, indone.zero)
|
|
74 endif
|
|
75 endfunc "}}}
|
|
76
|
|
77 " Init Script Vars "{{{
|
6009
|
78 let s:lasttick = 0
|
4869
|
79 let s:css1indent = 0
|
|
80 let s:js1indent = 0
|
|
81 " not to be changed:
|
|
82 let s:endtags = [0,0,0,0,0,0,0,0] " some places unused
|
|
83 let s:newstate = {}
|
|
84 let s:countonly = 0
|
|
85 "}}}
|
|
86 func! s:AddITags(taglist) "{{{
|
|
87 for itag in a:taglist
|
|
88 let s:indent_tags[itag] = 1
|
|
89 let s:indent_tags['/'.itag] = -1
|
|
90 endfor
|
|
91 endfunc "}}}
|
|
92 func! s:AddBlockTag(tag, id, ...) "{{{
|
|
93 if !(a:id >= 2 && a:id < 2+len(s:endtags))
|
|
94 return
|
|
95 endif
|
|
96 let s:indent_tags[a:tag] = a:id
|
|
97 if a:0 == 0
|
|
98 let s:indent_tags['/'.a:tag] = -a:id
|
|
99 let s:endtags[a:id-2] = "</".a:tag.">"
|
|
100 else
|
|
101 let s:indent_tags[a:1] = -a:id
|
|
102 let s:endtags[a:id-2] = a:1
|
|
103 endif
|
|
104 endfunc "}}}
|
|
105 func! s:RemoveITags(taglist) "{{{
|
|
106 " remove itags (protect blocktags from being removed)
|
|
107 for itag in a:taglist
|
|
108 if !has_key(s:indent_tags, itag) || s:indent_tags[itag] != 1
|
|
109 continue
|
|
110 endif
|
|
111 unlet s:indent_tags[itag]
|
|
112 if itag =~ '^\w\+$'
|
|
113 unlet s:indent_tags["/".itag]
|
|
114 endif
|
|
115 endfor
|
|
116 endfunc "}}}
|
|
117 " Add Indent Tags: {{{
|
|
118 if !exists("s:indent_tags")
|
|
119 let s:indent_tags = {}
|
|
120 endif
|
|
121
|
|
122 " old tags:
|
|
123 call s:AddITags(['a', 'abbr', 'acronym', 'address', 'b', 'bdo', 'big',
|
|
124 \ 'blockquote', 'button', 'caption', 'center', 'cite', 'code', 'colgroup',
|
|
125 \ 'del', 'dfn', 'dir', 'div', 'dl', 'em', 'fieldset', 'font', 'form',
|
|
126 \ 'frameset', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'i', 'iframe', 'ins', 'kbd',
|
|
127 \ 'label', 'legend', 'map', 'menu', 'noframes', 'noscript', 'object', 'ol',
|
|
128 \ 'optgroup', 'q', 's', 'samp', 'select', 'small', 'span', 'strong', 'sub',
|
|
129 \ 'sup', 'table', 'textarea', 'title', 'tt', 'u', 'ul', 'var', 'th', 'td',
|
|
130 \ 'tr', 'tfoot', 'thead'])
|
|
131
|
|
132 " tags added 2011 Sep 09 (especially HTML5 tags):
|
|
133 call s:AddITags(['area', 'article', 'aside', 'audio', 'bdi', 'canvas',
|
|
134 \ 'command', 'datalist', 'details', 'embed', 'figure', 'footer',
|
|
135 \ 'header', 'group', 'keygen', 'mark', 'math', 'meter', 'nav', 'output',
|
|
136 \ 'progress', 'ruby', 'section', 'svg', 'texture', 'time', 'video',
|
|
137 \ 'wbr', 'text'])
|
|
138
|
|
139 "}}}
|
|
140 " Add Block Tags: contain alien content "{{{
|
|
141 call s:AddBlockTag('pre', 2)
|
|
142 call s:AddBlockTag('script', 3)
|
|
143 call s:AddBlockTag('style', 4)
|
|
144 call s:AddBlockTag('<!--', 5, '-->')
|
|
145 "}}}
|
|
146
|
|
147 func! s:CountITags(...) "{{{
|
|
148
|
|
149 " relative indent steps for current line [unit &sw]:
|
|
150 let s:curind = 0
|
|
151 " relative indent steps for next line [unit &sw]:
|
|
152 let s:nextrel = 0
|
7
|
153
|
4869
|
154 if a:0==0
|
|
155 let s:block = s:newstate.block
|
6009
|
156 let tmpline = substitute(s:curline, '<\zs/\=\w\+\>\|<!--\|-->', '\=s:CheckTag(submatch(0))', 'g')
|
4869
|
157 if s:block == 3
|
|
158 let s:newstate.scripttype = s:GetScriptType(matchstr(tmpline, '\C.*<SCRIPT\>\zs[^>]*'))
|
|
159 endif
|
|
160 let s:newstate.block = s:block
|
|
161 else
|
|
162 let s:block = 0 " assume starting outside of a block
|
|
163 let s:countonly = 1 " don't change state
|
6009
|
164 let tmpline = substitute(s:altline, '<\zs/\=\w\+\>\|<!--\|-->', '\=s:CheckTag(submatch(0))', 'g')
|
4869
|
165 let s:countonly = 0
|
|
166 endif
|
|
167 endfunc "}}}
|
|
168 func! s:CheckTag(itag) "{{{
|
|
169 " "tag" or "/tag" or "<!--" or "-->"
|
|
170 let ind = get(s:indent_tags, a:itag)
|
|
171 if ind == -1
|
|
172 " closing tag
|
|
173 if s:block != 0
|
|
174 " ignore itag within a block
|
|
175 return "foo"
|
|
176 endif
|
|
177 if s:nextrel == 0
|
|
178 let s:curind -= 1
|
|
179 else
|
|
180 let s:nextrel -= 1
|
|
181 endif
|
|
182 " if s:curind >= 1
|
|
183 " let s:curind -= 1
|
|
184 " else
|
|
185 " let s:nextrel -= 1
|
|
186 " endif
|
|
187 elseif ind == 1
|
|
188 " opening tag
|
|
189 if s:block != 0
|
|
190 return "foo"
|
867
|
191 endif
|
4869
|
192 let s:nextrel += 1
|
|
193 elseif ind != 0
|
|
194 " block-tag (opening or closing)
|
|
195 return s:Blocktag(a:itag, ind)
|
|
196 endif
|
|
197 " else ind==0 (other tag found): keep indent
|
|
198 return "foo" " no matter
|
|
199 endfunc "}}}
|
|
200 func! s:Blocktag(blocktag, ind) "{{{
|
|
201 if a:ind > 0
|
|
202 " a block starts here
|
|
203 if s:block != 0
|
|
204 " already in a block (nesting) - ignore
|
|
205 " especially ignore comments after other blocktags
|
|
206 return "foo"
|
|
207 endif
|
|
208 let s:block = a:ind " block type
|
|
209 if s:countonly
|
|
210 return "foo"
|
|
211 endif
|
|
212 let s:newstate.blocklnr = v:lnum
|
|
213 " save allover indent for the endtag
|
4911
|
214 let s:newstate.blocktagind = b:indent.baseindent + (s:nextrel + s:curind) * s:ShiftWidth()
|
4869
|
215 if a:ind == 3
|
|
216 return "SCRIPT" " all except this must be lowercase
|
|
217 " line is to be checked again for the type attribute
|
|
218 endif
|
|
219 else
|
|
220 let s:block = 0
|
|
221 " we get here if starting and closing block-tag on same line
|
|
222 endif
|
|
223 return "foo"
|
|
224 endfunc "}}}
|
|
225 func! s:GetScriptType(str) "{{{
|
|
226 if a:str == "" || a:str =~ "java"
|
|
227 return "javascript"
|
|
228 else
|
|
229 return ""
|
|
230 endif
|
|
231 endfunc "}}}
|
|
232
|
|
233 func! s:FreshState(lnum) "{{{
|
|
234 " Look back in the file (lines 1 to a:lnum-1) to calc a state for line
|
|
235 " a:lnum. A state is to know ALL relevant details about the lines
|
|
236 " 1..a:lnum-1, initial calculating (here!) can be slow, but updating is
|
|
237 " fast (incremental).
|
|
238 " State:
|
|
239 " lnum last indented line == prevnonblank(a:lnum - 1)
|
|
240 " block = 0 a:lnum located within special tag: 0:none, 2:<pre>,
|
|
241 " 3:<script>, 4:<style>, 5:<!--
|
|
242 " baseindent use this indent for line a:lnum as a start - kind of
|
|
243 " autoindent (if block==0)
|
|
244 " scripttype = '' type attribute of a script tag (if block==3)
|
|
245 " blocktagind indent for current opening (get) and closing (set)
|
|
246 " blocktag (if block!=0)
|
|
247 " blocklnr lnum of starting blocktag (if block!=0)
|
|
248 " inattr line {lnum} starts with attributes of a tag
|
|
249 let state = {}
|
|
250 let state.lnum = prevnonblank(a:lnum - 1)
|
|
251 let state.scripttype = ""
|
|
252 let state.blocktagind = -1
|
|
253 let state.block = 0
|
|
254 let state.baseindent = 0
|
|
255 let state.blocklnr = 0
|
|
256 let state.inattr = 0
|
|
257
|
|
258 if state.lnum == 0
|
|
259 return state
|
7
|
260 endif
|
|
261
|
4869
|
262 " Heuristic:
|
|
263 " remember startline state.lnum
|
|
264 " look back for <pre, </pre, <script, </script, <style, </style tags
|
|
265 " remember stopline
|
|
266 " if opening tag found,
|
|
267 " assume a:lnum within block
|
|
268 " else
|
|
269 " look back in result range (stopline, startline) for comment
|
|
270 " \ delimiters (<!--, -->)
|
|
271 " if comment opener found,
|
|
272 " assume a:lnum within comment
|
|
273 " else
|
|
274 " assume usual html for a:lnum
|
|
275 " if a:lnum-1 has a closing comment
|
|
276 " look back to get indent of comment opener
|
|
277 " FI
|
1121
|
278
|
4869
|
279 " look back for blocktag
|
|
280 call cursor(a:lnum, 1)
|
|
281 let [stopline, stopcol] = searchpos('\c<\zs\/\=\%(pre\>\|script\>\|style\>\)', "bW")
|
|
282 " fugly ... why isn't there searchstr()
|
|
283 let tagline = tolower(getline(stopline))
|
|
284 let blocktag = matchstr(tagline, '\/\=\%(pre\>\|script\>\|style\>\)', stopcol-1)
|
|
285 if stopline > 0 && blocktag[0] != "/"
|
|
286 " opening tag found, assume a:lnum within block
|
|
287 let state.block = s:indent_tags[blocktag]
|
|
288 if state.block == 3
|
|
289 let state.scripttype = s:GetScriptType(matchstr(tagline, '\>[^>]*', stopcol))
|
|
290 endif
|
|
291 let state.blocklnr = stopline
|
|
292 " check preceding tags in the line:
|
|
293 let s:altline = tagline[: stopcol-2]
|
|
294 call s:CountITags(1)
|
4911
|
295 let state.blocktagind = indent(stopline) + (s:curind + s:nextrel) * s:ShiftWidth()
|
4869
|
296 return state
|
|
297 elseif stopline == state.lnum
|
|
298 " handle special case: previous line (= state.lnum) contains a
|
|
299 " closing blocktag which is preceded by line-noise;
|
|
300 " blocktag == "/..."
|
|
301 let swendtag = match(tagline, '^\s*</') >= 0
|
|
302 if !swendtag
|
|
303 let [bline, bcol] = searchpos('<'.blocktag[1:].'\>', "bW")
|
|
304 let s:altline = tolower(getline(bline)[: bcol-2])
|
|
305 call s:CountITags(1)
|
4911
|
306 let state.baseindent = indent(bline) + (s:nextrel+s:curline) * s:ShiftWidth()
|
4869
|
307 return state
|
7
|
308 endif
|
|
309 endif
|
|
310
|
4869
|
311 " else look back for comment
|
|
312 call cursor(a:lnum, 1)
|
|
313 let [comline, comcol, found] = searchpos('\(<!--\)\|-->', 'bpW', stopline)
|
|
314 if found == 2
|
|
315 " comment opener found, assume a:lnum within comment
|
|
316 let state.block = 5
|
|
317 let state.blocklnr = comline
|
|
318 " check preceding tags in the line:
|
|
319 let s:altline = tolower(getline(comline)[: comcol-2])
|
|
320 call s:CountITags(1)
|
4911
|
321 let state.blocktagind = indent(comline) + (s:curind + s:nextrel) * s:ShiftWidth()
|
4869
|
322 return state
|
|
323 endif
|
|
324
|
|
325 " else within usual html
|
|
326 let s:altline = tolower(getline(state.lnum))
|
6009
|
327
|
4869
|
328 " check a:lnum-1 for closing comment (we need indent from the opening line)
|
|
329 let comcol = stridx(s:altline, '-->')
|
|
330 if comcol >= 0
|
|
331 call cursor(state.lnum, comcol+1)
|
|
332 let [comline, comcol] = searchpos('<!--', 'bW')
|
|
333 if comline == state.lnum
|
|
334 let s:altline = s:altline[: comcol-2]
|
|
335 else
|
|
336 let s:altline = tolower(getline(comline)[: comcol-2])
|
7
|
337 endif
|
4869
|
338 call s:CountITags(1)
|
4911
|
339 let state.baseindent = indent(comline) + (s:nextrel+s:curline) * s:ShiftWidth()
|
4869
|
340 return state
|
|
341 " TODO check tags that follow "-->"
|
7
|
342 endif
|
|
343
|
6009
|
344 " Check if the previous line starts with end tag.
|
|
345 let swendtag = match(s:altline, '^\s*</') >= 0
|
|
346
|
|
347 " If previous line ended in a closing tag, line up with the opening tag.
|
|
348 " Avoids aligning with continuation lines.
|
|
349 " TODO: this assumes the start tag is at the start of a line.
|
|
350 if !swendtag && s:altline =~ '</\w\+\s*>\s*$'
|
|
351 call cursor(state.lnum, 99999)
|
|
352 normal F<h
|
|
353 " TODO: doesn't work for nested <br> and the like
|
|
354 let slnum = searchpair('<\w\+', '', '</\w', 'bW')
|
|
355 if slnum > 0
|
|
356 let state.baseindent = indent(slnum)
|
|
357 return state
|
|
358 endif
|
|
359 endif
|
|
360
|
4869
|
361 " else no comments
|
6009
|
362 let state.lnum = s:FindTagStart(state.lnum)
|
|
363 let s:altline = tolower(getline(state.lnum))
|
4869
|
364 call s:CountITags(1)
|
4911
|
365 let state.baseindent = indent(state.lnum) + s:nextrel * s:ShiftWidth()
|
4869
|
366 if !swendtag
|
4911
|
367 let state.baseindent += s:curind * s:ShiftWidth()
|
4869
|
368 endif
|
|
369 return state
|
|
370 endfunc "}}}
|
|
371
|
|
372 func! s:Alien2() "{{{
|
|
373 " <pre> block
|
|
374 return -1
|
|
375 endfunc "}}}
|
|
376 func! s:Alien3() "{{{
|
|
377 " <script> javascript
|
|
378 if prevnonblank(v:lnum-1) == b:indent.blocklnr
|
|
379 " indent for the first line after <script>
|
|
380 return eval(s:js1indent)
|
|
381 endif
|
|
382 if b:indent.scripttype == "javascript"
|
|
383 return cindent(v:lnum)
|
|
384 else
|
|
385 return -1
|
|
386 endif
|
|
387 endfunc "}}}
|
|
388 func! s:Alien4() "{{{
|
|
389 " <style>
|
|
390 if prevnonblank(v:lnum-1) == b:indent.blocklnr
|
|
391 " indent for first content line
|
|
392 return eval(s:css1indent)
|
|
393 endif
|
|
394 return s:CSSIndent()
|
|
395 endfunc
|
7
|
396
|
4869
|
397 func! s:CSSIndent() "{{{
|
|
398 " adopted $VIMRUNTIME/indent/css.vim
|
|
399 if getline(v:lnum) =~ '^\s*[*}]'
|
|
400 return cindent(v:lnum)
|
|
401 endif
|
|
402 let minline = b:indent.blocklnr
|
|
403 let pnum = s:css_prevnoncomment(v:lnum - 1, minline)
|
6009
|
404 let pnum = s:FindTagStart(pnum)
|
4869
|
405 if pnum <= minline
|
|
406 " < is to catch errors
|
|
407 " indent for first content line after comments
|
|
408 return eval(s:css1indent)
|
|
409 endif
|
4911
|
410 let ind = indent(pnum) + s:css_countbraces(pnum, 1) * s:ShiftWidth()
|
4869
|
411 let pline = getline(pnum)
|
|
412 if pline =~ '}\s*$'
|
4911
|
413 let ind -= (s:css_countbraces(pnum, 0) - (pline =~ '^\s*}')) * s:ShiftWidth()
|
4869
|
414 endif
|
|
415 return ind
|
|
416 endfunc "}}}
|
|
417 func! s:css_prevnoncomment(lnum, stopline) "{{{
|
|
418 " caller starts from a line a:lnum-1 that is not a comment
|
|
419 let lnum = prevnonblank(a:lnum)
|
|
420 let ccol = match(getline(lnum), '\*/')
|
|
421 if ccol < 0
|
|
422 return lnum
|
|
423 endif
|
|
424 call cursor(lnum, ccol+1)
|
|
425 let lnum = search('/\*', 'bW', a:stopline)
|
|
426 if indent(".") == virtcol(".")-1
|
|
427 return prevnonblank(lnum-1)
|
|
428 else
|
|
429 return lnum
|
|
430 endif
|
|
431 endfunc "}}}
|
|
432 func! s:css_countbraces(lnum, count_open) "{{{
|
|
433 let brs = substitute(getline(a:lnum),'[''"].\{-}[''"]\|/\*.\{-}\*/\|/\*.*$\|[^{}]','','g')
|
|
434 let n_open = 0
|
|
435 let n_close = 0
|
|
436 for brace in split(brs, '\zs')
|
|
437 if brace == "{"
|
|
438 let n_open += 1
|
|
439 elseif brace == "}"
|
|
440 if n_open > 0
|
|
441 let n_open -= 1
|
|
442 else
|
|
443 let n_close += 1
|
|
444 endif
|
|
445 endif
|
|
446 endfor
|
|
447 return a:count_open ? n_open : n_close
|
|
448 endfunc "}}}
|
|
449
|
|
450 "}}}
|
|
451 func! s:Alien5() "{{{
|
|
452 " <!-- -->
|
|
453 return -1
|
|
454 endfunc "}}}
|
|
455
|
6009
|
456 " When the "lnum" line ends in ">" find the line containing the
|
|
457 " matching "<". Avoids using the indent of a continuation line.
|
|
458 " Moves the cursor.
|
|
459 " Return the matching line number or "lnum".
|
|
460 func! s:FindTagStart(lnum) "{{{
|
|
461 if getline(a:lnum) =~ '>\s*$'
|
|
462 call cursor(a:lnum, 99999)
|
|
463 normal! %
|
|
464 return line('.')
|
|
465 endif
|
|
466 return a:lnum
|
|
467 endfunc "}}}
|
|
468
|
4869
|
469 func! HtmlIndent() "{{{
|
|
470 let s:curline = tolower(getline(v:lnum))
|
4911
|
471 let indentunit = s:ShiftWidth()
|
4869
|
472
|
|
473 let s:newstate = {}
|
|
474 let s:newstate.lnum = v:lnum
|
|
475
|
4911
|
476 " does the line start with a closing tag?
|
4869
|
477 let swendtag = match(s:curline, '^\s*</') >= 0
|
|
478
|
6009
|
479 if prevnonblank(v:lnum-1) == b:indent.lnum && s:lasttick == b:changedtick - 1
|
4869
|
480 " use state (continue from previous line)
|
|
481 else
|
|
482 " start over (know nothing)
|
|
483 let b:indent = s:FreshState(v:lnum)
|
7
|
484 endif
|
|
485
|
4869
|
486 if b:indent.block >= 2
|
|
487 " within block
|
|
488 let endtag = s:endtags[b:indent.block-2]
|
|
489 let blockend = stridx(s:curline, endtag)
|
|
490 if blockend >= 0
|
|
491 " block ends here
|
|
492 let s:newstate.block = 0
|
|
493 " calc indent for REST OF LINE (may start more blocks):
|
|
494 let s:curline = strpart(s:curline, blockend+strlen(endtag))
|
|
495 call s:CountITags()
|
|
496 if swendtag && b:indent.block != 5
|
4911
|
497 let indent = b:indent.blocktagind + s:curind * indentunit
|
|
498 let s:newstate.baseindent = indent + s:nextrel * indentunit
|
4869
|
499 else
|
|
500 let indent = s:Alien{b:indent.block}()
|
4911
|
501 let s:newstate.baseindent = b:indent.blocktagind + s:nextrel * indentunit
|
4869
|
502 endif
|
|
503 else
|
|
504 " block continues
|
|
505 " indent this line with alien method
|
|
506 let indent = s:Alien{b:indent.block}()
|
|
507 endif
|
|
508 else
|
|
509 " not within a block - within usual html
|
|
510 " if < 2 then always 0
|
|
511 let s:newstate.block = b:indent.block
|
|
512 call s:CountITags()
|
|
513 if swendtag
|
4911
|
514 let indent = b:indent.baseindent + s:curind * indentunit
|
|
515 let s:newstate.baseindent = indent + s:nextrel * indentunit
|
4869
|
516 else
|
|
517 let indent = b:indent.baseindent
|
4911
|
518 let s:newstate.baseindent = indent + (s:curind + s:nextrel) * indentunit
|
4869
|
519 endif
|
|
520 endif
|
6009
|
521 let s:lasttick = b:changedtick
|
|
522 call extend(b:indent, s:newstate, "force")
|
|
523 return indent
|
4869
|
524
|
|
525 endfunc "}}}
|
|
526
|
|
527 " check user settings (first time), clear cpo, Modeline: {{{1
|
|
528
|
|
529 " DEBUG:
|
|
530 com! -nargs=* IndHtmlLocal <args>
|
|
531
|
|
532 call HtmlIndent_CheckUserSettings()
|
7
|
533
|
867
|
534 let &cpo = s:cpo_save
|
|
535 unlet s:cpo_save
|
|
536
|
4869
|
537 " vim:set fdm=marker ts=8:
|