From 3e0c887365bc1ebd55b91dd69ab73f2dee1f00ed Mon Sep 17 00:00:00 2001 From: Dan Reif Date: Mon, 30 Apr 2018 12:00:42 -0700 Subject: Update (periodic rebuild) I originally meant to run this before adding haproxy, but accidentally pushed that into my branch. If you'd like to see that content, it's at https://github.com/CH-DanReif/vim-polyglot/commit/414ad25c3ad1ab9c4b6a99fe4f08d6c30b7e0f57. --- indent/haskell.vim | 2 +- indent/html.vim | 1445 ++++++++++++++++++++++++++++++++++--------------- indent/javascript.vim | 47 +- indent/julia.vim | 15 +- indent/nix.vim | 8 +- indent/swift.vim | 80 ++- 6 files changed, 1123 insertions(+), 474 deletions(-) (limited to 'indent') diff --git a/indent/haskell.vim b/indent/haskell.vim index 5a337144..11cca26b 100644 --- a/indent/haskell.vim +++ b/indent/haskell.vim @@ -320,7 +320,7 @@ function! GetHaskellIndent() " newtype Foo = Foo " >>deriving - if l:prevline =~ '\C\s*\<\(newtype\|data\)\>[^{]\+' && l:line =~ '\C^\s*\' + if l:prevline =~ '\C^\s*\<\(newtype\|data\)\>[^{]\+' && l:line =~ '\C^\s*\' return match(l:prevline, '\S') + &shiftwidth endif diff --git a/indent/html.vim b/indent/html.vim index 1e5691f7..defaca2a 100644 --- a/indent/html.vim +++ b/indent/html.vim @@ -1,466 +1,1065 @@ if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'html5') == -1 -" Description: HTML5 and inline SVG indenter -" Changed By: HT de Beer -" Last Change: 20121013 -" Added the SVG elements to the list of indenting element. SVG elements -" taken from http://www.w3.org/TR/SVG/eltindex.html -" -" Description: html5 (and html4) indenter -" Changed By: Brian Gershon -" Last Change: 30 Jan 2011 -" -" 1. Started with vim72 html indent file authored by Johannes Zellner (below) -" 2. Added html5 list as described here: -" http://stackoverflow.com/questions/3232518/how-to-update-vim-to-color-code-new-html-elements -" 3. Added this to a fork of https://github.com/othree/html5.vim -" which already provides nice html5 syntax highlighting. +" Vim indent script for HTML +" Header: "{{{ +" Maintainer: Bram Moolenaar +" Original Author: Andy Wokula +" Last Change: 2017 Jun 13 +" Version: 1.0 +" Description: HTML indent script with cached state for faster indenting on a +" range of lines. +" Supports template systems through hooks. +" Supports Closure stylesheets. " -" Description: html indenter -" Author: Johannes Zellner -" Last Change: Mo, 05 Jun 2006 22:32:41 CEST -" Restoring 'cpo' and 'ic' added by Bram 2006 May 5 -" Globals: -" let g:html_indent_tags = 'html\|p\|time' -" let g:html_exclude_tags = ['html', 'style', 'script', 'body'] - - -" Only load this indent file when no other was loaded. -if exists("b:did_indent") - finish +" Credits: +" indent/html.vim (2006 Jun 05) from J. Zellner +" indent/css.vim (2006 Dec 20) from N. Weibull +" +" History: +" 2014 June (v1.0) overhaul (Bram) +" 2012 Oct 21 (v0.9) added support for shiftwidth() +" 2011 Sep 09 (v0.8) added HTML5 tags (thx to J. Zuckerman) +" 2008 Apr 28 (v0.6) revised customization +" 2008 Mar 09 (v0.5) fixed 'indk' issue (thx to C.J. Robinson) +"}}} + +" Init Folklore, check user settings (2nd time ++) +if exists("b:did_indent") "{{{ + finish endif -runtime! indent/javascript.vim -let s:jsindent = &indentexpr -unlet b:did_indent -runtime! indent/css.vim -let s:cssindent = &indentexpr -let b:did_indent = 1 -" [-- local settings (must come before aborting the script) --] -setlocal indentexpr=HtmlIndentGet(v:lnum) -setlocal indentkeys=o,O,*,<>>,{,},!^F - - -let s:tags = [] -let s:no_tags = [] - -" [-- --] -call add(s:tags, 'a') -call add(s:tags, 'abbr') -call add(s:tags, 'acronym') -call add(s:tags, 'address') -call add(s:tags, 'b') -call add(s:tags, 'bdo') -call add(s:tags, 'big') -call add(s:tags, 'blockquote') -call add(s:tags, 'button') -call add(s:tags, 'caption') -call add(s:tags, 'center') -call add(s:tags, 'cite') -call add(s:tags, 'code') -call add(s:tags, 'colgroup') -call add(s:tags, 'del') -call add(s:tags, 'dfn') -call add(s:tags, 'dir') -call add(s:tags, 'div') -call add(s:tags, 'dl') -call add(s:tags, 'dt') -call add(s:tags, 'dd') -call add(s:tags, 'em') -call add(s:tags, 'fieldset') -call add(s:tags, 'font') -call add(s:tags, 'form') -call add(s:tags, 'frameset') -call add(s:tags, 'h1') -call add(s:tags, 'h2') -call add(s:tags, 'h3') -call add(s:tags, 'h4') -call add(s:tags, 'h5') -call add(s:tags, 'h6') -call add(s:tags, 'i') -call add(s:tags, 'iframe') -call add(s:tags, 'ins') -call add(s:tags, 'kbd') -call add(s:tags, 'label') -call add(s:tags, 'legend') -call add(s:tags, 'li') -call add(s:tags, 'map') -call add(s:tags, 'menu') -call add(s:tags, 'noframes') -call add(s:tags, 'noscript') -call add(s:tags, 'object') -call add(s:tags, 'ol') -call add(s:tags, 'optgroup') -call add(s:tags, 'p') -" call add(s:tags, 'pre') -call add(s:tags, 'q') -call add(s:tags, 's') -call add(s:tags, 'samp') -call add(s:tags, 'script') -call add(s:tags, 'select') -call add(s:tags, 'small') -call add(s:tags, 'span') -call add(s:tags, 'strong') -call add(s:tags, 'style') -call add(s:tags, 'sub') -call add(s:tags, 'sup') -call add(s:tags, 'table') -call add(s:tags, 'textarea') -call add(s:tags, 'title') -call add(s:tags, 'tt') -call add(s:tags, 'u') -call add(s:tags, 'ul') -call add(s:tags, 'var') - -" New HTML 5 elements -call add(s:tags, 'article') -call add(s:tags, 'aside') -call add(s:tags, 'audio') -call add(s:tags, 'canvas') -call add(s:tags, 'datalist') -call add(s:tags, 'details') -call add(s:tags, 'figcaption') -call add(s:tags, 'figure') -call add(s:tags, 'footer') -call add(s:tags, 'header') -call add(s:tags, 'hgroup') -call add(s:tags, 'main') -call add(s:tags, 'mark') -call add(s:tags, 'meter') -call add(s:tags, 'nav') -call add(s:tags, 'output') -call add(s:tags, 'progress') -call add(s:tags, 'picture') -call add(s:tags, 'rb') -call add(s:tags, 'rp') -call add(s:tags, 'rt') -call add(s:tags, 'rtc') -call add(s:tags, 'ruby') -call add(s:tags, 'section') -call add(s:tags, 'source') -call add(s:tags, 'summary') -call add(s:tags, 'time') -call add(s:tags, 'video') -call add(s:tags, 'bdi') -call add(s:tags, 'data') - -" Web Component -call add(s:tags, 'template') - -" Common inline used SVG elements -call add(s:tags, 'clipPath') -call add(s:tags, 'defs') -call add(s:tags, 'desc') -call add(s:tags, 'filter') -call add(s:tags, 'foreignObject') -call add(s:tags, 'g') -call add(s:tags, 'linearGradient') -call add(s:tags, 'marker') -call add(s:tags, 'mask') -call add(s:tags, 'pattern') -call add(s:tags, 'radialGradient') -call add(s:tags, 'svg') -call add(s:tags, 'switch') -call add(s:tags, 'symbol') -call add(s:tags, 'text') -call add(s:tags, 'textPath') -call add(s:tags, 'tref') -call add(s:tags, 'tspan') -" Common self closing SVG elements -call add(s:no_tags, 'animate') -call add(s:no_tags, 'animateTransform') -call add(s:no_tags, 'circle') -call add(s:no_tags, 'ellipse') -call add(s:no_tags, 'feBlend') -call add(s:no_tags, 'feColorMatrix') -call add(s:no_tags, 'feComposite') -call add(s:no_tags, 'feConvolveMatrix') -call add(s:no_tags, 'feDisplacementMap') -call add(s:no_tags, 'feFlood') -call add(s:no_tags, 'feFuncR') -call add(s:no_tags, 'feFuncG') -call add(s:no_tags, 'feFuncB') -call add(s:no_tags, 'feFuncA') -call add(s:no_tags, 'feGaussianBlur') -call add(s:no_tags, 'feImage') -call add(s:no_tags, 'feMergeNode') -call add(s:no_tags, 'feMorphology') -call add(s:no_tags, 'feOffset') -call add(s:no_tags, 'fePointLight') -call add(s:no_tags, 'feSpotLight') -call add(s:no_tags, 'feTile') -call add(s:no_tags, 'feTurbulence') -call add(s:no_tags, 'hatchpath') -call add(s:no_tags, 'hkern') -call add(s:no_tags, 'image') -call add(s:no_tags, 'line') -call add(s:no_tags, 'mpath') -call add(s:no_tags, 'polygon') -call add(s:no_tags, 'polyline') -call add(s:no_tags, 'path') -call add(s:no_tags, 'rect') -call add(s:no_tags, 'solidColor') -call add(s:no_tags, 'stop') -call add(s:no_tags, 'use') -call add(s:no_tags, 'view') -call add(s:no_tags, 'vkern') - -call add(s:tags, 'html') -call add(s:tags, 'head') -call add(s:tags, 'body') - -call add(s:tags, 'thead') -call add(s:tags, 'tbody') -call add(s:tags, 'tfoot') -call add(s:tags, 'tr') -call add(s:tags, 'th') -call add(s:tags, 'td') - -call add(s:no_tags, 'base') -call add(s:no_tags, 'link') -call add(s:no_tags, 'meta') -call add(s:no_tags, 'hr') -call add(s:no_tags, 'br') -call add(s:no_tags, 'wbr') -call add(s:no_tags, 'img') -call add(s:no_tags, 'embed') -call add(s:no_tags, 'param') -call add(s:no_tags, 'source') -call add(s:no_tags, 'track') -call add(s:no_tags, 'area') -call add(s:no_tags, 'col') -call add(s:no_tags, 'input') -call add(s:no_tags, 'keygen') -call add(s:no_tags, 'menuitem') - -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'], - \] - - -let s:html_noindent_tags = join(s:no_tags, '\|') - -if exists('g:html_exclude_tags') - for tag in g:html_exclude_tags - call remove(s:tags, index(s:tags, tag)) - endfor - let s:html_noindent_tags = s:html_noindent_tags.'\|'.join(g:html_exclude_tags, '\|') +" Load the Javascript indent script first, it defines GetJavascriptIndent(). +" Undo the rest. +" Load base python indent. +if !exists('*GetJavascriptIndent') + runtime! indent/javascript.vim endif +let b:did_indent = 1 + +setlocal indentexpr=HtmlIndent() +setlocal indentkeys=o,O,,<>>,{,},!^F + +" Needed for % to work when finding start/end of a tag. +setlocal matchpairs+=<:> + +let b:undo_indent = "setlocal inde< indk<" -" let s:html_indent_tags = join(s:tags, '\|') -let s:html_indent_tags = '[a-z_][a-z0-9_.-]*' -" if exists('g:html_indent_tags') - " let s:html_indent_tags = s:html_indent_tags.'\|'.g:html_indent_tags -" endif +" b:hi_indent keeps state to speed up indenting consecutive lines. +let b:hi_indent = {"lnum": -1} +"""""" Code below this is loaded only once. """"" +if exists("*HtmlIndent") && !exists('g:force_reload_html') + call HtmlIndent_CheckUserSettings() + finish +endif + +" Allow for line continuation below. let s:cpo_save = &cpo set cpo-=C +"}}} -func! HtmlIndentPatternCount(content, pattern) - let s = substitute('x'.a:content, a:pattern, "\1", 'g') - let s = substitute(s, "[^\1].*$", '', '') - return strlen(s) -endfun - -" [-- count indent-increasing tags of line a:lnum --] -fun! HtmlIndentOpen(lnum, pattern) - return HtmlIndentPatternCount(getline(a:lnum), - \ '.\{-}\(\(<\)\('.a:pattern.'\)\>\)') -endfun - -" [-- count indent-decreasing tags of line a:lnum --] -fun! HtmlIndentClose(lnum, pattern) - return HtmlIndentPatternCount(getline(a:lnum), - \ '.\{-}\(\(<\)/\('.a:pattern.'\)\>>\)') -endfun - -" [-- count self close tags of line a:lnum --] -fun! HtmlIndentSelfClose(lnum, pattern) - return HtmlIndentPatternCount(getline(a:lnum), - \ '.\{-}\(\(<\('.a:pattern.'\).*\)\@\)') -endfun - -" [-- count indent-increasing '{' of (java|css) line a:lnum --] -fun! HtmlIndentOpenAlt(lnum) - return strlen(substitute(getline(a:lnum), '[^{]\+', '', 'g')) -endfun - -" [-- count indent-decreasing '}' of (java|css) line a:lnum --] -fun! HtmlIndentCloseAlt(lnum) - return strlen(substitute(getline(a:lnum), '[^}]\+', '', 'g')) -endfun - -" [-- return the sum of indents respecting the syntax of a:lnum --] -fun! HtmlIndentSum(lnum, style) - if a:style == match(getline(a:lnum), '^\s*') - let open = HtmlIndentOpen(a:lnum, s:html_indent_tags) - HtmlIndentOpen(a:lnum, s:html_noindent_tags) - let close = HtmlIndentClose(a:lnum, s:html_indent_tags) - HtmlIndentClose(a:lnum, s:html_noindent_tags) - let self_close = HtmlIndentSelfClose(a:lnum, s:html_noindent_tags) - if 0 != open || 0 != close || 0 != self_close - return open - close - self_close - endif - endif - endif +" 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 +" files. +func! HtmlIndent_CheckUserSettings() + "{{{ + let inctags = '' + if exists("b:html_indent_inctags") + let inctags = b:html_indent_inctags + elseif exists("g:html_indent_inctags") + let inctags = g:html_indent_inctags + endif + let b:hi_tags = {} + if len(inctags) > 0 + call s:AddITags(b:hi_tags, split(inctags, ",")) + endif - if '' != &syntax && - \ synIDattr(synID(a:lnum, 1, 1), 'name') =~ '\(css\|java\).*' && - \ synIDattr(synID(a:lnum, strlen(getline(a:lnum)), 1), 'name') - \ =~ '\(css\|java\).*' - if a:style == match(getline(a:lnum), '^\s*}') - return HtmlIndentOpenAlt(a:lnum) - HtmlIndentCloseAlt(a:lnum) - endif + let autotags = '' + if exists("b:html_indent_autotags") + let autotags = b:html_indent_autotags + elseif exists("g:html_indent_autotags") + let autotags = g:html_indent_autotags + endif + let b:hi_removed_tags = {} + if len(autotags) > 0 + call s:RemoveITags(b:hi_removed_tags, split(autotags, ",")) + endif + + " Syntax names indicating being inside a string of an attribute value. + let string_names = [] + if exists("b:html_indent_string_names") + let string_names = b:html_indent_string_names + elseif exists("g:html_indent_string_names") + let string_names = g:html_indent_string_names + endif + let b:hi_insideStringNames = ['htmlString'] + if len(string_names) > 0 + for s in string_names + call add(b:hi_insideStringNames, s) + endfor + endif + + " Syntax names indicating being inside a tag. + let tag_names = [] + if exists("b:html_indent_tag_names") + let tag_names = b:html_indent_tag_names + elseif exists("g:html_indent_tag_names") + let tag_names = g:html_indent_tag_names + endif + let b:hi_insideTagNames = ['htmlTag', 'htmlScriptTag'] + if len(tag_names) > 0 + for s in tag_names + call add(b:hi_insideTagNames, s) + endfor + endif + + let indone = {"zero": 0 + \,"auto": "indent(prevnonblank(v:lnum-1))" + \,"inc": "b:hi_indent.blocktagind + shiftwidth()"} + + let script1 = '' + if exists("b:html_indent_script1") + let script1 = b:html_indent_script1 + elseif exists("g:html_indent_script1") + let script1 = g:html_indent_script1 + endif + if len(script1) > 0 + let b:hi_js1indent = get(indone, script1, indone.zero) + else + let b:hi_js1indent = 0 + endif + + let style1 = '' + if exists("b:html_indent_style1") + let style1 = b:html_indent_style1 + elseif exists("g:html_indent_style1") + let style1 = g:html_indent_style1 + endif + if len(style1) > 0 + let b:hi_css1indent = get(indone, style1, indone.zero) + else + let b:hi_css1indent = 0 + endif + + if !exists('b:html_indent_line_limit') + if exists('g:html_indent_line_limit') + let b:html_indent_line_limit = g:html_indent_line_limit + else + let b:html_indent_line_limit = 200 endif + endif +endfunc "}}} + +" Init Script Vars +"{{{ +let b:hi_lasttick = 0 +let b:hi_newstate = {} +let s:countonly = 0 + "}}} + +" Fill the s:indent_tags dict with known tags. +" The key is "tagname" or "/tagname". {{{ +" The value is: +" 1 opening tag +" 2 "pre" +" 3 "script" +" 4 "style" +" 5 comment start +" 6 conditional comment start +" -1 closing tag +" -2 "/pre" +" -3 "/script" +" -4 "/style" +" -5 comment end +" -6 conditional comment end +let s:indent_tags = {} +let s:endtags = [0,0,0,0,0,0,0] " long enough for the highest index +"}}} + +" Add a list of tag names for a pair of to "tags". +func! s:AddITags(tags, taglist) + "{{{ + for itag in a:taglist + let a:tags[itag] = 1 + let a:tags['/' . itag] = -1 + endfor +endfunc "}}} + +" Take a list of tag name pairs that are not to be used as tag pairs. +func! s:RemoveITags(tags, taglist) + "{{{ + for itag in a:taglist + let a:tags[itag] = 1 + let a:tags['/' . itag] = 1 + endfor +endfunc "}}} + +" Add a block tag, that is a tag with a different kind of indenting. +func! s:AddBlockTag(tag, id, ...) + "{{{ + if !(a:id >= 2 && a:id < len(s:endtags)) + echoerr 'AddBlockTag ' . a:id + return + endif + let s:indent_tags[a:tag] = a:id + if a:0 == 0 + let s:indent_tags['/' . a:tag] = -a:id + let s:endtags[a:id] = "" + else + let s:indent_tags[a:1] = -a:id + let s:endtags[a:id] = a:1 + endif +endfunc "}}} + +" Add known tag pairs. +" Self-closing tags and tags that are sometimes {{{ +" self-closing (e.g.,

) are not here (when encountering

we can find +" the matching

, but not the other way around). +" Old HTML tags: +call s:AddITags(s:indent_tags, [ + \ 'a', 'abbr', 'acronym', 'address', 'b', 'bdo', 'big', + \ 'blockquote', 'body', 'button', 'caption', 'center', 'cite', 'code', + \ 'colgroup', 'del', 'dfn', 'dir', 'div', 'dl', 'em', 'fieldset', 'font', + \ 'form', 'frameset', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'head', 'html', + \ 'i', 'iframe', 'ins', 'kbd', 'label', 'legend', 'li', + \ 'map', 'menu', 'noframes', 'noscript', 'object', 'ol', + \ 'optgroup', 'p', 'q', 's', 'samp', 'select', 'small', 'span', 'strong', 'sub', + \ 'sup', 'table', 'textarea', 'title', 'tt', 'u', 'ul', 'var', 'th', 'td', + \ 'tr', 'tbody', 'tfoot', 'thead']) + +" New HTML5 elements: +call s:AddITags(s:indent_tags, [ + \ 'area', 'article', 'aside', 'audio', 'bdi', 'canvas', + \ 'command', 'data', 'datalist', 'details', 'dislog', 'embed', 'figcaption', + \ 'figure', 'footer', 'header', 'keygen', 'main', 'mark', 'meter', 'nav', 'output', + \ 'picture', 'progress', 'rp', 'rt', 'ruby', 'section', 'source', 'summary', 'svg', + \ 'time', 'track', 'video', 'wbr']) + +" Tags added for web components: +call s:AddITags(s:indent_tags, [ + \ 'content', 'shadow', 'template']) +"}}} + +" Add Block Tags: these contain alien content +"{{{ +call s:AddBlockTag('pre', 2) +call s:AddBlockTag('script', 3) +call s:AddBlockTag('style', 4) +call s:AddBlockTag('') +call s:AddBlockTag('') +"}}} + +" Return non-zero when "tagname" is an opening tag, not being a block tag, for +" which there should be a closing tag. Can be used by scripts that include +" HTML indenting. +func! HtmlIndent_IsOpenTag(tagname) + "{{{ + if get(s:indent_tags, a:tagname) == 1 + return 1 + endif + return get(b:hi_tags, a:tagname) == 1 +endfunc "}}} + +" Get the value for "tagname", taking care of buffer-local tags. +func! s:get_tag(tagname) + "{{{ + let i = get(s:indent_tags, a:tagname) + if (i == 1 || i == -1) && get(b:hi_removed_tags, a:tagname) != 0 return 0 -endfun + endif + if i == 0 + let i = get(b:hi_tags, a:tagname) + endif + return i +endfunc "}}} -fun! HtmlIndentGet(lnum) - " Get shiftwidth value. - if exists('*shiftwidth') - let sw = shiftwidth() +" Count the number of start and end tags in "text". +func! s:CountITags(text) + "{{{ + " Store the result in s:curind and s:nextrel. + let s:curind = 0 " relative indent steps for current line [unit &sw]: + 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') + let s:countonly = 0 +endfunc "}}} + +" Count the number of start and end tags in text. +func! s:CountTagsAndState(text) + "{{{ + " Store the result in s:curind and s:nextrel. Update b:hi_newstate.block. + let s:curind = 0 " relative indent steps for current line [unit &sw]: + 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') + if s:block == 3 + let b:hi_newstate.scripttype = s:GetScriptType(matchstr(tmp, '\C.*\zs[^>]*')) + endif + let b:hi_newstate.block = s:block +endfunc "}}} + +" Used by s:CountITags() and s:CountTagsAndState(). +func! s:CheckTag(itag) + "{{{ + " Returns an empty string or "SCRIPT". + " a:itag can be "tag" or "/tag" or "" + if (s:CheckCustomTag(a:itag)) + return "" + endif + let ind = s:get_tag(a:itag) + if ind == -1 + " closing tag + if s:block != 0 + " ignore itag within a block + return "" + endif + if s:nextrel == 0 + let s:curind -= 1 else - let sw = &sw + let s:nextrel -= 1 endif + elseif ind == 1 + " opening tag + if s:block != 0 + return "" + endif + let s:nextrel += 1 + elseif ind != 0 + " block-tag (opening or closing) + return s:CheckBlockTag(a:itag, ind) + " else ind==0 (other tag found): keep indent + endif + return "" +endfunc "}}} - " Find a non-empty line above the current line. - let lnum = prevnonblank(a:lnum - 1) +" Used by s:CheckTag(). Returns an empty string or "SCRIPT". +func! s:CheckBlockTag(blocktag, ind) + "{{{ + if a:ind > 0 + " a block starts here + if s:block != 0 + " already in a block (nesting) - ignore + " especially ignore comments after other blocktags + return "" + endif + let s:block = a:ind " block type + if s:countonly + return "" + endif + let b:hi_newstate.blocklnr = v:lnum + " save allover indent for the endtag + let b:hi_newstate.blocktagind = b:hi_indent.baseindent + (s:nextrel + s:curind) * shiftwidth() + if a:ind == 3 + return "SCRIPT" " all except this must be lowercase + " line is to be checked again for the type attribute + endif + else + let s:block = 0 + " we get here if starting and closing a block-tag on the same line + endif + return "" +endfunc "}}} - " Hit the start of the file, use zero indent. - if lnum == 0 - return 0 +" Used by s:CheckTag(). +func! s:CheckCustomTag(ctag) + "{{{ + " Returns 1 if ctag is the tag for a custom element, 0 otherwise. + " a:ctag can be "tag" or "/tag" or "" + let pattern = '\%\(\w\+-\)\+\w\+' + if match(a:ctag, pattern) == -1 + return 0 + endif + if matchstr(a:ctag, '\/\ze.\+') == "/" + " closing tag + if s:block != 0 + " ignore ctag within a block + return 1 + endif + if s:nextrel == 0 + let s:curind -= 1 + else + let s:nextrel -= 1 endif + else + " opening tag + if s:block != 0 + return 1 + endif + let s:nextrel += 1 + endif + return 1 +endfunc "}}} - let restore_ic = &ic - setlocal ic " ignore case +" Return the ' - - """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" - " by Tye Zdrojewski , 05 Jun 2006 - " ZDR: This needs to be an AND (we are 'after the start of the pair' AND - " we are 'before the end of the pair'). Otherwise, indentation - " before the start of the script block will be affected; the end of - " the pair will still match if we are before the beginning of the - " pair. - " - if 0 < searchpair(js, '', jse, 'nWb') - \ && 0 < searchpair(js, '', jse, 'nW') - " we're inside javascript - if getline(searchpair(js, '', '', 'nWb')) !~ '