From e108a087b4a5a3acb55786643e5289a64c8b0c60 Mon Sep 17 00:00:00 2001 From: Adam Stankiewicz Date: Mon, 7 Oct 2013 11:07:27 +0200 Subject: Update latex, html, ruby, c, cpp --- indent/html.vim | 46 +++++++++++++++++++++++++++++++--------------- 1 file changed, 31 insertions(+), 15 deletions(-) (limited to 'indent/html.vim') diff --git a/indent/html.vim b/indent/html.vim index 6c30555d..d5b7c837 100644 --- a/indent/html.vim +++ b/indent/html.vim @@ -167,6 +167,16 @@ call add(s:tags, 'tr') call add(s:tags, 'th') call add(s:tags, 'td') + + +let s:omittable = [ + \ ['address', 'article', 'aside', 'blockquote', 'dir', 'div', 'dl', 'fieldset', 'footer', 'form', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'header', 'hr', 'menu', 'nav', 'ol', 'p', 'pre', 'section', 'table', 'ul'], + \ ['dt', 'dd'], + \ ['li'], + \ ['thead', 'tbody', 'tfoot'], + \ ['th', 'td'], + \] + if exists('g:html_exclude_tags') for tag in g:html_exclude_tags call remove(s:tags, index(s:tags, tag)) @@ -331,29 +341,35 @@ fun! HtmlIndentGet(lnum) let ind = ind - 1 endif - if getline(a:lnum) =~ '' - let block_start = search('^'.repeat(' ', ind * &sw).'\S' , 'bnW') - let prev_tag = search('', 'bW', block_start) - let prev_closetag = search('', 'W', a:lnum) - if prev_tag && !prev_closetag - let ind = ind - 1 + let lind = indent(lnum) + + for tags in s:omittable + let tags_exp = '<\(' . join(tags, '\|') . '\)>' + let close_tags_exp = '' + if getline(a:lnum) =~ tags_exp + let block_start = search('^'.repeat(' ', lind + (&sw * ind - 1)).'\S' , 'bnW') + let prev_tag = search(tags_exp, 'bW', block_start) + let prev_closetag = search(close_tags_exp, 'W', a:lnum) + if prev_tag && !prev_closetag + let ind = ind - 1 + endif endif - endif - if getline(a:lnum) =~ '' - let block_start = search('^'.repeat(' ', ind * &sw).'\S' , 'bnW') - let prev_tag = search('', 'bW', block_start) - let prev_closetag = search('', 'W', a:lnum) - if prev_tag && !prev_closetag - let ind = ind - 1 + if getline(a:lnum) =~ '' + let block_start = search('^'.repeat(' ', lind + (&sw * ind - 1)).'\S' , 'bnW') + let prev_tag = search(tags_exp, 'bW', block_start) + let prev_closetag = search(close_tags_exp, 'W', a:lnum) + if prev_tag && !prev_closetag + let ind = ind - 1 + endif endif - endif + endfor if restore_ic == 0 setlocal noic endif - return indent(lnum) + (&sw * ind) + return lind + (&sw * ind) endfun let &cpo = s:cpo_save -- cgit v1.2.3