From b5b7562475ad032a174b893286172de0d2c157cd Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Fri, 9 Mar 2018 22:22:21 +0100 Subject: Update runtime files. --- runtime/indent/html.vim | 32 ++++++++++++++++++++++++-------- 1 file changed, 24 insertions(+), 8 deletions(-) (limited to 'runtime/indent') diff --git a/runtime/indent/html.vim b/runtime/indent/html.vim index 37697841f..b105dcabc 100644 --- a/runtime/indent/html.vim +++ b/runtime/indent/html.vim @@ -2,7 +2,7 @@ " Header: "{{{ " Maintainer: Bram Moolenaar " Original Author: Andy Wokula -" Last Change: 2017 Jun 13 +" Last Change: 2018 Mar 09 " Version: 1.0 " Description: HTML indent script with cached state for faster indenting on a " range of lines. @@ -56,6 +56,9 @@ let s:cpo_save = &cpo set cpo-=C "}}} +" Pattern to match the name of a tag, including custom elements. +let s:tagname = '\w\+\(-\w\+\)*' + " Check and process settings from b:html_indent and g:html_indent... variables. " Prefer using buffer-local settings over global settings, so that there can " be defaults for all HTML files and exceptions for specific types of HTML @@ -280,7 +283,7 @@ func! s:CountITags(text) let s:nextrel = 0 " relative indent steps for next line [unit &sw]: let s:block = 0 " assume starting outside of a block let s:countonly = 1 " don't change state - call substitute(a:text, '<\zs/\=\w\+\(-\w\+\)*\>\|\|', '\=s:CheckTag(submatch(0))', 'g') + call substitute(a:text, '<\zs/\=' . s:tagname . '\>\|\|', '\=s:CheckTag(submatch(0))', 'g') let s:countonly = 0 endfunc "}}} @@ -292,7 +295,7 @@ func! s:CountTagsAndState(text) let s:nextrel = 0 " relative indent steps for next line [unit &sw]: let s:block = b:hi_newstate.block - let tmp = substitute(a:text, '<\zs/\=\w\+\(-\w\+\)*\>\|\|', '\=s:CheckTag(submatch(0))', 'g') + let tmp = substitute(a:text, '<\zs/\=' . s:tagname . '\>\|\|', '\=s:CheckTag(submatch(0))', 'g') if s:block == 3 let b:hi_newstate.scripttype = s:GetScriptType(matchstr(tmp, '\C.*\zs[^>]*')) endif @@ -530,7 +533,7 @@ func! s:FreshState(lnum) let swendtag = match(text, '^\s*= 0 " If previous line ended in a closing tag, line up with the opening tag. - if !swendtag && text =~ '\s*$' + if !swendtag && text =~ '\s*$' call cursor(state.lnum, 99999) normal! F< let start_lnum = HtmlIndent_FindStartTag() @@ -860,7 +863,7 @@ func! HtmlIndent_FindStartTag() " The cursor must be on or before a closing tag. " If found, positions the cursor at the match and returns the line number. " Otherwise returns 0. - let tagname = matchstr(getline('.')[col('.') - 1:], '', '', '', 'bW') if start_lnum > 0 return start_lnum @@ -876,7 +879,7 @@ func! HtmlIndent_FindTagEnd() " a self-closing tag, to the matching ">". " Limited to look up to b:html_indent_line_limit lines away. let text = getline('.') - let tagname = matchstr(text, '\w\+\|!--', col('.')) + let tagname = matchstr(text, s:tagname . '\|!--', col('.')) if tagname == '!--' call search('--\zs>') elseif s:get_tag('/' . tagname) != 0 @@ -921,9 +924,22 @@ func! s:InsideTag(foundHtmlString) else let idx = match(text, '\s\zs[_a-zA-Z0-9-]\+="') endif + if idx == -1 + " try = 0 + call cursor(lnum, idx) + return virtcol('.') + shiftwidth() + endif + endif if idx > 0 - " Found the attribute. TODO: assumes spaces, no Tabs. - return idx + " Found the attribute to align with. + call cursor(lnum, idx) + return virtcol('.') endif endwhile return -1 -- cgit v1.2.1