comparison runtime/indent/html.vim @ 867:a5677b7ce858

updated for version 7.0g04
author vimboss
date Fri, 05 May 2006 21:15:17 +0000
parents 8cd729851562
children e63691e7c504
comparison
equal deleted inserted replaced
866:5de6b337e1a2 867:a5677b7ce858
1 " Description: html indenter 1 " Description: html indenter
2 " Author: Johannes Zellner <johannes@zellner.org> 2 " Author: Johannes Zellner <johannes@zellner.org>
3 " Last Change: Tue, 27 Apr 2004 10:28:39 CEST 3 " Last Change: Tue, 27 Apr 2004 10:28:39 CEST
4 " Restoring 'cpo' and 'ic' added by Bram 2006 May 5
4 " Globals: g:html_indent_tags -- indenting tags 5 " Globals: g:html_indent_tags -- indenting tags
5 " g:html_indent_strict -- inhibit 'O O' elements 6 " g:html_indent_strict -- inhibit 'O O' elements
6 " g:html_indent_strict_table -- inhibit 'O -' elements 7 " g:html_indent_strict_table -- inhibit 'O -' elements
7 8
8 " Only load this indent file when no other was loaded. 9 " Only load this indent file when no other was loaded.
114 call <SID>HtmlIndentPush('thead') 115 call <SID>HtmlIndentPush('thead')
115 endif 116 endif
116 117
117 delfun <SID>HtmlIndentPush 118 delfun <SID>HtmlIndentPush
118 119
120 let s:cpo_save = &cpo
119 set cpo-=C 121 set cpo-=C
120 122
121 " [-- count indent-increasing tags of line a:lnum --] 123 " [-- count indent-increasing tags of line a:lnum --]
122 fun! <SID>HtmlIndentOpen(lnum, pattern) 124 fun! <SID>HtmlIndentOpen(lnum, pattern)
123 let s = substitute('x'.getline(a:lnum), 125 let s = substitute('x'.getline(a:lnum),
181 " [-- special handling for <pre>: no indenting --] 183 " [-- special handling for <pre>: no indenting --]
182 if getline(a:lnum) =~ '\c</pre>' 184 if getline(a:lnum) =~ '\c</pre>'
183 \ || 0 < searchpair('\c<pre>', '', '\c</pre>', 'nWb') 185 \ || 0 < searchpair('\c<pre>', '', '\c</pre>', 'nWb')
184 \ || 0 < searchpair('\c<pre>', '', '\c</pre>', 'nW') 186 \ || 0 < searchpair('\c<pre>', '', '\c</pre>', 'nW')
185 " we're in a line with </pre> or inside <pre> ... </pre> 187 " we're in a line with </pre> or inside <pre> ... </pre>
188 if restore_ic == 0
189 setlocal noic
190 endif
186 return -1 191 return -1
187 endif 192 endif
188 193
189 " [-- special handling for <javascript>: use cindent --] 194 " [-- special handling for <javascript>: use cindent --]
190 let js = '<script.*type\s*=\s*.*java' 195 let js = '<script.*type\s*=\s*.*java'
191 if 0 < searchpair(js, '', '</script>', 'nWb') 196 if 0 < searchpair(js, '', '</script>', 'nWb')
192 \ || 0 < searchpair(js, '', '</script>', 'nW') 197 \ || 0 < searchpair(js, '', '</script>', 'nW')
193 " we're inside javascript 198 " we're inside javascript
194 if getline(lnum) !~ js && getline(a:lnum) != '</script>' 199 if getline(lnum) !~ js && getline(a:lnum) != '</script>'
200 if restore_ic == 0
201 setlocal noic
202 endif
195 return cindent(a:lnum) 203 return cindent(a:lnum)
196 endif 204 endif
197 endif 205 endif
198 206
199 if getline(lnum) =~ '\c</pre>' 207 if getline(lnum) =~ '\c</pre>'
200 " line before the current line a:lnum contains 208 " line before the current line a:lnum contains
201 " a closing </pre>. --> search for line before 209 " a closing </pre>. --> search for line before
202 " starting <pre> to restore the indent. 210 " starting <pre> to restore the indent.
203 let preline = prevnonblank(search('\c<pre>', 'bW') - 1) 211 let preline = prevnonblank(search('\c<pre>', 'bW') - 1)
204 if preline > 0 212 if preline > 0
213 if restore_ic == 0
214 setlocal noic
215 endif
205 return indent(preline) 216 return indent(preline)
206 endif 217 endif
207 endif 218 endif
208 219
209 let ind = <SID>HtmlIndentSum(lnum, -1) 220 let ind = <SID>HtmlIndentSum(lnum, -1)
214 endif 225 endif
215 226
216 return indent(lnum) + (&sw * ind) 227 return indent(lnum) + (&sw * ind)
217 endfun 228 endfun
218 229
230 let &cpo = s:cpo_save
231 unlet s:cpo_save
232
219 " [-- EOF <runtime>/indent/html.vim --] 233 " [-- EOF <runtime>/indent/html.vim --]