annotate runtime/indent/html.vim @ 14637:0ecb909e3249

Update runtime files. commit https://github.com/vim/vim/commit/fc65cabb15d0236bce001ad78e12a40511caf941 Author: Bram Moolenaar <Bram@vim.org> Date: Tue Aug 28 22:58:02 2018 +0200 Update runtime files.
author Christian Brabandt <cb@256bit.org>
date Tue, 28 Aug 2018 23:00:08 +0200
parents 5923f64c8f5b
children 2b30a2b4bde2
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
4869
a5352e73dc00 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents: 1121
diff changeset
1 " Vim indent script for HTML
6032
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
2 " Header: "{{{
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
3 " Maintainer: Bram Moolenaar
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
4 " Original Author: Andy Wokula <anwoku@yahoo.de>
13563
5923f64c8f5b Update runtime files
Christian Brabandt <cb@256bit.org>
parents: 13482
diff changeset
5 " Last Change: 2018 Mar 28
6032
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
6 " Version: 1.0
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
7 " Description: HTML indent script with cached state for faster indenting on a
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
8 " range of lines.
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
9 " Supports template systems through hooks.
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
10 " Supports Closure stylesheets.
4869
a5352e73dc00 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents: 1121
diff changeset
11 "
a5352e73dc00 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents: 1121
diff changeset
12 " Credits:
a5352e73dc00 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents: 1121
diff changeset
13 " indent/html.vim (2006 Jun 05) from J. Zellner
a5352e73dc00 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents: 1121
diff changeset
14 " indent/css.vim (2006 Dec 20) from N. Weibull
a5352e73dc00 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents: 1121
diff changeset
15 "
a5352e73dc00 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents: 1121
diff changeset
16 " History:
6032
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
17 " 2014 June (v1.0) overhaul (Bram)
4911
78c318784090 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4869
diff changeset
18 " 2012 Oct 21 (v0.9) added support for shiftwidth()
78c318784090 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4869
diff changeset
19 " 2011 Sep 09 (v0.8) added HTML5 tags (thx to J. Zuckerman)
78c318784090 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4869
diff changeset
20 " 2008 Apr 28 (v0.6) revised customization
78c318784090 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4869
diff changeset
21 " 2008 Mar 09 (v0.5) fixed 'indk' issue (thx to C.J. Robinson)
6032
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
22 "}}}
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
23
6032
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
24 " Init Folklore, check user settings (2nd time ++)
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
25 if exists("b:did_indent") "{{{
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
26 finish
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
27 endif
10734
523cd59d6db0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 10228
diff changeset
28
523cd59d6db0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 10228
diff changeset
29 " Load the Javascript indent script first, it defines GetJavascriptIndent().
523cd59d6db0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 10228
diff changeset
30 " Undo the rest.
523cd59d6db0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 10228
diff changeset
31 " Load base python indent.
523cd59d6db0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 10228
diff changeset
32 if !exists('*GetJavascriptIndent')
523cd59d6db0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 10228
diff changeset
33 runtime! indent/javascript.vim
523cd59d6db0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 10228
diff changeset
34 endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
35 let b:did_indent = 1
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
36
4869
a5352e73dc00 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents: 1121
diff changeset
37 setlocal indentexpr=HtmlIndent()
a5352e73dc00 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents: 1121
diff changeset
38 setlocal indentkeys=o,O,<Return>,<>>,{,},!^F
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
39
6032
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
40 " Needed for % to work when finding start/end of a tag.
6009
7b83c190d370 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4911
diff changeset
41 setlocal matchpairs+=<:>
7b83c190d370 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4911
diff changeset
42
10734
523cd59d6db0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 10228
diff changeset
43 let b:undo_indent = "setlocal inde< indk<"
6032
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
44
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
45 " b:hi_indent keeps state to speed up indenting consecutive lines.
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
46 let b:hi_indent = {"lnum": -1}
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
47
6032
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
48 """""" Code below this is loaded only once. """""
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
49 if exists("*HtmlIndent") && !exists('g:force_reload_html')
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
50 call HtmlIndent_CheckUserSettings()
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
51 finish
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
52 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
53
6032
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
54 " Allow for line continuation below.
867
a5677b7ce858 updated for version 7.0g04
vimboss
parents: 856
diff changeset
55 let s:cpo_save = &cpo
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
56 set cpo-=C
4869
a5352e73dc00 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents: 1121
diff changeset
57 "}}}
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
58
13437
02b3f719eacb Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
59 " Pattern to match the name of a tag, including custom elements.
02b3f719eacb Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
60 let s:tagname = '\w\+\(-\w\+\)*'
02b3f719eacb Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
61
6032
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
62 " Check and process settings from b:html_indent and g:html_indent... variables.
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
63 " Prefer using buffer-local settings over global settings, so that there can
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
64 " be defaults for all HTML files and exceptions for specific types of HTML
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
65 " files.
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
66 func! HtmlIndent_CheckUserSettings()
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
67 "{{{
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
68 let inctags = ''
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
69 if exists("b:html_indent_inctags")
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
70 let inctags = b:html_indent_inctags
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
71 elseif exists("g:html_indent_inctags")
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
72 let inctags = g:html_indent_inctags
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
73 endif
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
74 let b:hi_tags = {}
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
75 if len(inctags) > 0
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
76 call s:AddITags(b:hi_tags, split(inctags, ","))
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
77 endif
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
78
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
79 let autotags = ''
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
80 if exists("b:html_indent_autotags")
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
81 let autotags = b:html_indent_autotags
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
82 elseif exists("g:html_indent_autotags")
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
83 let autotags = g:html_indent_autotags
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
84 endif
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
85 let b:hi_removed_tags = {}
6840
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 6663
diff changeset
86 if len(autotags) > 0
6032
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
87 call s:RemoveITags(b:hi_removed_tags, split(autotags, ","))
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
88 endif
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
89
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
90 " Syntax names indicating being inside a string of an attribute value.
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
91 let string_names = []
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
92 if exists("b:html_indent_string_names")
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
93 let string_names = b:html_indent_string_names
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
94 elseif exists("g:html_indent_string_names")
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
95 let string_names = g:html_indent_string_names
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
96 endif
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
97 let b:hi_insideStringNames = ['htmlString']
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
98 if len(string_names) > 0
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
99 for s in string_names
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
100 call add(b:hi_insideStringNames, s)
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
101 endfor
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
102 endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
103
6032
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
104 " Syntax names indicating being inside a tag.
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
105 let tag_names = []
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
106 if exists("b:html_indent_tag_names")
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
107 let tag_names = b:html_indent_tag_names
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
108 elseif exists("g:html_indent_tag_names")
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
109 let tag_names = g:html_indent_tag_names
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
110 endif
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
111 let b:hi_insideTagNames = ['htmlTag', 'htmlScriptTag']
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
112 if len(tag_names) > 0
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
113 for s in tag_names
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
114 call add(b:hi_insideTagNames, s)
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
115 endfor
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
116 endif
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
117
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
118 let indone = {"zero": 0
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
119 \,"auto": "indent(prevnonblank(v:lnum-1))"
11518
63b0b7b79b25 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 10734
diff changeset
120 \,"inc": "b:hi_indent.blocktagind + shiftwidth()"}
6032
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
121
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
122 let script1 = ''
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
123 if exists("b:html_indent_script1")
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
124 let script1 = b:html_indent_script1
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
125 elseif exists("g:html_indent_script1")
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
126 let script1 = g:html_indent_script1
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
127 endif
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
128 if len(script1) > 0
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
129 let b:hi_js1indent = get(indone, script1, indone.zero)
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
130 else
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
131 let b:hi_js1indent = 0
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
132 endif
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
133
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
134 let style1 = ''
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
135 if exists("b:html_indent_style1")
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
136 let style1 = b:html_indent_style1
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
137 elseif exists("g:html_indent_style1")
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
138 let style1 = g:html_indent_style1
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
139 endif
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
140 if len(style1) > 0
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
141 let b:hi_css1indent = get(indone, style1, indone.zero)
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
142 else
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
143 let b:hi_css1indent = 0
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
144 endif
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
145
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
146 if !exists('b:html_indent_line_limit')
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
147 if exists('g:html_indent_line_limit')
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
148 let b:html_indent_line_limit = g:html_indent_line_limit
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
149 else
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
150 let b:html_indent_line_limit = 200
4869
a5352e73dc00 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents: 1121
diff changeset
151 endif
6032
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
152 endif
4869
a5352e73dc00 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents: 1121
diff changeset
153 endfunc "}}}
a5352e73dc00 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents: 1121
diff changeset
154
6032
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
155 " Init Script Vars
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
156 "{{{
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
157 let b:hi_lasttick = 0
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
158 let b:hi_newstate = {}
4869
a5352e73dc00 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents: 1121
diff changeset
159 let s:countonly = 0
a5352e73dc00 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents: 1121
diff changeset
160 "}}}
6032
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
161
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
162 " Fill the s:indent_tags dict with known tags.
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
163 " The key is "tagname" or "/tagname". {{{
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
164 " The value is:
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
165 " 1 opening tag
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
166 " 2 "pre"
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
167 " 3 "script"
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
168 " 4 "style"
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
169 " 5 comment start
7147
c590de398af9 commit https://github.com/vim/vim/commit/ca63501fbcd1cf9c8aa9ff12c093c95b62a89ed7
Christian Brabandt <cb@256bit.org>
parents: 6840
diff changeset
170 " 6 conditional comment start
6032
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
171 " -1 closing tag
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
172 " -2 "/pre"
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
173 " -3 "/script"
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
174 " -4 "/style"
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
175 " -5 comment end
7147
c590de398af9 commit https://github.com/vim/vim/commit/ca63501fbcd1cf9c8aa9ff12c093c95b62a89ed7
Christian Brabandt <cb@256bit.org>
parents: 6840
diff changeset
176 " -6 conditional comment end
6032
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
177 let s:indent_tags = {}
7147
c590de398af9 commit https://github.com/vim/vim/commit/ca63501fbcd1cf9c8aa9ff12c093c95b62a89ed7
Christian Brabandt <cb@256bit.org>
parents: 6840
diff changeset
178 let s:endtags = [0,0,0,0,0,0,0] " long enough for the highest index
6032
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
179 "}}}
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
180
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
181 " Add a list of tag names for a pair of <tag> </tag> to "tags".
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
182 func! s:AddITags(tags, taglist)
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
183 "{{{
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
184 for itag in a:taglist
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
185 let a:tags[itag] = 1
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
186 let a:tags['/' . itag] = -1
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
187 endfor
4869
a5352e73dc00 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents: 1121
diff changeset
188 endfunc "}}}
6032
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
189
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
190 " Take a list of tag name pairs that are not to be used as tag pairs.
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
191 func! s:RemoveITags(tags, taglist)
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
192 "{{{
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
193 for itag in a:taglist
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
194 let a:tags[itag] = 1
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
195 let a:tags['/' . itag] = 1
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
196 endfor
4869
a5352e73dc00 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents: 1121
diff changeset
197 endfunc "}}}
a5352e73dc00 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents: 1121
diff changeset
198
6032
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
199 " Add a block tag, that is a tag with a different kind of indenting.
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
200 func! s:AddBlockTag(tag, id, ...)
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
201 "{{{
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
202 if !(a:id >= 2 && a:id < len(s:endtags))
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
203 echoerr 'AddBlockTag ' . a:id
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
204 return
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
205 endif
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
206 let s:indent_tags[a:tag] = a:id
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
207 if a:0 == 0
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
208 let s:indent_tags['/' . a:tag] = -a:id
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
209 let s:endtags[a:id] = "</" . a:tag . ">"
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
210 else
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
211 let s:indent_tags[a:1] = -a:id
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
212 let s:endtags[a:id] = a:1
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
213 endif
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
214 endfunc "}}}
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
215
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
216 " Add known tag pairs.
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
217 " Self-closing tags and tags that are sometimes {{{
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
218 " self-closing (e.g., <p>) are not here (when encountering </p> we can find
13563
5923f64c8f5b Update runtime files
Christian Brabandt <cb@256bit.org>
parents: 13482
diff changeset
219 " the matching <p>, but not the other way around). Known self-closing tags:
5923f64c8f5b Update runtime files
Christian Brabandt <cb@256bit.org>
parents: 13482
diff changeset
220 " 'p', 'img', 'source'.
6032
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
221 " Old HTML tags:
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
222 call s:AddITags(s:indent_tags, [
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
223 \ 'a', 'abbr', 'acronym', 'address', 'b', 'bdo', 'big',
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
224 \ 'blockquote', 'body', 'button', 'caption', 'center', 'cite', 'code',
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
225 \ 'colgroup', 'del', 'dfn', 'dir', 'div', 'dl', 'em', 'fieldset', 'font',
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
226 \ 'form', 'frameset', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'head', 'html',
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
227 \ 'i', 'iframe', 'ins', 'kbd', 'label', 'legend', 'li',
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
228 \ 'map', 'menu', 'noframes', 'noscript', 'object', 'ol',
4869
a5352e73dc00 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents: 1121
diff changeset
229 \ 'optgroup', 'q', 's', 'samp', 'select', 'small', 'span', 'strong', 'sub',
a5352e73dc00 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents: 1121
diff changeset
230 \ 'sup', 'table', 'textarea', 'title', 'tt', 'u', 'ul', 'var', 'th', 'td',
6032
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
231 \ 'tr', 'tbody', 'tfoot', 'thead'])
4869
a5352e73dc00 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents: 1121
diff changeset
232
8869
b73f9ed65072 commit https://github.com/vim/vim/commit/939a1abe935a539f2d4c90a56cb0682cbaf3bbb0
Christian Brabandt <cb@256bit.org>
parents: 7147
diff changeset
233 " New HTML5 elements:
6032
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
234 call s:AddITags(s:indent_tags, [
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
235 \ 'area', 'article', 'aside', 'audio', 'bdi', 'canvas',
8869
b73f9ed65072 commit https://github.com/vim/vim/commit/939a1abe935a539f2d4c90a56cb0682cbaf3bbb0
Christian Brabandt <cb@256bit.org>
parents: 7147
diff changeset
236 \ 'command', 'data', 'datalist', 'details', 'embed', 'figcaption',
13482
9eebe457eb3c Update runtime files. Convert a couple of help files to utf-8.
Christian Brabandt <cb@256bit.org>
parents: 13437
diff changeset
237 \ 'figure', 'footer', 'header', 'keygen', 'main', 'mark', 'meter',
13563
5923f64c8f5b Update runtime files
Christian Brabandt <cb@256bit.org>
parents: 13482
diff changeset
238 \ 'nav', 'output', 'picture', 'progress', 'rp', 'rt', 'ruby', 'section',
13482
9eebe457eb3c Update runtime files. Convert a couple of help files to utf-8.
Christian Brabandt <cb@256bit.org>
parents: 13437
diff changeset
239 \ 'summary', 'svg', 'time', 'track', 'video', 'wbr'])
6663
056809de0b29 updated for version 7.4.656
Bram Moolenaar <bram@vim.org>
parents: 6484
diff changeset
240
056809de0b29 updated for version 7.4.656
Bram Moolenaar <bram@vim.org>
parents: 6484
diff changeset
241 " Tags added for web components:
056809de0b29 updated for version 7.4.656
Bram Moolenaar <bram@vim.org>
parents: 6484
diff changeset
242 call s:AddITags(s:indent_tags, [
056809de0b29 updated for version 7.4.656
Bram Moolenaar <bram@vim.org>
parents: 6484
diff changeset
243 \ 'content', 'shadow', 'template'])
6032
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
244 "}}}
4869
a5352e73dc00 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents: 1121
diff changeset
245
6032
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
246 " Add Block Tags: these contain alien content
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
247 "{{{
4869
a5352e73dc00 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents: 1121
diff changeset
248 call s:AddBlockTag('pre', 2)
a5352e73dc00 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents: 1121
diff changeset
249 call s:AddBlockTag('script', 3)
a5352e73dc00 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents: 1121
diff changeset
250 call s:AddBlockTag('style', 4)
a5352e73dc00 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents: 1121
diff changeset
251 call s:AddBlockTag('<!--', 5, '-->')
7147
c590de398af9 commit https://github.com/vim/vim/commit/ca63501fbcd1cf9c8aa9ff12c093c95b62a89ed7
Christian Brabandt <cb@256bit.org>
parents: 6840
diff changeset
252 call s:AddBlockTag('<!--[', 6, '![endif]-->')
4869
a5352e73dc00 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents: 1121
diff changeset
253 "}}}
a5352e73dc00 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents: 1121
diff changeset
254
6032
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
255 " Return non-zero when "tagname" is an opening tag, not being a block tag, for
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
256 " which there should be a closing tag. Can be used by scripts that include
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
257 " HTML indenting.
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
258 func! HtmlIndent_IsOpenTag(tagname)
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
259 "{{{
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
260 if get(s:indent_tags, a:tagname) == 1
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
261 return 1
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
262 endif
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
263 return get(b:hi_tags, a:tagname) == 1
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
264 endfunc "}}}
4869
a5352e73dc00 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents: 1121
diff changeset
265
6032
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
266 " Get the value for "tagname", taking care of buffer-local tags.
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
267 func! s:get_tag(tagname)
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
268 "{{{
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
269 let i = get(s:indent_tags, a:tagname)
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
270 if (i == 1 || i == -1) && get(b:hi_removed_tags, a:tagname) != 0
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
271 return 0
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
272 endif
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
273 if i == 0
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
274 let i = get(b:hi_tags, a:tagname)
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
275 endif
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
276 return i
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
277 endfunc "}}}
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
278
6032
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
279 " Count the number of start and end tags in "text".
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
280 func! s:CountITags(text)
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
281 "{{{
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
282 " Store the result in s:curind and s:nextrel.
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
283 let s:curind = 0 " relative indent steps for current line [unit &sw]:
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
284 let s:nextrel = 0 " relative indent steps for next line [unit &sw]:
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
285 let s:block = 0 " assume starting outside of a block
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
286 let s:countonly = 1 " don't change state
13437
02b3f719eacb Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
287 call substitute(a:text, '<\zs/\=' . s:tagname . '\>\|<!--\[\|\[endif\]-->\|<!--\|-->', '\=s:CheckTag(submatch(0))', 'g')
6032
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
288 let s:countonly = 0
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
289 endfunc "}}}
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
290
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
291 " Count the number of start and end tags in text.
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
292 func! s:CountTagsAndState(text)
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
293 "{{{
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
294 " Store the result in s:curind and s:nextrel. Update b:hi_newstate.block.
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
295 let s:curind = 0 " relative indent steps for current line [unit &sw]:
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
296 let s:nextrel = 0 " relative indent steps for next line [unit &sw]:
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
297
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
298 let s:block = b:hi_newstate.block
13437
02b3f719eacb Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
299 let tmp = substitute(a:text, '<\zs/\=' . s:tagname . '\>\|<!--\[\|\[endif\]-->\|<!--\|-->', '\=s:CheckTag(submatch(0))', 'g')
6032
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
300 if s:block == 3
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
301 let b:hi_newstate.scripttype = s:GetScriptType(matchstr(tmp, '\C.*<SCRIPT\>\zs[^>]*'))
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
302 endif
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
303 let b:hi_newstate.block = s:block
4869
a5352e73dc00 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents: 1121
diff changeset
304 endfunc "}}}
6032
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
305
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
306 " Used by s:CountITags() and s:CountTagsAndState().
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
307 func! s:CheckTag(itag)
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
308 "{{{
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
309 " Returns an empty string or "SCRIPT".
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
310 " a:itag can be "tag" or "/tag" or "<!--" or "-->"
6663
056809de0b29 updated for version 7.4.656
Bram Moolenaar <bram@vim.org>
parents: 6484
diff changeset
311 if (s:CheckCustomTag(a:itag))
056809de0b29 updated for version 7.4.656
Bram Moolenaar <bram@vim.org>
parents: 6484
diff changeset
312 return ""
056809de0b29 updated for version 7.4.656
Bram Moolenaar <bram@vim.org>
parents: 6484
diff changeset
313 endif
6032
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
314 let ind = s:get_tag(a:itag)
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
315 if ind == -1
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
316 " closing tag
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
317 if s:block != 0
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
318 " ignore itag within a block
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
319 return ""
4869
a5352e73dc00 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents: 1121
diff changeset
320 endif
6032
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
321 if s:nextrel == 0
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
322 let s:curind -= 1
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
323 else
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
324 let s:nextrel -= 1
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
325 endif
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
326 elseif ind == 1
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
327 " opening tag
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
328 if s:block != 0
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
329 return ""
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
330 endif
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
331 let s:nextrel += 1
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
332 elseif ind != 0
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
333 " block-tag (opening or closing)
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
334 return s:CheckBlockTag(a:itag, ind)
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
335 " else ind==0 (other tag found): keep indent
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
336 endif
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
337 return ""
4869
a5352e73dc00 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents: 1121
diff changeset
338 endfunc "}}}
6032
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
339
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
340 " Used by s:CheckTag(). Returns an empty string or "SCRIPT".
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
341 func! s:CheckBlockTag(blocktag, ind)
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
342 "{{{
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
343 if a:ind > 0
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
344 " a block starts here
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
345 if s:block != 0
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
346 " already in a block (nesting) - ignore
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
347 " especially ignore comments after other blocktags
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
348 return ""
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
349 endif
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
350 let s:block = a:ind " block type
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
351 if s:countonly
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
352 return ""
4869
a5352e73dc00 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents: 1121
diff changeset
353 endif
6032
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
354 let b:hi_newstate.blocklnr = v:lnum
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
355 " save allover indent for the endtag
11518
63b0b7b79b25 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 10734
diff changeset
356 let b:hi_newstate.blocktagind = b:hi_indent.baseindent + (s:nextrel + s:curind) * shiftwidth()
6032
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
357 if a:ind == 3
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
358 return "SCRIPT" " all except this must be lowercase
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
359 " line is to be checked again for the type attribute
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
360 endif
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
361 else
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
362 let s:block = 0
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
363 " we get here if starting and closing a block-tag on the same line
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
364 endif
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
365 return ""
4869
a5352e73dc00 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents: 1121
diff changeset
366 endfunc "}}}
6032
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
367
6663
056809de0b29 updated for version 7.4.656
Bram Moolenaar <bram@vim.org>
parents: 6484
diff changeset
368 " Used by s:CheckTag().
056809de0b29 updated for version 7.4.656
Bram Moolenaar <bram@vim.org>
parents: 6484
diff changeset
369 func! s:CheckCustomTag(ctag)
056809de0b29 updated for version 7.4.656
Bram Moolenaar <bram@vim.org>
parents: 6484
diff changeset
370 "{{{
056809de0b29 updated for version 7.4.656
Bram Moolenaar <bram@vim.org>
parents: 6484
diff changeset
371 " Returns 1 if ctag is the tag for a custom element, 0 otherwise.
056809de0b29 updated for version 7.4.656
Bram Moolenaar <bram@vim.org>
parents: 6484
diff changeset
372 " a:ctag can be "tag" or "/tag" or "<!--" or "-->"
056809de0b29 updated for version 7.4.656
Bram Moolenaar <bram@vim.org>
parents: 6484
diff changeset
373 let pattern = '\%\(\w\+-\)\+\w\+'
056809de0b29 updated for version 7.4.656
Bram Moolenaar <bram@vim.org>
parents: 6484
diff changeset
374 if match(a:ctag, pattern) == -1
056809de0b29 updated for version 7.4.656
Bram Moolenaar <bram@vim.org>
parents: 6484
diff changeset
375 return 0
056809de0b29 updated for version 7.4.656
Bram Moolenaar <bram@vim.org>
parents: 6484
diff changeset
376 endif
056809de0b29 updated for version 7.4.656
Bram Moolenaar <bram@vim.org>
parents: 6484
diff changeset
377 if matchstr(a:ctag, '\/\ze.\+') == "/"
056809de0b29 updated for version 7.4.656
Bram Moolenaar <bram@vim.org>
parents: 6484
diff changeset
378 " closing tag
056809de0b29 updated for version 7.4.656
Bram Moolenaar <bram@vim.org>
parents: 6484
diff changeset
379 if s:block != 0
056809de0b29 updated for version 7.4.656
Bram Moolenaar <bram@vim.org>
parents: 6484
diff changeset
380 " ignore ctag within a block
056809de0b29 updated for version 7.4.656
Bram Moolenaar <bram@vim.org>
parents: 6484
diff changeset
381 return 1
056809de0b29 updated for version 7.4.656
Bram Moolenaar <bram@vim.org>
parents: 6484
diff changeset
382 endif
056809de0b29 updated for version 7.4.656
Bram Moolenaar <bram@vim.org>
parents: 6484
diff changeset
383 if s:nextrel == 0
056809de0b29 updated for version 7.4.656
Bram Moolenaar <bram@vim.org>
parents: 6484
diff changeset
384 let s:curind -= 1
056809de0b29 updated for version 7.4.656
Bram Moolenaar <bram@vim.org>
parents: 6484
diff changeset
385 else
056809de0b29 updated for version 7.4.656
Bram Moolenaar <bram@vim.org>
parents: 6484
diff changeset
386 let s:nextrel -= 1
056809de0b29 updated for version 7.4.656
Bram Moolenaar <bram@vim.org>
parents: 6484
diff changeset
387 endif
056809de0b29 updated for version 7.4.656
Bram Moolenaar <bram@vim.org>
parents: 6484
diff changeset
388 else
056809de0b29 updated for version 7.4.656
Bram Moolenaar <bram@vim.org>
parents: 6484
diff changeset
389 " opening tag
056809de0b29 updated for version 7.4.656
Bram Moolenaar <bram@vim.org>
parents: 6484
diff changeset
390 if s:block != 0
056809de0b29 updated for version 7.4.656
Bram Moolenaar <bram@vim.org>
parents: 6484
diff changeset
391 return 1
056809de0b29 updated for version 7.4.656
Bram Moolenaar <bram@vim.org>
parents: 6484
diff changeset
392 endif
056809de0b29 updated for version 7.4.656
Bram Moolenaar <bram@vim.org>
parents: 6484
diff changeset
393 let s:nextrel += 1
056809de0b29 updated for version 7.4.656
Bram Moolenaar <bram@vim.org>
parents: 6484
diff changeset
394 endif
056809de0b29 updated for version 7.4.656
Bram Moolenaar <bram@vim.org>
parents: 6484
diff changeset
395 return 1
056809de0b29 updated for version 7.4.656
Bram Moolenaar <bram@vim.org>
parents: 6484
diff changeset
396 endfunc "}}}
056809de0b29 updated for version 7.4.656
Bram Moolenaar <bram@vim.org>
parents: 6484
diff changeset
397
6032
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
398 " Return the <script> type: either "javascript" or ""
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
399 func! s:GetScriptType(str)
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
400 "{{{
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
401 if a:str == "" || a:str =~ "java"
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
402 return "javascript"
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
403 else
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
404 return ""
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
405 endif
4869
a5352e73dc00 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents: 1121
diff changeset
406 endfunc "}}}
a5352e73dc00 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents: 1121
diff changeset
407
6032
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
408 " Look back in the file, starting at a:lnum - 1, to compute a state for the
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
409 " start of line a:lnum. Return the new state.
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
410 func! s:FreshState(lnum)
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
411 "{{{
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
412 " A state is to know ALL relevant details about the
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
413 " lines 1..a:lnum-1, initial calculating (here!) can be slow, but updating is
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
414 " fast (incremental).
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
415 " TODO: this should be split up in detecting the block type and computing the
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
416 " indent for the block type, so that when we do not know the indent we do
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
417 " not need to clear the whole state and re-detect the block type again.
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
418 " State:
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
419 " lnum last indented line == prevnonblank(a:lnum - 1)
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
420 " block = 0 a:lnum located within special tag: 0:none, 2:<pre>,
7147
c590de398af9 commit https://github.com/vim/vim/commit/ca63501fbcd1cf9c8aa9ff12c093c95b62a89ed7
Christian Brabandt <cb@256bit.org>
parents: 6840
diff changeset
421 " 3:<script>, 4:<style>, 5:<!--, 6:<!--[
6032
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
422 " baseindent use this indent for line a:lnum as a start - kind of
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
423 " autoindent (if block==0)
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
424 " scripttype = '' type attribute of a script tag (if block==3)
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
425 " blocktagind indent for current opening (get) and closing (set)
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
426 " blocktag (if block!=0)
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
427 " blocklnr lnum of starting blocktag (if block!=0)
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
428 " inattr line {lnum} starts with attributes of a tag
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
429 let state = {}
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
430 let state.lnum = prevnonblank(a:lnum - 1)
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
431 let state.scripttype = ""
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
432 let state.blocktagind = -1
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
433 let state.block = 0
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
434 let state.baseindent = 0
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
435 let state.blocklnr = 0
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
436 let state.inattr = 0
4869
a5352e73dc00 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents: 1121
diff changeset
437
6032
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
438 if state.lnum == 0
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
439 return state
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
440 endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
441
6032
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
442 " Heuristic:
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
443 " remember startline state.lnum
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
444 " look back for <pre, </pre, <script, </script, <style, </style tags
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
445 " remember stopline
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
446 " if opening tag found,
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
447 " assume a:lnum within block
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
448 " else
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
449 " look back in result range (stopline, startline) for comment
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
450 " \ delimiters (<!--, -->)
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
451 " if comment opener found,
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
452 " assume a:lnum within comment
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
453 " else
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
454 " assume usual html for a:lnum
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
455 " if a:lnum-1 has a closing comment
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
456 " look back to get indent of comment opener
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
457 " FI
1121
e63691e7c504 updated for version 7.1a
vimboss
parents: 867
diff changeset
458
6032
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
459 " look back for a blocktag
7147
c590de398af9 commit https://github.com/vim/vim/commit/ca63501fbcd1cf9c8aa9ff12c093c95b62a89ed7
Christian Brabandt <cb@256bit.org>
parents: 6840
diff changeset
460 let stopline2 = v:lnum + 1
c590de398af9 commit https://github.com/vim/vim/commit/ca63501fbcd1cf9c8aa9ff12c093c95b62a89ed7
Christian Brabandt <cb@256bit.org>
parents: 6840
diff changeset
461 if has_key(b:hi_indent, 'block') && b:hi_indent.block > 5
c590de398af9 commit https://github.com/vim/vim/commit/ca63501fbcd1cf9c8aa9ff12c093c95b62a89ed7
Christian Brabandt <cb@256bit.org>
parents: 6840
diff changeset
462 let [stopline2, stopcol2] = searchpos('<!--', 'bnW')
c590de398af9 commit https://github.com/vim/vim/commit/ca63501fbcd1cf9c8aa9ff12c093c95b62a89ed7
Christian Brabandt <cb@256bit.org>
parents: 6840
diff changeset
463 endif
c590de398af9 commit https://github.com/vim/vim/commit/ca63501fbcd1cf9c8aa9ff12c093c95b62a89ed7
Christian Brabandt <cb@256bit.org>
parents: 6840
diff changeset
464 let [stopline, stopcol] = searchpos('\c<\zs\/\=\%(pre\>\|script\>\|style\>\)', "bnW")
c590de398af9 commit https://github.com/vim/vim/commit/ca63501fbcd1cf9c8aa9ff12c093c95b62a89ed7
Christian Brabandt <cb@256bit.org>
parents: 6840
diff changeset
465 if stopline > 0 && stopline < stopline2
c590de398af9 commit https://github.com/vim/vim/commit/ca63501fbcd1cf9c8aa9ff12c093c95b62a89ed7
Christian Brabandt <cb@256bit.org>
parents: 6840
diff changeset
466 " ugly ... why isn't there searchstr()
4869
a5352e73dc00 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents: 1121
diff changeset
467 let tagline = tolower(getline(stopline))
6032
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
468 let blocktag = matchstr(tagline, '\/\=\%(pre\>\|script\>\|style\>\)', stopcol - 1)
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
469 if blocktag[0] != "/"
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
470 " opening tag found, assume a:lnum within block
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
471 let state.block = s:indent_tags[blocktag]
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
472 if state.block == 3
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
473 let state.scripttype = s:GetScriptType(matchstr(tagline, '\>[^>]*', stopcol))
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
474 endif
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
475 let state.blocklnr = stopline
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
476 " check preceding tags in the line:
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
477 call s:CountITags(tagline[: stopcol-2])
11518
63b0b7b79b25 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 10734
diff changeset
478 let state.blocktagind = indent(stopline) + (s:curind + s:nextrel) * shiftwidth()
6032
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
479 return state
4869
a5352e73dc00 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents: 1121
diff changeset
480 elseif stopline == state.lnum
6032
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
481 " handle special case: previous line (= state.lnum) contains a
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
482 " closing blocktag which is preceded by line-noise;
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
483 " blocktag == "/..."
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
484 let swendtag = match(tagline, '^\s*</') >= 0
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
485 if !swendtag
7147
c590de398af9 commit https://github.com/vim/vim/commit/ca63501fbcd1cf9c8aa9ff12c093c95b62a89ed7
Christian Brabandt <cb@256bit.org>
parents: 6840
diff changeset
486 let [bline, bcol] = searchpos('<'.blocktag[1:].'\>', "bnW")
6032
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
487 call s:CountITags(tolower(getline(bline)[: bcol-2]))
11518
63b0b7b79b25 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 10734
diff changeset
488 let state.baseindent = indent(bline) + (s:curind + s:nextrel) * shiftwidth()
6032
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
489 return state
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
490 endif
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
491 endif
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
492 endif
7147
c590de398af9 commit https://github.com/vim/vim/commit/ca63501fbcd1cf9c8aa9ff12c093c95b62a89ed7
Christian Brabandt <cb@256bit.org>
parents: 6840
diff changeset
493 if stopline > stopline2
c590de398af9 commit https://github.com/vim/vim/commit/ca63501fbcd1cf9c8aa9ff12c093c95b62a89ed7
Christian Brabandt <cb@256bit.org>
parents: 6840
diff changeset
494 let stopline = stopline2
c590de398af9 commit https://github.com/vim/vim/commit/ca63501fbcd1cf9c8aa9ff12c093c95b62a89ed7
Christian Brabandt <cb@256bit.org>
parents: 6840
diff changeset
495 let stopcol = stopcol2
c590de398af9 commit https://github.com/vim/vim/commit/ca63501fbcd1cf9c8aa9ff12c093c95b62a89ed7
Christian Brabandt <cb@256bit.org>
parents: 6840
diff changeset
496 endif
6032
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
497
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
498 " else look back for comment
7147
c590de398af9 commit https://github.com/vim/vim/commit/ca63501fbcd1cf9c8aa9ff12c093c95b62a89ed7
Christian Brabandt <cb@256bit.org>
parents: 6840
diff changeset
499 let [comlnum, comcol, found] = searchpos('\(<!--\[\)\|\(<!--\)\|-->', 'bpnW', stopline)
c590de398af9 commit https://github.com/vim/vim/commit/ca63501fbcd1cf9c8aa9ff12c093c95b62a89ed7
Christian Brabandt <cb@256bit.org>
parents: 6840
diff changeset
500 if found == 2 || found == 3
6032
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
501 " comment opener found, assume a:lnum within comment
7147
c590de398af9 commit https://github.com/vim/vim/commit/ca63501fbcd1cf9c8aa9ff12c093c95b62a89ed7
Christian Brabandt <cb@256bit.org>
parents: 6840
diff changeset
502 let state.block = (found == 3 ? 5 : 6)
6032
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
503 let state.blocklnr = comlnum
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
504 " check preceding tags in the line:
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
505 call s:CountITags(tolower(getline(comlnum)[: comcol-2]))
7147
c590de398af9 commit https://github.com/vim/vim/commit/ca63501fbcd1cf9c8aa9ff12c093c95b62a89ed7
Christian Brabandt <cb@256bit.org>
parents: 6840
diff changeset
506 if found == 2
c590de398af9 commit https://github.com/vim/vim/commit/ca63501fbcd1cf9c8aa9ff12c093c95b62a89ed7
Christian Brabandt <cb@256bit.org>
parents: 6840
diff changeset
507 let state.baseindent = b:hi_indent.baseindent
c590de398af9 commit https://github.com/vim/vim/commit/ca63501fbcd1cf9c8aa9ff12c093c95b62a89ed7
Christian Brabandt <cb@256bit.org>
parents: 6840
diff changeset
508 endif
11518
63b0b7b79b25 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 10734
diff changeset
509 let state.blocktagind = indent(comlnum) + (s:curind + s:nextrel) * shiftwidth()
6032
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
510 return state
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
511 endif
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
512
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
513 " else within usual HTML
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
514 let text = tolower(getline(state.lnum))
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
515
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
516 " Check a:lnum-1 for closing comment (we need indent from the opening line).
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
517 " Not when other tags follow (might be --> inside a string).
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
518 let comcol = stridx(text, '-->')
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
519 if comcol >= 0 && match(text, '[<>]', comcol) <= 0
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
520 call cursor(state.lnum, comcol + 1)
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
521 let [comlnum, comcol] = searchpos('<!--', 'bW')
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
522 if comlnum == state.lnum
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
523 let text = text[: comcol-2]
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
524 else
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
525 let text = tolower(getline(comlnum)[: comcol-2])
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
526 endif
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
527 call s:CountITags(text)
11518
63b0b7b79b25 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 10734
diff changeset
528 let state.baseindent = indent(comlnum) + (s:curind + s:nextrel) * shiftwidth()
6032
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
529 " TODO check tags that follow "-->"
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
530 return state
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
531 endif
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
532
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
533 " Check if the previous line starts with end tag.
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
534 let swendtag = match(text, '^\s*</') >= 0
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
535
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
536 " If previous line ended in a closing tag, line up with the opening tag.
13437
02b3f719eacb Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
537 if !swendtag && text =~ '</' . s:tagname . '\s*>\s*$'
6032
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
538 call cursor(state.lnum, 99999)
6159
babc6a1d4c27 Runtime file updates.
Bram Moolenaar <bram@vim.org>
parents: 6032
diff changeset
539 normal! F<
6032
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
540 let start_lnum = HtmlIndent_FindStartTag()
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
541 if start_lnum > 0
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
542 let state.baseindent = indent(start_lnum)
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
543 if col('.') > 2
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
544 " check for tags before the matching opening tag.
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
545 let text = getline(start_lnum)
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
546 let swendtag = match(text, '^\s*</') >= 0
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
547 call s:CountITags(text[: col('.') - 2])
11518
63b0b7b79b25 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 10734
diff changeset
548 let state.baseindent += s:nextrel * shiftwidth()
6032
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
549 if !swendtag
11518
63b0b7b79b25 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 10734
diff changeset
550 let state.baseindent += s:curind * shiftwidth()
6032
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
551 endif
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
552 endif
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
553 return state
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
554 endif
6032
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
555 endif
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
556
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
557 " Else: no comments. Skip backwards to find the tag we're inside.
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
558 let [state.lnum, found] = HtmlIndent_FindTagStart(state.lnum)
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
559 " Check if that line starts with end tag.
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
560 let text = getline(state.lnum)
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
561 let swendtag = match(text, '^\s*</') >= 0
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
562 call s:CountITags(tolower(text))
11518
63b0b7b79b25 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 10734
diff changeset
563 let state.baseindent = indent(state.lnum) + s:nextrel * shiftwidth()
6032
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
564 if !swendtag
11518
63b0b7b79b25 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 10734
diff changeset
565 let state.baseindent += s:curind * shiftwidth()
6032
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
566 endif
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
567 return state
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
568 endfunc "}}}
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
569
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
570 " Indent inside a <pre> block: Keep indent as-is.
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
571 func! s:Alien2()
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
572 "{{{
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
573 return -1
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
574 endfunc "}}}
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
575
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
576 " Return the indent inside a <script> block for javascript.
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
577 func! s:Alien3()
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
578 "{{{
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
579 let lnum = prevnonblank(v:lnum - 1)
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
580 while lnum > 1 && getline(lnum) =~ '^\s*/[/*]'
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
581 " Skip over comments to avoid that cindent() aligns with the <script> tag
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
582 let lnum = prevnonblank(lnum - 1)
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
583 endwhile
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
584 if lnum == b:hi_indent.blocklnr
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
585 " indent for the first line after <script>
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
586 return eval(b:hi_js1indent)
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
587 endif
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
588 if b:hi_indent.scripttype == "javascript"
10734
523cd59d6db0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 10228
diff changeset
589 return GetJavascriptIndent()
6032
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
590 else
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
591 return -1
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
592 endif
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
593 endfunc "}}}
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
594
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
595 " Return the indent inside a <style> block.
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
596 func! s:Alien4()
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
597 "{{{
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
598 if prevnonblank(v:lnum-1) == b:hi_indent.blocklnr
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
599 " indent for first content line
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
600 return eval(b:hi_css1indent)
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
601 endif
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
602 return s:CSSIndent()
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
603 endfunc "}}}
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
604
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
605 " Indending inside a <style> block. Returns the indent.
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
606 func! s:CSSIndent()
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
607 "{{{
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
608 " This handles standard CSS and also Closure stylesheets where special lines
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
609 " start with @.
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
610 " When the line starts with '*' or the previous line starts with "/*"
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
611 " and does not end in "*/", use C indenting to format the comment.
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
612 " Adopted $VIMRUNTIME/indent/css.vim
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
613 let curtext = getline(v:lnum)
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
614 if curtext =~ '^\s*[*]'
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
615 \ || (v:lnum > 1 && getline(v:lnum - 1) =~ '\s*/\*'
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
616 \ && getline(v:lnum - 1) !~ '\*/\s*$')
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
617 return cindent(v:lnum)
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
618 endif
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
619
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
620 let min_lnum = b:hi_indent.blocklnr
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
621 let prev_lnum = s:CssPrevNonComment(v:lnum - 1, min_lnum)
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
622 let [prev_lnum, found] = HtmlIndent_FindTagStart(prev_lnum)
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
623 if prev_lnum <= min_lnum
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
624 " Just below the <style> tag, indent for first content line after comments.
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
625 return eval(b:hi_css1indent)
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
626 endif
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
627
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
628 " If the current line starts with "}" align with it's match.
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
629 if curtext =~ '^\s*}'
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
630 call cursor(v:lnum, 1)
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
631 try
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
632 normal! %
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
633 " Found the matching "{", align with it after skipping unfinished lines.
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
634 let align_lnum = s:CssFirstUnfinished(line('.'), min_lnum)
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
635 return indent(align_lnum)
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
636 catch
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
637 " can't find it, try something else, but it's most likely going to be
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
638 " wrong
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
639 endtry
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
640 endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
641
6032
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
642 " add indent after {
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
643 let brace_counts = HtmlIndent_CountBraces(prev_lnum)
11518
63b0b7b79b25 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 10734
diff changeset
644 let extra = brace_counts.c_open * shiftwidth()
6032
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
645
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
646 let prev_text = getline(prev_lnum)
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
647 let below_end_brace = prev_text =~ '}\s*$'
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
648
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
649 " Search back to align with the first line that's unfinished.
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
650 let align_lnum = s:CssFirstUnfinished(prev_lnum, min_lnum)
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
651
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
652 " Handle continuation lines if aligning with previous line and not after a
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
653 " "}".
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
654 if extra == 0 && align_lnum == prev_lnum && !below_end_brace
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
655 let prev_hasfield = prev_text =~ '^\s*[a-zA-Z0-9-]\+:'
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
656 let prev_special = prev_text =~ '^\s*\(/\*\|@\)'
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
657 if curtext =~ '^\s*\(/\*\|@\)'
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
658 " if the current line is not a comment or starts with @ (used by template
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
659 " systems) reduce indent if previous line is a continuation line
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
660 if !prev_hasfield && !prev_special
11518
63b0b7b79b25 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 10734
diff changeset
661 let extra = -shiftwidth()
6032
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
662 endif
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
663 else
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
664 let cur_hasfield = curtext =~ '^\s*[a-zA-Z0-9-]\+:'
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
665 let prev_unfinished = s:CssUnfinished(prev_text)
14637
0ecb909e3249 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 13563
diff changeset
666 if prev_unfinished
6032
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
667 " Continuation line has extra indent if the previous line was not a
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
668 " continuation line.
11518
63b0b7b79b25 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 10734
diff changeset
669 let extra = shiftwidth()
6032
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
670 " Align with @if
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
671 if prev_text =~ '^\s*@if '
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
672 let extra = 4
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
673 endif
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
674 elseif cur_hasfield && !prev_hasfield && !prev_special
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
675 " less indent below a continuation line
11518
63b0b7b79b25 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 10734
diff changeset
676 let extra = -shiftwidth()
6032
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
677 endif
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
678 endif
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
679 endif
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
680
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
681 if below_end_brace
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
682 " find matching {, if that line starts with @ it's not the start of a rule
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
683 " but something else from a template system
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
684 call cursor(prev_lnum, 1)
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
685 call search('}\s*$')
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
686 try
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
687 normal! %
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
688 " Found the matching "{", align with it.
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
689 let align_lnum = s:CssFirstUnfinished(line('.'), min_lnum)
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
690 let special = getline(align_lnum) =~ '^\s*@'
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
691 catch
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
692 let special = 0
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
693 endtry
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
694 if special
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
695 " do not reduce indent below @{ ... }
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
696 if extra < 0
11518
63b0b7b79b25 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 10734
diff changeset
697 let extra += shiftwidth()
6032
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
698 endif
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
699 else
11518
63b0b7b79b25 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 10734
diff changeset
700 let extra -= (brace_counts.c_close - (prev_text =~ '^\s*}')) * shiftwidth()
6032
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
701 endif
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
702 endif
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
703
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
704 " if no extra indent yet...
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
705 if extra == 0
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
706 if brace_counts.p_open > brace_counts.p_close
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
707 " previous line has more ( than ): add a shiftwidth
11518
63b0b7b79b25 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 10734
diff changeset
708 let extra = shiftwidth()
6032
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
709 elseif brace_counts.p_open < brace_counts.p_close
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
710 " previous line has more ) than (: subtract a shiftwidth
11518
63b0b7b79b25 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 10734
diff changeset
711 let extra = -shiftwidth()
6032
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
712 endif
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
713 endif
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
714
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
715 return indent(align_lnum) + extra
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
716 endfunc "}}}
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
717
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
718 " Inside <style>: Whether a line is unfinished.
14637
0ecb909e3249 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 13563
diff changeset
719 " tag:
0ecb909e3249 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 13563
diff changeset
720 " tag: blah
0ecb909e3249 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 13563
diff changeset
721 " tag: blah &&
0ecb909e3249 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 13563
diff changeset
722 " tag: blah ||
6032
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
723 func! s:CssUnfinished(text)
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
724 "{{{
14637
0ecb909e3249 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 13563
diff changeset
725 return a:text =~ '\(||\|&&\|:\|\k\)\s*$'
6032
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
726 endfunc "}}}
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
727
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
728 " Search back for the first unfinished line above "lnum".
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
729 func! s:CssFirstUnfinished(lnum, min_lnum)
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
730 "{{{
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
731 let align_lnum = a:lnum
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
732 while align_lnum > a:min_lnum && s:CssUnfinished(getline(align_lnum - 1))
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
733 let align_lnum -= 1
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
734 endwhile
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
735 return align_lnum
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
736 endfunc "}}}
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
737
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
738 " Find the non-empty line at or before "lnum" that is not a comment.
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
739 func! s:CssPrevNonComment(lnum, stopline)
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
740 "{{{
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
741 " caller starts from a line a:lnum + 1 that is not a comment
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
742 let lnum = prevnonblank(a:lnum)
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
743 while 1
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
744 let ccol = match(getline(lnum), '\*/')
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
745 if ccol < 0
10228
8a1481e59d64 commit https://github.com/vim/vim/commit/3e496b0ea31996b665824f45664dee1fdd73c4d0
Christian Brabandt <cb@256bit.org>
parents: 8869
diff changeset
746 " No comment end thus it's something else.
6032
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
747 return lnum
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
748 endif
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
749 call cursor(lnum, ccol + 1)
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
750 " Search back for the /* that starts the comment
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
751 let lnum = search('/\*', 'bW', a:stopline)
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
752 if indent(".") == virtcol(".") - 1
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
753 " The found /* is at the start of the line. Now go back to the line
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
754 " above it and again check if it is a comment.
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
755 let lnum = prevnonblank(lnum - 1)
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
756 else
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
757 " /* is after something else, thus it's not a comment line.
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
758 return lnum
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
759 endif
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
760 endwhile
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
761 endfunc "}}}
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
762
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
763 " Check the number of {} and () in line "lnum". Return a dict with the counts.
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
764 func! HtmlIndent_CountBraces(lnum)
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
765 "{{{
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
766 let brs = substitute(getline(a:lnum), '[''"].\{-}[''"]\|/\*.\{-}\*/\|/\*.*$\|[^{}()]', '', 'g')
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
767 let c_open = 0
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
768 let c_close = 0
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
769 let p_open = 0
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
770 let p_close = 0
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
771 for brace in split(brs, '\zs')
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
772 if brace == "{"
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
773 let c_open += 1
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
774 elseif brace == "}"
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
775 if c_open > 0
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
776 let c_open -= 1
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
777 else
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
778 let c_close += 1
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
779 endif
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
780 elseif brace == '('
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
781 let p_open += 1
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
782 elseif brace == ')'
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
783 if p_open > 0
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
784 let p_open -= 1
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
785 else
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
786 let p_close += 1
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
787 endif
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
788 endif
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
789 endfor
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
790 return {'c_open': c_open,
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
791 \ 'c_close': c_close,
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
792 \ 'p_open': p_open,
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
793 \ 'p_close': p_close}
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
794 endfunc "}}}
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
795
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
796 " Return the indent for a comment: <!-- -->
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
797 func! s:Alien5()
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
798 "{{{
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
799 let curtext = getline(v:lnum)
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
800 if curtext =~ '^\s*\zs-->'
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
801 " current line starts with end of comment, line up with comment start.
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
802 call cursor(v:lnum, 0)
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
803 let lnum = search('<!--', 'b')
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
804 if lnum > 0
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
805 " TODO: what if <!-- is not at the start of the line?
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
806 return indent(lnum)
4869
a5352e73dc00 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents: 1121
diff changeset
807 endif
a5352e73dc00 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents: 1121
diff changeset
808
6032
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
809 " Strange, can't find it.
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
810 return -1
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
811 endif
6009
7b83c190d370 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4911
diff changeset
812
6032
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
813 let prevlnum = prevnonblank(v:lnum - 1)
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
814 let prevtext = getline(prevlnum)
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
815 let idx = match(prevtext, '^\s*\zs<!--')
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
816 if idx >= 0
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
817 " just below comment start, add a shiftwidth
11518
63b0b7b79b25 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 10734
diff changeset
818 return idx + shiftwidth()
6032
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
819 endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
820
6032
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
821 " Some files add 4 spaces just below a TODO line. It's difficult to detect
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
822 " the end of the TODO, so let's not do that.
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
823
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
824 " Align with the previous non-blank line.
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
825 return indent(prevlnum)
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
826 endfunc "}}}
6009
7b83c190d370 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4911
diff changeset
827
7147
c590de398af9 commit https://github.com/vim/vim/commit/ca63501fbcd1cf9c8aa9ff12c093c95b62a89ed7
Christian Brabandt <cb@256bit.org>
parents: 6840
diff changeset
828 " Return the indent for conditional comment: <!--[ ![endif]-->
c590de398af9 commit https://github.com/vim/vim/commit/ca63501fbcd1cf9c8aa9ff12c093c95b62a89ed7
Christian Brabandt <cb@256bit.org>
parents: 6840
diff changeset
829 func! s:Alien6()
c590de398af9 commit https://github.com/vim/vim/commit/ca63501fbcd1cf9c8aa9ff12c093c95b62a89ed7
Christian Brabandt <cb@256bit.org>
parents: 6840
diff changeset
830 "{{{
c590de398af9 commit https://github.com/vim/vim/commit/ca63501fbcd1cf9c8aa9ff12c093c95b62a89ed7
Christian Brabandt <cb@256bit.org>
parents: 6840
diff changeset
831 let curtext = getline(v:lnum)
c590de398af9 commit https://github.com/vim/vim/commit/ca63501fbcd1cf9c8aa9ff12c093c95b62a89ed7
Christian Brabandt <cb@256bit.org>
parents: 6840
diff changeset
832 if curtext =~ '\s*\zs<!\[endif\]-->'
c590de398af9 commit https://github.com/vim/vim/commit/ca63501fbcd1cf9c8aa9ff12c093c95b62a89ed7
Christian Brabandt <cb@256bit.org>
parents: 6840
diff changeset
833 " current line starts with end of comment, line up with comment start.
c590de398af9 commit https://github.com/vim/vim/commit/ca63501fbcd1cf9c8aa9ff12c093c95b62a89ed7
Christian Brabandt <cb@256bit.org>
parents: 6840
diff changeset
834 let lnum = search('<!--', 'bn')
c590de398af9 commit https://github.com/vim/vim/commit/ca63501fbcd1cf9c8aa9ff12c093c95b62a89ed7
Christian Brabandt <cb@256bit.org>
parents: 6840
diff changeset
835 if lnum > 0
c590de398af9 commit https://github.com/vim/vim/commit/ca63501fbcd1cf9c8aa9ff12c093c95b62a89ed7
Christian Brabandt <cb@256bit.org>
parents: 6840
diff changeset
836 return indent(lnum)
c590de398af9 commit https://github.com/vim/vim/commit/ca63501fbcd1cf9c8aa9ff12c093c95b62a89ed7
Christian Brabandt <cb@256bit.org>
parents: 6840
diff changeset
837 endif
c590de398af9 commit https://github.com/vim/vim/commit/ca63501fbcd1cf9c8aa9ff12c093c95b62a89ed7
Christian Brabandt <cb@256bit.org>
parents: 6840
diff changeset
838 endif
11518
63b0b7b79b25 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 10734
diff changeset
839 return b:hi_indent.baseindent + shiftwidth()
7147
c590de398af9 commit https://github.com/vim/vim/commit/ca63501fbcd1cf9c8aa9ff12c093c95b62a89ed7
Christian Brabandt <cb@256bit.org>
parents: 6840
diff changeset
840 endfunc "}}}
c590de398af9 commit https://github.com/vim/vim/commit/ca63501fbcd1cf9c8aa9ff12c093c95b62a89ed7
Christian Brabandt <cb@256bit.org>
parents: 6840
diff changeset
841
6032
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
842 " When the "lnum" line ends in ">" find the line containing the matching "<".
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
843 func! HtmlIndent_FindTagStart(lnum)
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
844 "{{{
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
845 " Avoids using the indent of a continuation line.
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
846 " Moves the cursor.
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
847 " Return two values:
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
848 " - the matching line number or "lnum".
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
849 " - a flag indicating whether we found the end of a tag.
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
850 " This method is global so that HTML-like indenters can use it.
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
851 " To avoid matching " > " or " < " inside a string require that the opening
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
852 " "<" is followed by a word character and the closing ">" comes after a
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
853 " non-white character.
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
854 let idx = match(getline(a:lnum), '\S>\s*$')
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
855 if idx > 0
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
856 call cursor(a:lnum, idx)
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
857 let lnum = searchpair('<\w', '' , '\S>', 'bW', '', max([a:lnum - b:html_indent_line_limit, 0]))
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
858 if lnum > 0
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
859 return [lnum, 1]
6009
7b83c190d370 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4911
diff changeset
860 endif
6032
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
861 endif
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
862 return [a:lnum, 0]
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
863 endfunc "}}}
6009
7b83c190d370 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4911
diff changeset
864
6032
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
865 " Find the unclosed start tag from the current cursor position.
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
866 func! HtmlIndent_FindStartTag()
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
867 "{{{
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
868 " The cursor must be on or before a closing tag.
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
869 " If found, positions the cursor at the match and returns the line number.
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
870 " Otherwise returns 0.
13437
02b3f719eacb Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
871 let tagname = matchstr(getline('.')[col('.') - 1:], '</\zs' . s:tagname . '\ze')
6032
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
872 let start_lnum = searchpair('<' . tagname . '\>', '', '</' . tagname . '\>', 'bW')
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
873 if start_lnum > 0
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
874 return start_lnum
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
875 endif
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
876 return 0
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
877 endfunc "}}}
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
878
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
879 " Moves the cursor from a "<" to the matching ">".
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
880 func! HtmlIndent_FindTagEnd()
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
881 "{{{
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
882 " Call this with the cursor on the "<" of a start tag.
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
883 " This will move the cursor to the ">" of the matching end tag or, when it's
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
884 " a self-closing tag, to the matching ">".
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
885 " Limited to look up to b:html_indent_line_limit lines away.
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
886 let text = getline('.')
13437
02b3f719eacb Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
887 let tagname = matchstr(text, s:tagname . '\|!--', col('.'))
6032
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
888 if tagname == '!--'
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
889 call search('--\zs>')
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
890 elseif s:get_tag('/' . tagname) != 0
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
891 " tag with a closing tag, find matching "</tag>"
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
892 call searchpair('<' . tagname, '', '</' . tagname . '\zs>', 'W', '', line('.') + b:html_indent_line_limit)
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
893 else
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
894 " self-closing tag, find the ">"
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
895 call search('\S\zs>')
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
896 endif
4869
a5352e73dc00 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents: 1121
diff changeset
897 endfunc "}}}
a5352e73dc00 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents: 1121
diff changeset
898
6032
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
899 " Indenting inside a start tag. Return the correct indent or -1 if unknown.
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
900 func! s:InsideTag(foundHtmlString)
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
901 "{{{
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
902 if a:foundHtmlString
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
903 " Inside an attribute string.
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
904 " Align with the previous line or use an external function.
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
905 let lnum = v:lnum - 1
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
906 if lnum > 1
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
907 if exists('b:html_indent_tag_string_func')
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
908 return b:html_indent_tag_string_func(lnum)
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
909 endif
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
910 return indent(lnum)
4869
a5352e73dc00 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents: 1121
diff changeset
911 endif
6032
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
912 endif
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
913
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
914 " Should be another attribute: " attr="val". Align with the previous
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
915 " attribute start.
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
916 let lnum = v:lnum
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
917 while lnum > 1
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
918 let lnum -= 1
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
919 let text = getline(lnum)
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
920 " Find a match with one of these, align with "attr":
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
921 " attr=
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
922 " <tag attr=
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
923 " text<tag attr=
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
924 " <tag>text</tag>text<tag attr=
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
925 " For long lines search for the first match, finding the last match
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
926 " gets very slow.
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
927 if len(text) < 300
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
928 let idx = match(text, '.*\s\zs[_a-zA-Z0-9-]\+="')
4869
a5352e73dc00 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents: 1121
diff changeset
929 else
6032
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
930 let idx = match(text, '\s\zs[_a-zA-Z0-9-]\+="')
4869
a5352e73dc00 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents: 1121
diff changeset
931 endif
13437
02b3f719eacb Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
932 if idx == -1
02b3f719eacb Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
933 " try <tag attr
02b3f719eacb Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
934 let idx = match(text, '<' . s:tagname . '\s\+\zs\w')
02b3f719eacb Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
935 endif
02b3f719eacb Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
936 if idx == -1
02b3f719eacb Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
937 " after just <tag indent one level more
02b3f719eacb Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
938 let idx = match(text, '<' . s:tagname . '$')
02b3f719eacb Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
939 if idx >= 0
02b3f719eacb Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
940 call cursor(lnum, idx)
02b3f719eacb Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
941 return virtcol('.') + shiftwidth()
02b3f719eacb Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
942 endif
02b3f719eacb Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
943 endif
6032
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
944 if idx > 0
13437
02b3f719eacb Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
945 " Found the attribute to align with.
02b3f719eacb Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
946 call cursor(lnum, idx)
02b3f719eacb Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
947 return virtcol('.')
6032
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
948 endif
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
949 endwhile
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
950 return -1
4869
a5352e73dc00 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents: 1121
diff changeset
951 endfunc "}}}
a5352e73dc00 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents: 1121
diff changeset
952
6032
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
953 " THE MAIN INDENT FUNCTION. Return the amount of indent for v:lnum.
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
954 func! HtmlIndent()
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
955 "{{{
6484
ce4ecfbebded Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 6159
diff changeset
956 if prevnonblank(v:lnum - 1) < 1
6032
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
957 " First non-blank line has no indent.
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
958 return 0
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
959 endif
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
960
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
961 let curtext = tolower(getline(v:lnum))
11518
63b0b7b79b25 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 10734
diff changeset
962 let indentunit = shiftwidth()
6032
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
963
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
964 let b:hi_newstate = {}
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
965 let b:hi_newstate.lnum = v:lnum
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
966
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
967 " When syntax HL is enabled, detect we are inside a tag. Indenting inside
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
968 " a tag works very differently. Do not do this when the line starts with
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
969 " "<", it gets the "htmlTag" ID but we are not inside a tag then.
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
970 if curtext !~ '^\s*<'
6159
babc6a1d4c27 Runtime file updates.
Bram Moolenaar <bram@vim.org>
parents: 6032
diff changeset
971 normal! ^
6032
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
972 let stack = synstack(v:lnum, col('.')) " assumes there are no tabs
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
973 let foundHtmlString = 0
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
974 for synid in reverse(stack)
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
975 let name = synIDattr(synid, "name")
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
976 if index(b:hi_insideStringNames, name) >= 0
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
977 let foundHtmlString = 1
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
978 elseif index(b:hi_insideTagNames, name) >= 0
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
979 " Yes, we are inside a tag.
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
980 let indent = s:InsideTag(foundHtmlString)
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
981 if indent >= 0
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
982 " Do not keep the state. TODO: could keep the block type.
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
983 let b:hi_indent.lnum = 0
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
984 return indent
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
985 endif
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
986 endif
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
987 endfor
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
988 endif
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
989
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
990 " does the line start with a closing tag?
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
991 let swendtag = match(curtext, '^\s*</') >= 0
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
992
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
993 if prevnonblank(v:lnum - 1) == b:hi_indent.lnum && b:hi_lasttick == b:changedtick - 1
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
994 " use state (continue from previous line)
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
995 else
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
996 " start over (know nothing)
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
997 let b:hi_indent = s:FreshState(v:lnum)
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
998 endif
4869
a5352e73dc00 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents: 1121
diff changeset
999
6032
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
1000 if b:hi_indent.block >= 2
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
1001 " within block
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
1002 let endtag = s:endtags[b:hi_indent.block]
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
1003 let blockend = stridx(curtext, endtag)
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
1004 if blockend >= 0
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
1005 " block ends here
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
1006 let b:hi_newstate.block = 0
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
1007 " calc indent for REST OF LINE (may start more blocks):
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
1008 call s:CountTagsAndState(strpart(curtext, blockend + strlen(endtag)))
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
1009 if swendtag && b:hi_indent.block != 5
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
1010 let indent = b:hi_indent.blocktagind + s:curind * indentunit
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
1011 let b:hi_newstate.baseindent = indent + s:nextrel * indentunit
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
1012 else
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
1013 let indent = s:Alien{b:hi_indent.block}()
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
1014 let b:hi_newstate.baseindent = b:hi_indent.blocktagind + s:nextrel * indentunit
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
1015 endif
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
1016 else
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
1017 " block continues
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
1018 " indent this line with alien method
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
1019 let indent = s:Alien{b:hi_indent.block}()
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
1020 endif
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
1021 else
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
1022 " not within a block - within usual html
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
1023 let b:hi_newstate.block = b:hi_indent.block
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
1024 if swendtag
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
1025 " The current line starts with an end tag, align with its start tag.
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
1026 call cursor(v:lnum, 1)
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
1027 let start_lnum = HtmlIndent_FindStartTag()
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
1028 if start_lnum > 0
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
1029 " check for the line starting with something inside a tag:
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
1030 " <sometag <- align here
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
1031 " attr=val><open> not here
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
1032 let text = getline(start_lnum)
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
1033 let angle = matchstr(text, '[<>]')
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
1034 if angle == '>'
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
1035 call cursor(start_lnum, 1)
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
1036 normal! f>%
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
1037 let start_lnum = line('.')
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
1038 let text = getline(start_lnum)
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
1039 endif
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
1040
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
1041 let indent = indent(start_lnum)
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
1042 if col('.') > 2
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
1043 let swendtag = match(text, '^\s*</') >= 0
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
1044 call s:CountITags(text[: col('.') - 2])
11518
63b0b7b79b25 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 10734
diff changeset
1045 let indent += s:nextrel * shiftwidth()
6032
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
1046 if !swendtag
11518
63b0b7b79b25 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 10734
diff changeset
1047 let indent += s:curind * shiftwidth()
6032
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
1048 endif
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
1049 endif
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
1050 else
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
1051 " not sure what to do
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
1052 let indent = b:hi_indent.baseindent
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
1053 endif
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
1054 let b:hi_newstate.baseindent = indent
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
1055 else
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
1056 call s:CountTagsAndState(curtext)
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
1057 let indent = b:hi_indent.baseindent
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
1058 let b:hi_newstate.baseindent = indent + (s:curind + s:nextrel) * indentunit
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
1059 endif
6009
7b83c190d370 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4911
diff changeset
1060 endif
6032
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
1061
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
1062 let b:hi_lasttick = b:changedtick
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
1063 call extend(b:hi_indent, b:hi_newstate, "force")
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
1064 return indent
6009
7b83c190d370 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4911
diff changeset
1065 endfunc "}}}
7b83c190d370 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4911
diff changeset
1066
6032
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
1067 " Check user settings when loading this script the first time.
4869
a5352e73dc00 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents: 1121
diff changeset
1068 call HtmlIndent_CheckUserSettings()
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1069
867
a5677b7ce858 updated for version 7.0g04
vimboss
parents: 856
diff changeset
1070 let &cpo = s:cpo_save
a5677b7ce858 updated for version 7.0g04
vimboss
parents: 856
diff changeset
1071 unlet s:cpo_save
a5677b7ce858 updated for version 7.0g04
vimboss
parents: 856
diff changeset
1072
6032
b8f703a4e55f Updated runtime files. Overhauled HTML indent script.
Bram Moolenaar <bram@vim.org>
parents: 6009
diff changeset
1073 " vim: fdm=marker ts=8 sw=2 tw=78