diff options
| author | Adam Stankiewicz <sheerun@sher.pl> | 2020-10-08 00:40:28 +0200 | 
|---|---|---|
| committer | Adam Stankiewicz <sheerun@sher.pl> | 2020-10-08 00:40:28 +0200 | 
| commit | bb3de8fa5e509d5f5faf173fd1a92635a0023274 (patch) | |
| tree | a6401fbc683b8213f008d0564fa40e7f81e1c6f2 | |
| parent | b3763a917a6a3ca85ae51086fc8d29b28f66fc88 (diff) | |
| download | vim-polyglot-bb3de8fa5e509d5f5faf173fd1a92635a0023274.tar.gz vim-polyglot-bb3de8fa5e509d5f5faf173fd1a92635a0023274.zip | |
Fix markdown and other highlighting, #578
Diffstat (limited to '')
| -rw-r--r-- | README.md | 2 | ||||
| -rw-r--r-- | after/ftplugin/html.vim | 13 | ||||
| -rw-r--r-- | after/indent/html.vim | 1064 | ||||
| -rw-r--r-- | after/syntax/html.vim | 186 | ||||
| -rw-r--r-- | after/syntax/html/aria.vim (renamed from syntax/html/aria.vim) | 0 | ||||
| -rw-r--r-- | after/syntax/html/electron.vim (renamed from syntax/html/electron.vim) | 0 | ||||
| -rw-r--r-- | after/syntax/html/rdfa.vim (renamed from syntax/html/rdfa.vim) | 0 | ||||
| -rw-r--r-- | after/syntax/javascript/html5.vim (renamed from syntax/javascript/html5.vim) | 0 | ||||
| -rw-r--r-- | ftdetect/polyglot.vim | 10 | ||||
| -rw-r--r-- | ftplugin/html.vim | 56 | ||||
| -rw-r--r-- | indent/html.vim | 76 | ||||
| -rw-r--r-- | packages.yaml | 20 | ||||
| -rw-r--r-- | syntax/html.vim | 497 | ||||
| -rw-r--r-- | tests/filetypes.vim | 2 | 
14 files changed, 1691 insertions, 235 deletions
| @@ -7,7 +7,7 @@ A collection of language packs for Vim.  > One to rule them all, one to find them, one to bring them all and in the darkness bind them.  - It **won't affect your startup time**, as scripts are loaded only on demand\*. -- It **installs and updates 120+ times faster** than the <!--Package Count-->590<!--/Package Count--> packages it consists of. +- It **installs and updates 120+ times faster** than the <!--Package Count-->591<!--/Package Count--> packages it consists of.  - It is more secure because scripts loaded for all extensions are generated by vim-polyglot (ftdetect).  - Solid syntax and indentation support (other features skipped). Only the best language packs.  - All unnecessary files are ignored (like enormous documentation from php support). diff --git a/after/ftplugin/html.vim b/after/ftplugin/html.vim new file mode 100644 index 00000000..50cdb2ae --- /dev/null +++ b/after/ftplugin/html.vim @@ -0,0 +1,13 @@ +if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'html5') == -1 + +" Maintainer:  	othree <othree@gmail.com> +" URL:		      http://github.com/othree/html5.vim +" Last Change:  2014-05-02 +" License:      MIT +" Changes:      Add - to keyword + +" setlocal iskeyword+=- + +setlocal commentstring=<!--%s--> + +endif diff --git a/after/indent/html.vim b/after/indent/html.vim new file mode 100644 index 00000000..3b9c7eb4 --- /dev/null +++ b/after/indent/html.vim @@ -0,0 +1,1064 @@ +if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'html5') == -1 + +" Vim indent script for HTML +" Header: "{{{ +" Maintainer:	Bram Moolenaar +" Original Author: Andy Wokula <anwoku@yahoo.de> +" 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. +" +" 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 + +" 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,<Return>,<>>,{,},!^F + +" Needed for % to work when finding start/end of a tag. +setlocal matchpairs+=<:> + +let b:undo_indent = "setlocal inde< indk<" + +" 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 +"}}} + +" 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 + +  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 <tag> </tag> 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] = "</" . a:tag . ">" +  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., <p>) are not here (when encountering </p> we can find +" the matching <p>, 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('<!--', 5, '-->') +call s:AddBlockTag('<!--[', 6, '![endif]-->') +"}}} + +" 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 +  endif +  if i == 0 +    let i = get(b:hi_tags, a:tagname) +  endif +  return i +endfunc "}}} + +" 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\+\)*\>\|<!--\[\|\[endif\]-->\|<!--\|-->', '\=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\+\)*\>\|<!--\[\|\[endif\]-->\|<!--\|-->', '\=s:CheckTag(submatch(0))', 'g') +  if s:block == 3 +    let b:hi_newstate.scripttype = s:GetScriptType(matchstr(tmp, '\C.*<SCRIPT\>\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 "<!--" 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 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 "}}} + +" 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 "}}} + +" 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 "<!--" 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 "}}} + +" Return the <script> type: either "javascript" or "" +func! s:GetScriptType(str) +  "{{{ +  if a:str == "" || a:str =~ "java" +    return "javascript" +  else +    return "" +  endif +endfunc "}}} + +" Look back in the file, starting at a:lnum - 1, to compute a state for the +" start of line a:lnum.  Return the new state. +func! s:FreshState(lnum) +  "{{{ +  " A state is to know ALL relevant details about the +  " lines 1..a:lnum-1, initial calculating (here!) can be slow, but updating is +  " fast (incremental). +  " TODO: this should be split up in detecting the block type and computing the +  " indent for the block type, so that when we do not know the indent we do +  " not need to clear the whole state and re-detect the block type again. +  " State: +  "	lnum		last indented line == prevnonblank(a:lnum - 1) +  "	block = 0	a:lnum located within special tag: 0:none, 2:<pre>, +  "			3:<script>, 4:<style>, 5:<!--, 6:<!--[ +  "	baseindent	use this indent for line a:lnum as a start - kind of +  "			autoindent (if block==0) +  "	scripttype = ''	type attribute of a script tag (if block==3) +  "	blocktagind	indent for current opening (get) and closing (set) +  "			blocktag (if block!=0) +  "	blocklnr	lnum of starting blocktag (if block!=0) +  "	inattr		line {lnum} starts with attributes of a tag +  let state = {} +  let state.lnum = prevnonblank(a:lnum - 1) +  let state.scripttype = "" +  let state.blocktagind = -1 +  let state.block = 0 +  let state.baseindent = 0 +  let state.blocklnr = 0 +  let state.inattr = 0 + +  if state.lnum == 0 +    return state +  endif + +  " Heuristic: +  " remember startline state.lnum +  " look back for <pre, </pre, <script, </script, <style, </style tags +  " remember stopline +  " if opening tag found, +  "	assume a:lnum within block +  " else +  "	look back in result range (stopline, startline) for comment +  "	    \ delimiters (<!--, -->) +  "	if comment opener found, +  "	    assume a:lnum within comment +  "	else +  "	    assume usual html for a:lnum +  "	    if a:lnum-1 has a closing comment +  "		look back to get indent of comment opener +  " FI + +  " look back for a blocktag +  let stopline2 = v:lnum + 1 +  if has_key(b:hi_indent, 'block') && b:hi_indent.block > 5 +    let [stopline2, stopcol2] = searchpos('<!--', 'bnW') +  endif +  let [stopline, stopcol] = searchpos('\c<\zs\/\=\%(pre\>\|script\>\|style\>\)', "bnW") +  if stopline > 0 && stopline < stopline2 +    " ugly ... why isn't there searchstr() +    let tagline = tolower(getline(stopline)) +    let blocktag = matchstr(tagline, '\/\=\%(pre\>\|script\>\|style\>\)', stopcol - 1) +    if blocktag[0] != "/" +      " opening tag found, assume a:lnum within block +      let state.block = s:indent_tags[blocktag] +      if state.block == 3 +        let state.scripttype = s:GetScriptType(matchstr(tagline, '\>[^>]*', stopcol)) +      endif +      let state.blocklnr = stopline +      " check preceding tags in the line: +      call s:CountITags(tagline[: stopcol-2]) +      let state.blocktagind = indent(stopline) + (s:curind + s:nextrel) * shiftwidth() +      return state +    elseif stopline == state.lnum +      " handle special case: previous line (= state.lnum) contains a +      " closing blocktag which is preceded by line-noise; +      " blocktag == "/..." +      let swendtag = match(tagline, '^\s*</') >= 0 +      if !swendtag +        let [bline, bcol] = searchpos('<'.blocktag[1:].'\>', "bnW") +        call s:CountITags(tolower(getline(bline)[: bcol-2])) +        let state.baseindent = indent(bline) + (s:curind + s:nextrel) * shiftwidth() +        return state +      endif +    endif +  endif +  if stopline > stopline2 +    let stopline = stopline2 +    let stopcol = stopcol2 +  endif + +  " else look back for comment +  let [comlnum, comcol, found] = searchpos('\(<!--\[\)\|\(<!--\)\|-->', 'bpnW', stopline) +  if found == 2 || found == 3 +    " comment opener found, assume a:lnum within comment +    let state.block = (found == 3 ? 5 : 6) +    let state.blocklnr = comlnum +    " check preceding tags in the line: +    call s:CountITags(tolower(getline(comlnum)[: comcol-2])) +    if found == 2 +      let state.baseindent = b:hi_indent.baseindent +    endif +    let state.blocktagind = indent(comlnum) + (s:curind + s:nextrel) * shiftwidth() +    return state +  endif + +  " else within usual HTML +  let text = tolower(getline(state.lnum)) + +  " Check a:lnum-1 for closing comment (we need indent from the opening line). +  " Not when other tags follow (might be --> inside a string). +  let comcol = stridx(text, '-->') +  if comcol >= 0 && match(text, '[<>]', comcol) <= 0 +    call cursor(state.lnum, comcol + 1) +    let [comlnum, comcol] = searchpos('<!--', 'bW') +    if comlnum == state.lnum +      let text = text[: comcol-2] +    else +      let text = tolower(getline(comlnum)[: comcol-2]) +    endif +    call s:CountITags(text) +    let state.baseindent = indent(comlnum) + (s:curind + s:nextrel) * shiftwidth() +    " TODO check tags that follow "-->" +    return state +  endif + +  " Check if the previous line starts with end tag. +  let swendtag = match(text, '^\s*</') >= 0 + +  " If previous line ended in a closing tag, line up with the opening tag. +  if !swendtag && text =~ '</\w\+\s*>\s*$' +    call cursor(state.lnum, 99999) +    normal! F< +    let start_lnum = HtmlIndent_FindStartTag() +    if start_lnum > 0 +      let state.baseindent = indent(start_lnum) +      if col('.') > 2 +        " check for tags before the matching opening tag. +        let text = getline(start_lnum) +        let swendtag = match(text, '^\s*</') >= 0 +        call s:CountITags(text[: col('.') - 2]) +        let state.baseindent += s:nextrel * shiftwidth() +        if !swendtag +          let state.baseindent += s:curind * shiftwidth() +        endif +      endif +      return state +    endif +  endif + +  " Else: no comments. Skip backwards to find the tag we're inside. +  let [state.lnum, found] = HtmlIndent_FindTagStart(state.lnum) +  " Check if that line starts with end tag. +  let text = getline(state.lnum) +  let swendtag = match(text, '^\s*</') >= 0 +  call s:CountITags(tolower(text)) +  let state.baseindent = indent(state.lnum) + s:nextrel * shiftwidth() +  if !swendtag +    let state.baseindent += s:curind * shiftwidth() +  endif +  return state +endfunc "}}} + +" Indent inside a <pre> block: Keep indent as-is. +func! s:Alien2() +  "{{{ +  return -1 +endfunc "}}} + +" Return the indent inside a <script> block for javascript. +func! s:Alien3() +  "{{{ +  let lnum = prevnonblank(v:lnum - 1) +  while lnum > 1 && getline(lnum) =~ '^\s*/[/*]' +    " Skip over comments to avoid that cindent() aligns with the <script> tag +    let lnum = prevnonblank(lnum - 1) +  endwhile +  if lnum == b:hi_indent.blocklnr +    " indent for the first line after <script> +    return eval(b:hi_js1indent) +  endif +  if b:hi_indent.scripttype == "javascript" +    return GetJavascriptIndent() +  else +    return -1 +  endif +endfunc "}}} + +" Return the indent inside a <style> block. +func! s:Alien4() +  "{{{ +  if prevnonblank(v:lnum-1) == b:hi_indent.blocklnr +    " indent for first content line +    return eval(b:hi_css1indent) +  endif +  return s:CSSIndent() +endfunc "}}} + +" Indending inside a <style> block.  Returns the indent. +func! s:CSSIndent() +  "{{{ +  " This handles standard CSS and also Closure stylesheets where special lines +  " start with @. +  " When the line starts with '*' or the previous line starts with "/*" +  " and does not end in "*/", use C indenting to format the comment. +  " Adopted $VIMRUNTIME/indent/css.vim +  let curtext = getline(v:lnum) +  if curtext =~ '^\s*[*]' +        \ || (v:lnum > 1 && getline(v:lnum - 1) =~ '\s*/\*' +        \     && getline(v:lnum - 1) !~ '\*/\s*$') +    return cindent(v:lnum) +  endif + +  let min_lnum = b:hi_indent.blocklnr +  let prev_lnum = s:CssPrevNonComment(v:lnum - 1, min_lnum) +  let [prev_lnum, found] = HtmlIndent_FindTagStart(prev_lnum) +  if prev_lnum <= min_lnum +    " Just below the <style> tag, indent for first content line after comments. +    return eval(b:hi_css1indent) +  endif + +  " If the current line starts with "}" align with it's match. +  if curtext =~ '^\s*}' +    call cursor(v:lnum, 1) +    try +      normal! % +      " Found the matching "{", align with it after skipping unfinished lines. +      let align_lnum = s:CssFirstUnfinished(line('.'), min_lnum) +      return indent(align_lnum) +    catch +      " can't find it, try something else, but it's most likely going to be +      " wrong +    endtry +  endif + +  " add indent after { +  let brace_counts = HtmlIndent_CountBraces(prev_lnum) +  let extra = brace_counts.c_open * shiftwidth() + +  let prev_text = getline(prev_lnum) +  let below_end_brace = prev_text =~ '}\s*$' + +  " Search back to align with the first line that's unfinished. +  let align_lnum = s:CssFirstUnfinished(prev_lnum, min_lnum) + +  " Handle continuation lines if aligning with previous line and not after a +  " "}". +  if extra == 0 && align_lnum == prev_lnum && !below_end_brace +    let prev_hasfield = prev_text =~ '^\s*[a-zA-Z0-9-]\+:' +    let prev_special = prev_text =~ '^\s*\(/\*\|@\)' +    if curtext =~ '^\s*\(/\*\|@\)' +      " if the current line is not a comment or starts with @ (used by template +      " systems) reduce indent if previous line is a continuation line +      if !prev_hasfield && !prev_special +        let extra = -shiftwidth() +      endif +    else +      let cur_hasfield = curtext =~ '^\s*[a-zA-Z0-9-]\+:' +      let prev_unfinished = s:CssUnfinished(prev_text) +      if !cur_hasfield && (prev_hasfield || prev_unfinished) +        " Continuation line has extra indent if the previous line was not a +        " continuation line. +        let extra = shiftwidth() +        " Align with @if +        if prev_text =~ '^\s*@if ' +          let extra = 4 +        endif +      elseif cur_hasfield && !prev_hasfield && !prev_special +        " less indent below a continuation line +        let extra = -shiftwidth() +      endif +    endif +  endif + +  if below_end_brace +    " find matching {, if that line starts with @ it's not the start of a rule +    " but something else from a template system +    call cursor(prev_lnum, 1) +    call search('}\s*$') +    try +      normal! % +      " Found the matching "{", align with it. +      let align_lnum = s:CssFirstUnfinished(line('.'), min_lnum) +      let special = getline(align_lnum) =~ '^\s*@' +    catch +      let special = 0 +    endtry +    if special +      " do not reduce indent below @{ ... } +      if extra < 0 +        let extra += shiftwidth() +      endif +    else +      let extra -= (brace_counts.c_close - (prev_text =~ '^\s*}')) * shiftwidth() +    endif +  endif + +  " if no extra indent yet... +  if extra == 0 +    if brace_counts.p_open > brace_counts.p_close +      " previous line has more ( than ): add a shiftwidth +      let extra = shiftwidth() +    elseif brace_counts.p_open < brace_counts.p_close +      " previous line has more ) than (: subtract a shiftwidth +      let extra = -shiftwidth() +    endif +  endif + +  return indent(align_lnum) + extra +endfunc "}}} + +" Inside <style>: Whether a line is unfinished. +func! s:CssUnfinished(text) +  "{{{ +  return a:text =~ '\s\(||\|&&\|:\)\s*$' +endfunc "}}} + +" Search back for the first unfinished line above "lnum". +func! s:CssFirstUnfinished(lnum, min_lnum) +  "{{{ +  let align_lnum = a:lnum +  while align_lnum > a:min_lnum && s:CssUnfinished(getline(align_lnum - 1)) +    let align_lnum -= 1 +  endwhile +  return align_lnum +endfunc "}}} + +" Find the non-empty line at or before "lnum" that is not a comment. +func! s:CssPrevNonComment(lnum, stopline) +  "{{{ +  " caller starts from a line a:lnum + 1 that is not a comment +  let lnum = prevnonblank(a:lnum) +  while 1 +    let ccol = match(getline(lnum), '\*/') +    if ccol < 0 +      " No comment end thus it's something else. +      return lnum +    endif +    call cursor(lnum, ccol + 1) +    " Search back for the /* that starts the comment +    let lnum = search('/\*', 'bW', a:stopline) +    if indent(".") == virtcol(".") - 1 +      " The  found /* is at the start of the line. Now go back to the line +      " above it and again check if it is a comment. +      let lnum = prevnonblank(lnum - 1) +    else +      " /* is after something else, thus it's not a comment line. +      return lnum +    endif +  endwhile +endfunc "}}} + +" Check the number of {} and () in line "lnum". Return a dict with the counts. +func! HtmlIndent_CountBraces(lnum) +  "{{{ +  let brs = substitute(getline(a:lnum), '[''"].\{-}[''"]\|/\*.\{-}\*/\|/\*.*$\|[^{}()]', '', 'g') +  let c_open = 0 +  let c_close = 0 +  let p_open = 0 +  let p_close = 0 +  for brace in split(brs, '\zs') +    if brace == "{" +      let c_open += 1 +    elseif brace == "}" +      if c_open > 0 +        let c_open -= 1 +      else +        let c_close += 1 +      endif +    elseif brace == '(' +      let p_open += 1 +    elseif brace == ')' +      if p_open > 0 +        let p_open -= 1 +      else +        let p_close += 1 +      endif +    endif +  endfor +  return {'c_open': c_open, +        \ 'c_close': c_close, +        \ 'p_open': p_open, +        \ 'p_close': p_close} +endfunc "}}} + +" Return the indent for a comment: <!-- --> +func! s:Alien5() +  "{{{ +  let curtext = getline(v:lnum) +  if curtext =~ '^\s*\zs-->' +    " current line starts with end of comment, line up with comment start. +    call cursor(v:lnum, 0) +    let lnum = search('<!--', 'b') +    if lnum > 0 +      " TODO: what if <!-- is not at the start of the line? +      return indent(lnum) +    endif + +    " Strange, can't find it. +    return -1 +  endif + +  let prevlnum = prevnonblank(v:lnum - 1) +  let prevtext = getline(prevlnum) +  let idx = match(prevtext, '^\s*\zs<!--') +  if idx >= 0 +    " just below comment start, add a shiftwidth +    return idx + shiftwidth() +  endif + +  " Some files add 4 spaces just below a TODO line.  It's difficult to detect +  " the end of the TODO, so let's not do that. + +  " Align with the previous non-blank line. +  return indent(prevlnum) +endfunc "}}} + +" Return the indent for conditional comment: <!--[ ![endif]--> +func! s:Alien6() +  "{{{ +  let curtext = getline(v:lnum) +  if curtext =~ '\s*\zs<!\[endif\]-->' +    " current line starts with end of comment, line up with comment start. +    let lnum = search('<!--', 'bn') +    if lnum > 0 +      return indent(lnum) +    endif +  endif +  return b:hi_indent.baseindent + shiftwidth() +endfunc "}}} + +" When the "lnum" line ends in ">" find the line containing the matching "<". +func! HtmlIndent_FindTagStart(lnum) +  "{{{ +  " Avoids using the indent of a continuation line. +  " Moves the cursor. +  " Return two values: +  " - the matching line number or "lnum". +  " - a flag indicating whether we found the end of a tag. +  " This method is global so that HTML-like indenters can use it. +  " To avoid matching " > " or " < " inside a string require that the opening +  " "<" is followed by a word character +  let idx = match(getline(a:lnum), '\S>\s*$') +  if idx > 0 +    call cursor(a:lnum, idx) +    let lnum = searchpair('<\w', '' , '>', 'bW', '', max([a:lnum - b:html_indent_line_limit, 0])) +    if lnum > 0 +      return [lnum, 1] +    endif +  endif +  return [a:lnum, 0] +endfunc "}}} + +" Find the unclosed start tag from the current cursor position. +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:], '</\zs\w\+\(-\w\+\)*\ze') +  let start_lnum = searchpair('<' . tagname . '\>', '', '</' . tagname . '\>', 'bW') +  if start_lnum > 0 +    return start_lnum +  endif +  return 0 +endfunc "}}} + +" Moves the cursor from a "<" to the matching ">". +func! HtmlIndent_FindTagEnd() +  "{{{ +  " Call this with the cursor on the "<" of a start tag. +  " This will move the cursor to the ">" of the matching end tag or, when it's +  " 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\+\(-\w\+\)*\|!--', col('.')) +  if tagname == '!--' +    call search('--\zs>') +  elseif s:get_tag('/' . tagname) != 0 +    " tag with a closing tag, find matching "</tag>" +    call searchpair('<' . tagname, '', '</' . tagname . '\zs>', 'W', '', line('.') + b:html_indent_line_limit) +  else +    " self-closing tag, find the ">" +    call search('\S\zs>') +  endif +endfunc "}}} + +" Indenting inside a start tag. Return the correct indent or -1 if unknown. +func! s:InsideTag(foundHtmlString) +  "{{{ +  if a:foundHtmlString +    " Inside an attribute string. +    " Align with the previous line or use an external function. +    let lnum = v:lnum - 1 +    if lnum > 1 +      if exists('b:html_indent_tag_string_func') +        return b:html_indent_tag_string_func(lnum) +      endif +      return indent(lnum) +    endif +  endif + +  " Should be another attribute: " attr="val".  Align with the previous +  " attribute start. +  let lnum = v:lnum +  while lnum > 1 +    let lnum -= 1 +    let text = getline(lnum) +    " Find a match with one of these, align with "attr": +    "       attr= +    "  <tag attr= +    "  text<tag attr= +    "  <tag>text</tag>text<tag attr= +    " For long lines search for the first match, finding the last match +    " gets very slow. +    if len(text) < 300 +      let idx = match(text, '.*\s\zs[_a-zA-Z0-9-]\+="') +    else +      let idx = match(text, '\s\zs[_a-zA-Z0-9-]\+="') +    endif +    if idx == -1 +      let idx = match(text, '<\w\+\(-\w\+\)*\s\zs\w') +    endif +    if idx == -1 +      let idx = match(text, '<\w\+\(-\w\+\)*') +      if idx >= 0 +        let idx = idx + shiftwidth() +      endif +    endif +    if idx > 0 +      " Found the attribute.  TODO: assumes spaces, no Tabs. +      return idx +    endif +  endwhile +  return -1 +endfunc "}}} + +" THE MAIN INDENT FUNCTION. Return the amount of indent for v:lnum. +func! HtmlIndent() +  "{{{ +  if prevnonblank(v:lnum - 1) < 1 +    " First non-blank line has no indent. +    return 0 +  endif + +  let curtext = tolower(getline(v:lnum)) +  let indentunit = shiftwidth() + +  let b:hi_newstate = {} +  let b:hi_newstate.lnum = v:lnum + +  " When syntax HL is enabled, detect we are inside a tag.  Indenting inside +  " a tag works very differently. Do not do this when the line starts with +  " "<", it gets the "htmlTag" ID but we are not inside a tag then. +  if curtext !~ '^\s*<' +    normal! ^ +    let stack = synstack(v:lnum, col('.'))  " assumes there are no tabs +    let foundHtmlString = 0 +    for synid in reverse(stack) +      let name = synIDattr(synid, "name") +      if index(b:hi_insideStringNames, name) >= 0 +        let foundHtmlString = 1 +      elseif index(b:hi_insideTagNames, name) >= 0 +        " Yes, we are inside a tag. +        let indent = s:InsideTag(foundHtmlString) +        if indent >= 0 +          " Do not keep the state. TODO: could keep the block type. +          let b:hi_indent.lnum = 0 +          return indent +        endif +      endif +    endfor +  endif + +  " does the line start with a closing tag? +  let swendtag = match(curtext, '^\s*</') >= 0 + +  if prevnonblank(v:lnum - 1) == b:hi_indent.lnum && b:hi_lasttick == b:changedtick - 1 +    " use state (continue from previous line) +  else +    " start over (know nothing) +    let b:hi_indent = s:FreshState(v:lnum) +  endif + +  if b:hi_indent.block >= 2 +    " within block +    let endtag = s:endtags[b:hi_indent.block] +    let blockend = stridx(curtext, endtag) +    if blockend >= 0 +      " block ends here +      let b:hi_newstate.block = 0 +      " calc indent for REST OF LINE (may start more blocks): +      call s:CountTagsAndState(strpart(curtext, blockend + strlen(endtag))) +      if swendtag && b:hi_indent.block != 5 +        let indent = b:hi_indent.blocktagind + s:curind * indentunit +        let b:hi_newstate.baseindent = indent + s:nextrel * indentunit +      else +        let indent = s:Alien{b:hi_indent.block}() +        let b:hi_newstate.baseindent = b:hi_indent.blocktagind + s:nextrel * indentunit +      endif +    else +      " block continues +      " indent this line with alien method +      let indent = s:Alien{b:hi_indent.block}() +    endif +  else +    " not within a block - within usual html +    let b:hi_newstate.block = b:hi_indent.block +    if swendtag +      " The current line starts with an end tag, align with its start tag. +      call cursor(v:lnum, 1) +      let start_lnum = HtmlIndent_FindStartTag() +      if start_lnum > 0 +        " check for the line starting with something inside a tag: +        " <sometag               <- align here +        "    attr=val><open>     not here +        let text = getline(start_lnum) +        let angle = matchstr(text, '[<>]') +        if angle == '>' +          call cursor(start_lnum, 1) +          normal! f>% +          let start_lnum = line('.') +          let text = getline(start_lnum) +        endif + +        let indent = indent(start_lnum) +        if col('.') > 2 +          let swendtag = match(text, '^\s*</') >= 0 +          call s:CountITags(text[: col('.') - 2]) +          let indent += s:nextrel * shiftwidth() +          if !swendtag +            let indent += s:curind * shiftwidth() +          endif +        endif +      else +        " not sure what to do +        let indent = b:hi_indent.baseindent +      endif +      let b:hi_newstate.baseindent = indent +    else +      call s:CountTagsAndState(curtext) +      let indent = b:hi_indent.baseindent +      let b:hi_newstate.baseindent = indent + (s:curind + s:nextrel) * indentunit +    endif +  endif + +  let b:hi_lasttick = b:changedtick +  call extend(b:hi_indent, b:hi_newstate, "force") +  return indent +endfunc "}}} + +" Check user settings when loading this script the first time. +call HtmlIndent_CheckUserSettings() + +let &cpo = s:cpo_save +unlet s:cpo_save + +" vim: fdm=marker ts=8 sw=2 tw=78 + +endif diff --git a/after/syntax/html.vim b/after/syntax/html.vim index bc7e8eed..c02c02a3 100644 --- a/after/syntax/html.vim +++ b/after/syntax/html.vim @@ -2,11 +2,195 @@ if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'html5') == -1  " Vim syntax file  " Language:     HTML (version 5.1) -" Last Change:  2017 Feb 15 +"               SVG (SVG 1.1 Second Edition) +"               MathML (MathML 3.0 Second Edition) +" Last Change:  2017 Mar 07  " License:      Public domain  "               (but let me know if you like :) )  " +" Note: This file just add new tags from HTML 5 +"       and don't replace default html.vim syntax file +"  " Maintainer:   Kao, Wei-Ko(othree) ( othree AT gmail DOT com ) +" Changes:      update to Draft 2016 Jan 13 +"               add microdata Attributes +" Maintainer:   Rodrigo Machado <rcmachado@gmail.com> +" URL:          http://rm.blog.br/vim/syntax/html.vim +" Modified:     htdebeer <H.T.de.Beer@gmail.com> +" Changes:      add common SVG elements and attributes for inline SVG + +" Patch 7.4.1142 +if has("patch-7.4-1142") +  if has("win32") +    syn iskeyword @,48-57,_,128-167,224-235,- +  else +    syn iskeyword @,48-57,_,192-255,- +  endif +endif + +" HTML 5 tags +syn keyword htmlTagName contained article aside audio canvas command +syn keyword htmlTagName contained datalist details dialog embed figcaption figure footer +syn keyword htmlTagName contained header hgroup keygen main mark meter menu menuitem nav output +syn keyword htmlTagName contained progress ruby rt rp rb rtc section source summary time track video data +syn keyword htmlTagName contained template content shadow slot +syn keyword htmlTagName contained wbr bdi +syn keyword htmlTagName contained picture + +" SVG tags +" http://www.w3.org/TR/SVG/ +" as found in http://www.w3.org/TR/SVG/eltindex.html +syn keyword htmlTagName contained svg  +syn keyword htmlTagName contained altGlyph altGlyphDef altGlyphItem  +syn keyword htmlTagName contained animate animateColor animateMotion animateTransform  +syn keyword htmlTagName contained circle ellipse rect line polyline polygon image path +syn keyword htmlTagName contained clipPath color-profile cursor  +syn keyword htmlTagName contained defs desc g symbol view use switch foreignObject +syn keyword htmlTagName contained filter feBlend feColorMatrix feComponentTransfer feComposite feConvolveMatrix feDiffuseLighting feDisplacementMap feDistantLight feFlood feFuncA feFuncB feFuncG feFuncR feGaussianBlur feImage feMerge feMergeNode feMorphology feOffset fePointLight feSpecularLighting feSpotLight feTile feTurbulence  +syn keyword htmlTagName contained font font-face font-face-format font-face-name font-face-src font-face-uri  +syn keyword htmlTagName contained glyph glyphRef hkern  +syn keyword htmlTagName contained linearGradient marker mask pattern radialGradient set stop +syn keyword htmlTagName contained missing-glyph mpath  +syn keyword htmlTagName contained text textPath tref tspan vkern +syn keyword htmlTagName contained metadata title + +" MathML tags +" https://www.w3.org/TR/MathML3/appendixi.html#index.elem +syn keyword htmlTagName contained abs and annotation annotation-xml apply approx arccos arccosh arccot arccoth +syn keyword htmlTagName contained arccsc arccsch arcsec arcsech arcsin arcsinh arctan arctanh arg bind +syn keyword htmlTagName contained bvar card cartesianproduct cbytes ceiling cerror ci cn codomain complexes +syn keyword htmlTagName contained compose condition conjugate cos cosh cot coth cs csc csch +syn keyword htmlTagName contained csymbol curl declare degree determinant diff divergence divide domain domainofapplication +syn keyword htmlTagName contained emptyset eq equivalent eulergamma exists exp exponentiale factorial factorof false +syn keyword htmlTagName contained floor fn forall gcd geq grad gt ident image imaginary +syn keyword htmlTagName contained imaginaryi implies in infinity int integers intersect interval inverse lambda +syn keyword htmlTagName contained laplacian lcm leq limit list ln log logbase lowlimit lt +syn keyword htmlTagName contained maction maligngroup malignmark math matrix matrixrow max mean median menclose +syn keyword htmlTagName contained merror mfenced mfrac mglyph mi mi" min minus mlabeledtr mlongdiv +syn keyword htmlTagName contained mmultiscripts mn mo mode moment momentabout mover mpadded mphantom mprescripts +syn keyword htmlTagName contained mroot mrow ms mscarries mscarry msgroup msline mspace msqrt msrow +syn keyword htmlTagName contained mstack mstyle msub msubsup msup mtable mtd mtext mtr munder +syn keyword htmlTagName contained munderover naturalnumbers neq none not notanumber notin notprsubset notsubset or +syn keyword htmlTagName contained otherwise outerproduct partialdiff pi piece piecewise plus power primes product +syn keyword htmlTagName contained prsubset quotient rationals real reals reln rem root scalarproduct sdev +syn keyword htmlTagName contained sec sech selector semantics sep set setdiff share sin sinh +syn keyword htmlTagName contained span subset sum tan tanh tendsto times transpose true union +syn keyword htmlTagName contained uplimit variance vector vectorproduct xor + +" Custom Element +syn match htmlTagName contained "\<[a-z][-.0-9_a-z]*-[-.0-9_a-z]*\>" +syn match htmlTagName contained "[.0-9_a-z]\@<=-[-.0-9_a-z]*\>" + +" HTML 5 arguments +" Core Attributes +syn keyword htmlArg contained accesskey class contenteditable contextmenu dir  +syn keyword htmlArg contained draggable hidden id is lang spellcheck style tabindex title translate +" Event-handler Attributes +syn keyword htmlArg contained onabort onblur oncanplay oncanplaythrough onchange +syn keyword htmlArg contained onclick oncontextmenu ondblclick ondrag ondragend ondragenter ondragleave ondragover  +syn keyword htmlArg contained ondragstart ondrop ondurationchange onemptied onended onerror onfocus onformchange  +syn keyword htmlArg contained onforminput oninput oninvalid onkeydown onkeypress onkeyup onload onloadeddata  +syn keyword htmlArg contained onloadedmetadata onloadstart onmousedown onmousemove onmouseout onmouseover onmouseup +syn keyword htmlArg contained onmousewheel onpause onplay onplaying onprogress onratechange onreadystatechange  +syn keyword htmlArg contained onscroll onseeked onseeking onselect onshow onstalled onsubmit onsuspend ontimeupdate  +syn keyword htmlArg contained onvolumechange onwaiting +" XML Attributes +syn keyword htmlArg contained xml:lang xml:space xml:base xmlns +" new features +" <body> +syn keyword htmlArg contained onafterprint onbeforeprint onbeforeunload onblur onerror onfocus onhashchange onload  +syn keyword htmlArg contained onmessage onoffline ononline onpopstate onredo onresize onstorage onundo onunload +" <video>, <audio>, <source>, <track> +syn keyword htmlArg contained autoplay preload controls loop poster media kind charset srclang track playsinline +" <form>, <input>, <button> +syn keyword htmlArg contained form autocomplete autofocus list min max step +syn keyword htmlArg contained formaction autofocus formenctype formmethod formtarget formnovalidate +syn keyword htmlArg contained required placeholder pattern +" <command>, <details>, <time> +syn keyword htmlArg contained label icon open datetime-local pubdate +" <script> +syn keyword htmlArg contained async +" <content> +syn keyword htmlArg contained select +" <iframe> +syn keyword htmlArg contained seamless srcdoc sandbox allowfullscreen allowusermedia allowpaymentrequest allowpresentation +" <picture> +syn keyword htmlArg contained srcset sizes +" <a> +syn keyword htmlArg contained download media +" <script>, <style> +syn keyword htmlArg contained nonce +" <area>, <a>, <img>, <iframe>, <link> +syn keyword htmlArg contained referrerpolicy +" https://w3c.github.io/webappsec-subresource-integrity/#the-integrity-attribute +syn keyword htmlArg contained integrity crossorigin +" <link> +syn keyword htmlArg contained prefetch  +" syn keyword htmlArg contained preload +" <img> +syn keyword htmlArg contained decoding +" https://w3c.github.io/selection-api/#extensions-to-globaleventhandlers +syn keyword htmlArg contained onselectstart onselectionchange +" https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/loading +syn keyword htmlArg contained loading + +" Custom Data Attributes +" http://w3c.github.io/html/single-page.html#embedding-custom-non-visible-data-with-the-data-attributes +syn match   htmlArg "\<data[-.0-9_a-z]*-[-.0-9_a-z]*\>" contained + +" Vendor Extension Attributes +" http://w3c.github.io/html/single-page.html#conformance-requirements-extensibility +syn match   htmlArg "\<x[-.0-9_a-z]*-[-.0-9_a-z]*\>" contained + +" Microdata +" http://dev.w3.org/html5/md/ +syn keyword htmlArg contained itemid itemscope itemtype itemprop itemref + +" SVG +" http://www.w3.org/TR/SVG/ +" Some common attributes from http://www.w3.org/TR/SVG/attindex.html +syn keyword htmlArg contained accent-height accumulate additive alphabetic amplitude arabic-form ascent attributeName attributeType azimuth  +syn keyword htmlArg contained baseFrequency baseProfile bbox begin bias by  +syn keyword htmlArg contained calcMode cap-height class clipPathUnits contentScriptType contentStyleType cx cy  +syn keyword htmlArg contained d descent diffuseConstant divisor dur dx dy  +syn keyword htmlArg contained edgeMode elevation end exponent externalResourcesRequired  +syn keyword htmlArg contained fill filterRes filterUnits font-family font-size font-stretch font-style font-variant font-weight format format from fx fy  +syn keyword htmlArg contained g1 g2 glyph-name glyphRef gradientTransform gradientUnits  +syn keyword htmlArg contained hanging height horiz-adv-x horiz-origin-x horiz-origin-y  +syn keyword htmlArg contained id ideographic in in2 intercept  +syn keyword htmlArg contained k k1 k2 k3 k4 kernelMatrix kernelUnitLength keyPoints keySplines keyTimes  +syn keyword htmlArg contained lang lengthAdjust limitingConeAngle local  +syn keyword htmlArg contained markerHeight markerUnits markerWidth maskContentUnits maskUnits mathematical max media method min mode name  +syn keyword htmlArg contained numOctaves  +syn keyword htmlArg contained offset onabort onactivate onbegin onclick onend onerror onfocusin onfocusout onload onmousedown onmousemove onmouseout onmouseover onmouseup onrepeat onresize onscroll onunload onzoom operator order orient orientation origin overline-position overline-thickness  +syn keyword htmlArg contained panose-1 path pathLength patternContentUnits patternTransform patternUnits points pointsAtX pointsAtY pointsAtZ preserveAlpha preserveAspectRatio primitiveUnits  +syn keyword htmlArg contained r radius refX refY rendering-intent repeatCount repeatDur requiredExtensions requiredFeatures restart result rotate rx ry  +syn keyword htmlArg contained scale seed slope spacing specularConstant specularExponent spreadMethod startOffset stdDeviation stemh stemv stitchTiles strikethrough-position strikethrough-thickness string surfaceScale systemLanguage  +syn keyword htmlArg contained tableValues target targetX targetY textLength title to transform type +syn keyword htmlArg contained u1 u2 underline-position underline-thickness unicode unicode-range units-per-em  +syn keyword htmlArg contained v-alphabetic v-hanging v-ideographic v-mathematical values version vert-adv-y vert-origin-x vert-origin-y viewBox viewTarget  +syn keyword htmlArg contained width widths  +syn keyword htmlArg contained x x-height x1 x2 xChannelSelector xlink:actuate xlink:actuate xlink:arcrole xlink:href xlink:role xlink:show xlink:title xlink:type xml:base xml:lang xml:space  +syn keyword htmlArg contained y y1 y2 yChannelSelector  +syn keyword htmlArg contained z zoomAndPan  +syn keyword htmlArg contained alignment-baseline baseline-shift clip-path clip-rule clip color-interpolation-filters color-interpolation color-profile color-rendering color cursor direction display dominant-baseline enable-background fill-opacity fill-rule fill filter flood-color flood-opacity font-family font-size-adjust font-size font-stretch font-style font-variant font-weight glyph-orientation-horizontal glyph-orientation-vertical image-rendering kerning letter-spacing lighting-color marker-end marker-mid marker-start mask opacity overflow pointer-events shape-rendering stop-color stop-opacity stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width stroke text-anchor text-decoration text-rendering unicode-bidi visibility word-spacing writing-mode + +" MathML attributes +" https://www.w3.org/TR/MathML3/chapter2.html#interf.toplevel.atts +syn keyword htmlArg contained accent accentunder actiontype align alignmentscope altimg altimg-height altimg-valign altimg-width alttext +syn keyword htmlArg contained annotation-xml background base baseline bevelled cd cdgroup charalign charspacing close +syn keyword htmlArg contained closure color columnalign columnalignment columnlines columnspacing columnspan columnwidth crossout decimalpoint +syn keyword htmlArg contained definitionURL denomalign depth display displaystyle edge encoding equalcolumns equalrows fence +syn keyword htmlArg contained fontfamily fontsize fontstyle fontweight form frame framespacing groupalign height indentalign +syn keyword htmlArg contained indentalignfirst indentalignlast indentshift indentshiftfirst indentshiftlast indenttarget index infixlinebreakstyle integer largeop +syn keyword htmlArg contained leftoverhang length linebreak linebreakmultchar linebreakstyle lineleading linethickness location longdivstyle lquote +syn keyword htmlArg contained lspace ltr macros math mathbackground mathcolor mathsize mathvariant maxsize maxwidth +syn keyword htmlArg contained mediummathspace menclose minlabelspacing minsize mode movablelimits msgroup mslinethickness name nargs +syn keyword htmlArg contained newline notation numalign number occurrence open order other overflow position +syn keyword htmlArg contained rightoverhang role rowalign rowlines rowspacing rowspan rquote rspace schemaLocation scope +syn keyword htmlArg contained scriptlevel scriptminsize scriptsize scriptsizemultiplier selection separator separators shift side stackalign +syn keyword htmlArg contained stretchy subscriptshift superscriptshift symmetric thickmathspace thinmathspace type valign verythickmathspace verythinmathspace +syn keyword htmlArg contained veryverythickmathspace veryverythinmathspace voffset width xref  " Comment  " https://github.com/w3c/html/issues/694 diff --git a/syntax/html/aria.vim b/after/syntax/html/aria.vim index 0c555e6e..0c555e6e 100644 --- a/syntax/html/aria.vim +++ b/after/syntax/html/aria.vim diff --git a/syntax/html/electron.vim b/after/syntax/html/electron.vim index f51e1aef..f51e1aef 100644 --- a/syntax/html/electron.vim +++ b/after/syntax/html/electron.vim diff --git a/syntax/html/rdfa.vim b/after/syntax/html/rdfa.vim index d772d43c..d772d43c 100644 --- a/syntax/html/rdfa.vim +++ b/after/syntax/html/rdfa.vim diff --git a/syntax/javascript/html5.vim b/after/syntax/javascript/html5.vim index 42ab78ad..42ab78ad 100644 --- a/syntax/javascript/html5.vim +++ b/after/syntax/javascript/html5.vim diff --git a/ftdetect/polyglot.vim b/ftdetect/polyglot.vim index 791c4c0e..2f8cad97 100644 --- a/ftdetect/polyglot.vim +++ b/ftdetect/polyglot.vim @@ -118,6 +118,11 @@ augroup filetypedetect  " DO NOT EDIT CODE BELOW, IT IS GENERATED WITH MAKEFILE +if !has_key(s:disabled_packages, 'html') +  au! BufNewFile,BufRead,BufWritePost *.html call polyglot#detect#Html() +  au BufNewFile,BufRead *.htm,*.html.hl,*.inc,*.st,*.xht,*.xhtml setf html +endif +  if !has_key(s:disabled_packages, 'pullrequest')    au BufNewFile,BufRead PULLREQ_EDITMSG setf pullrequest  endif @@ -2197,11 +2202,6 @@ if !has_key(s:disabled_packages, 'i3')    au BufNewFile,BufRead *.i3.config,*.i3config,{.,}i3.config,{.,}i3config,i3.config,i3config setf i3config  endif -if !has_key(s:disabled_packages, 'html5') -  au! BufNewFile,BufRead,BufWritePost *.html call polyglot#detect#Html() -  au BufNewFile,BufRead *.htm,*.html.hl,*.inc,*.st,*.xht,*.xhtml setf html -endif -  if !has_key(s:disabled_packages, 'hive')    au BufNewFile,BufRead *.hql,*.q,*.ql setf hive  endif diff --git a/ftplugin/html.vim b/ftplugin/html.vim index 50cdb2ae..d65502be 100644 --- a/ftplugin/html.vim +++ b/ftplugin/html.vim @@ -1,13 +1,55 @@ -if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'html5') == -1 +if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'html') == -1 -" Maintainer:  	othree <othree@gmail.com> -" URL:		      http://github.com/othree/html5.vim -" Last Change:  2014-05-02 -" License:      MIT -" Changes:      Add - to keyword +" Vim filetype plugin file +" Language:	html +" Maintainer:	Dan Sharp <dwsharp at users dot sourceforge dot net> +" Last Changed: 20 Jan 2009 +" URL:		http://dwsharp.users.sourceforge.net/vim/ftplugin -" setlocal iskeyword+=- +if exists("b:did_ftplugin") | finish | endif +let b:did_ftplugin = 1 +" Make sure the continuation lines below do not cause problems in +" compatibility mode. +let s:save_cpo = &cpo +set cpo-=C + +setlocal matchpairs+=<:>  setlocal commentstring=<!--%s--> +setlocal comments=s:<!--,m:\ \ \ \ ,e:--> + +if exists("g:ft_html_autocomment") && (g:ft_html_autocomment == 1) +    setlocal formatoptions-=t formatoptions+=croql +endif + +if exists('&omnifunc') +  setlocal omnifunc=htmlcomplete#CompleteTags +  call htmlcomplete#DetectOmniFlavor() +endif + +" HTML:  thanks to Johannes Zellner and Benji Fisher. +if exists("loaded_matchit") +    let b:match_ignorecase = 1 +    let b:match_words = '<:>,' . +    \ '<\@<=[ou]l\>[^>]*\%(>\|$\):<\@<=li\>:<\@<=/[ou]l>,' . +    \ '<\@<=dl\>[^>]*\%(>\|$\):<\@<=d[td]\>:<\@<=/dl>,' . +    \ '<\@<=\([^/][^ \t>]*\)[^>]*\%(>\|$\):<\@<=/\1>' +endif + +" Change the :browse e filter to primarily show HTML-related files. +if has("gui_win32") +    let  b:browsefilter="HTML Files (*.html,*.htm)\t*.htm;*.html\n" . +		\	"JavaScript Files (*.js)\t*.js\n" . +		\	"Cascading StyleSheets (*.css)\t*.css\n" . +		\	"All Files (*.*)\t*.*\n" +endif + +" Undo the stuff we changed. +let b:undo_ftplugin = "setlocal commentstring< matchpairs< omnifunc< comments< formatoptions<" . +    \	" | unlet! b:match_ignorecase b:match_skip b:match_words b:browsefilter" + +" Restore the saved compatibility options. +let &cpo = s:save_cpo +unlet s:save_cpo  endif diff --git a/indent/html.vim b/indent/html.vim index 3b9c7eb4..1e56c85e 100644 --- a/indent/html.vim +++ b/indent/html.vim @@ -1,11 +1,10 @@ -if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'html5') == -1 +if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'html') == -1  " Vim indent script for HTML -" Header: "{{{  " Maintainer:	Bram Moolenaar  " Original Author: Andy Wokula <anwoku@yahoo.de> -" Last Change:	2017 Jun 13 -" Version:	1.0 +" Last Change:	2020 Jul 06 +" Version:	1.0 "{{{  " Description:	HTML indent script with cached state for faster indenting on a  "		range of lines.  "		Supports template systems through hooks. @@ -58,6 +57,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 @@ -216,25 +218,27 @@ endfunc "}}}  " Self-closing tags and tags that are sometimes {{{  " self-closing (e.g., <p>) are not here (when encountering </p> we can find  " the matching <p>, but not the other way around). +" Known self-closing tags: " 'p', 'img', 'source', 'area', 'keygen', 'track', +" 'wbr'.  " 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', +    \ 'colgroup', 'dd', 'del', 'dfn', 'dir', 'div', 'dl', 'dt', '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', +    \ 'optgroup', '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']) +    \ 'article', 'aside', 'audio', 'bdi', 'canvas', 'command', 'data', +    \ 'datalist', 'details', 'dialog', 'embed', 'figcaption', 'figure', +    \ 'footer', 'header', 'hgroup', 'main', 'mark', 'meter', 'nav', 'output', +    \ 'picture', 'progress', 'rp', 'rt', 'ruby', 'section', 'summary', +    \ 'svg', 'time', 'video'])  " Tags added for web components:  call s:AddITags(s:indent_tags, [ @@ -282,7 +286,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\+\)*\>\|<!--\[\|\[endif\]-->\|<!--\|-->', '\=s:CheckTag(submatch(0))', 'g') +  call substitute(a:text, '<\zs/\=' . s:tagname . '\>\|<!--\[\|\[endif\]-->\|<!--\|-->', '\=s:CheckTag(submatch(0))', 'g')    let s:countonly = 0  endfunc "}}} @@ -294,7 +298,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\+\)*\>\|<!--\[\|\[endif\]-->\|<!--\|-->', '\=s:CheckTag(submatch(0))', 'g') +  let tmp = substitute(a:text, '<\zs/\=' . s:tagname . '\>\|<!--\[\|\[endif\]-->\|<!--\|-->', '\=s:CheckTag(submatch(0))', 'g')    if s:block == 3      let b:hi_newstate.scripttype = s:GetScriptType(matchstr(tmp, '\C.*<SCRIPT\>\zs[^>]*'))    endif @@ -532,7 +536,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 =~ '</\w\+\s*>\s*$' +  if !swendtag && text =~ '</' . s:tagname . '\s*>\s*$'      call cursor(state.lnum, 99999)      normal! F<      let start_lnum = HtmlIndent_FindStartTag() @@ -584,7 +588,7 @@ func! s:Alien3()      return eval(b:hi_js1indent)    endif    if b:hi_indent.scripttype == "javascript" -    return GetJavascriptIndent() +    return eval(b:hi_js1indent) + GetJavascriptIndent()    else      return -1    endif @@ -623,7 +627,7 @@ func! s:CSSIndent()      return eval(b:hi_css1indent)    endif -  " If the current line starts with "}" align with it's match. +  " If the current line starts with "}" align with its match.    if curtext =~ '^\s*}'      call cursor(v:lnum, 1)      try @@ -661,7 +665,7 @@ func! s:CSSIndent()      else        let cur_hasfield = curtext =~ '^\s*[a-zA-Z0-9-]\+:'        let prev_unfinished = s:CssUnfinished(prev_text) -      if !cur_hasfield && (prev_hasfield || prev_unfinished) +      if prev_unfinished          " Continuation line has extra indent if the previous line was not a          " continuation line.          let extra = shiftwidth() @@ -714,9 +718,13 @@ func! s:CSSIndent()  endfunc "}}}  " Inside <style>: Whether a line is unfinished. +" 	tag: +" 	tag: blah +" 	tag: blah && +" 	tag: blah ||  func! s:CssUnfinished(text)    "{{{ -  return a:text =~ '\s\(||\|&&\|:\)\s*$' +  return a:text =~ '\(||\|&&\|:\|\k\)\s*$'  endfunc "}}}  " Search back for the first unfinished line above "lnum". @@ -843,11 +851,12 @@ func! HtmlIndent_FindTagStart(lnum)    " - a flag indicating whether we found the end of a tag.    " This method is global so that HTML-like indenters can use it.    " To avoid matching " > " or " < " inside a string require that the opening -  " "<" is followed by a word character +  " "<" is followed by a word character and the closing ">" comes after a +  " non-white character.    let idx = match(getline(a:lnum), '\S>\s*$')    if idx > 0      call cursor(a:lnum, idx) -    let lnum = searchpair('<\w', '' , '>', 'bW', '', max([a:lnum - b:html_indent_line_limit, 0])) +    let lnum = searchpair('<\w', '' , '\S>', 'bW', '', max([a:lnum - b:html_indent_line_limit, 0]))      if lnum > 0        return [lnum, 1]      endif @@ -861,7 +870,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:], '</\zs\w\+\(-\w\+\)*\ze') +  let tagname = matchstr(getline('.')[col('.') - 1:], '</\zs' . s:tagname . '\ze')    let start_lnum = searchpair('<' . tagname . '\>', '', '</' . tagname . '\>', 'bW')    if start_lnum > 0      return start_lnum @@ -877,7 +886,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\+\(-\w\+\)*\|!--', col('.')) +  let tagname = matchstr(text, s:tagname . '\|!--', col('.'))    if tagname == '!--'      call search('--\zs>')    elseif s:get_tag('/' . tagname) != 0 @@ -894,12 +903,19 @@ func! s:InsideTag(foundHtmlString)    "{{{    if a:foundHtmlString      " Inside an attribute string. -    " Align with the previous line or use an external function. +    " Align with the opening quote or use an external function.      let lnum = v:lnum - 1      if lnum > 1        if exists('b:html_indent_tag_string_func')          return b:html_indent_tag_string_func(lnum)        endif +      " If there is a double quote in the previous line, indent with the +      " character after it. +      if getline(lnum) =~ '"' +	call cursor(lnum, 0) +	normal f" +	return virtcol('.') +      endif        return indent(lnum)      endif    endif @@ -923,17 +939,21 @@ func! s:InsideTag(foundHtmlString)        let idx = match(text, '\s\zs[_a-zA-Z0-9-]\+="')      endif      if idx == -1 -      let idx = match(text, '<\w\+\(-\w\+\)*\s\zs\w') +      " try <tag attr +      let idx = match(text, '<' . s:tagname . '\s\+\zs\w')      endif      if idx == -1 -      let idx = match(text, '<\w\+\(-\w\+\)*') +      " after just "<tag" indent one level more +      let idx = match(text, '<' . s:tagname . '$')        if idx >= 0 -        let idx = idx + shiftwidth() +	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 diff --git a/packages.yaml b/packages.yaml index e8a136fa..e160bfd6 100644 --- a/packages.yaml +++ b/packages.yaml @@ -792,13 +792,6 @@ filetypes:    extra_extensions:    - ql  --- -# TODO: change after https://github.com/othree/html5.vim/pull/106 is merged -name: html5 -remote: sheerun/html5.vim -filetypes: -- name: html -  linguist: HTML ----  name: i3  remote: mboughaba/i3config.vim  filetypes: @@ -5485,3 +5478,16 @@ remote: vim/vim:runtime  glob: "**/autodoc.vim"  # Needed by c, cmod, and pike  filetypes: [] +--- +name: html +remote: vim/vim:runtime +glob: "**/html.vim" +filetypes: +- name: html +  linguist: HTML +--- +# TODO: change after https://github.com/othree/html5.vim/pull/106 is merged +name: html5 +remote: sheerun/html5.vim +dependencies: html +filetypes: [] diff --git a/syntax/html.vim b/syntax/html.vim index 43db7575..a04b4c90 100644 --- a/syntax/html.vim +++ b/syntax/html.vim @@ -1,23 +1,15 @@ -if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'html5') == -1 +if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'html') == -1  " Vim syntax file -" Language:     HTML (version 5.1) -"               SVG (SVG 1.1 Second Edition) -"               MathML (MathML 3.0 Second Edition) -" Last Change:  2017 Mar 07 -" License:      Public domain -"               (but let me know if you like :) ) +" Language:             HTML +" Maintainer:           Jorge Maldonado Ventura <jorgesumle@freakspot.net> +" Previous Maintainer:  Claudio Fleiner <claudio@fleiner.com> +" Repository:           https://notabug.org/jorgesumle/vim-html-syntax +" Last Change:          2020 Mar 17 +" Included patch from Florian Breisch to add the summary element  " -" Note: This file just add new tags from HTML 5 -"       and don't replace default html.vim syntax file -" -" Maintainer:   Kao, Wei-Ko(othree) ( othree AT gmail DOT com ) -" Changes:      update to Draft 2016 Jan 13 -"               add microdata Attributes -" Maintainer:   Rodrigo Machado <rcmachado@gmail.com> -" URL:          http://rm.blog.br/vim/syntax/html.vim -" Modified:     htdebeer <H.T.de.Beer@gmail.com> -" Changes:      add common SVG elements and attributes for inline SVG + +" Please check :help html.vim for some comments and a description of the options  " quit when a syntax file was already loaded  if !exists("main_syntax") @@ -30,178 +22,312 @@ endif  let s:cpo_save = &cpo  set cpo&vim -" Patch 7.4.1142 -if has("patch-7.4-1142") -  if has("win32") -    syn iskeyword @,48-57,_,128-167,224-235,- +syntax spell toplevel + +syn case ignore + +" mark illegal characters +syn match htmlError "[<>&]" + + +" tags +syn region  htmlString   contained start=+"+ end=+"+ contains=htmlSpecialChar,javaScriptExpression,@htmlPreproc +syn region  htmlString   contained start=+'+ end=+'+ contains=htmlSpecialChar,javaScriptExpression,@htmlPreproc +syn match   htmlValue    contained "=[\t ]*[^'" \t>][^ \t>]*"hs=s+1   contains=javaScriptExpression,@htmlPreproc +syn region  htmlEndTag             start=+</+      end=+>+ contains=htmlTagN,htmlTagError +syn region  htmlTag                start=+<[^/]+   end=+>+ fold contains=htmlTagN,htmlString,htmlArg,htmlValue,htmlTagError,htmlEvent,htmlCssDefinition,@htmlPreproc,@htmlArgCluster +syn match   htmlTagN     contained +<\s*[-a-zA-Z0-9]\++hs=s+1 contains=htmlTagName,htmlSpecialTagName,@htmlTagNameCluster +syn match   htmlTagN     contained +</\s*[-a-zA-Z0-9]\++hs=s+2 contains=htmlTagName,htmlSpecialTagName,@htmlTagNameCluster +syn match   htmlTagError contained "[^>]<"ms=s+1 + + +" tag names +syn keyword htmlTagName contained address applet area a base basefont +syn keyword htmlTagName contained big blockquote br caption center +syn keyword htmlTagName contained cite code dd dfn dir div dl dt font +syn keyword htmlTagName contained form hr html img +syn keyword htmlTagName contained input isindex kbd li link map menu +syn keyword htmlTagName contained meta ol option param pre p samp span +syn keyword htmlTagName contained select small sub sup +syn keyword htmlTagName contained table td textarea th tr tt ul var xmp +syn match htmlTagName contained "\<\(b\|i\|u\|h[1-6]\|em\|strong\|head\|body\|title\)\>" + +" new html 4.0 tags +syn keyword htmlTagName contained abbr acronym bdo button col label +syn keyword htmlTagName contained colgroup fieldset iframe ins legend +syn keyword htmlTagName contained object optgroup q s tbody tfoot thead + +" new html 5 tags +syn keyword htmlTagName contained article aside audio bdi canvas data +syn keyword htmlTagName contained datalist details dialog embed figcaption +syn keyword htmlTagName contained figure footer header hgroup keygen main +syn keyword htmlTagName contained mark menuitem meter nav output picture +syn keyword htmlTagName contained progress rb rp rt rtc ruby section +syn keyword htmlTagName contained slot source summary template time track +syn keyword htmlTagName contained video wbr + +" legal arg names +syn keyword htmlArg contained action +syn keyword htmlArg contained align alink alt archive background bgcolor +syn keyword htmlArg contained border bordercolor cellpadding +syn keyword htmlArg contained cellspacing checked class clear code codebase color +syn keyword htmlArg contained cols colspan content coords enctype face +syn keyword htmlArg contained gutter height hspace id +syn keyword htmlArg contained link lowsrc marginheight +syn keyword htmlArg contained marginwidth maxlength method name prompt +syn keyword htmlArg contained rel rev rows rowspan scrolling selected shape +syn keyword htmlArg contained size src start target text type url +syn keyword htmlArg contained usemap ismap valign value vlink vspace width wrap +syn match   htmlArg contained "\<\(http-equiv\|href\|title\)="me=e-1 + +" aria attributes +syn match htmlArg contained "\<\(aria-activedescendant\|aria-atomic\)\>" +syn match htmlArg contained "\<\(aria-autocomplete\|aria-busy\|aria-checked\)\>" +syn match htmlArg contained "\<\(aria-colcount\|aria-colindex\|aria-colspan\)\>" +syn match htmlArg contained "\<\(aria-controls\|aria-current\)\>" +syn match htmlArg contained "\<\(aria-describedby\|aria-details\)\>" +syn match htmlArg contained "\<\(aria-disabled\|aria-dropeffect\)\>" +syn match htmlArg contained "\<\(aria-errormessage\|aria-expanded\)\>" +syn match htmlArg contained "\<\(aria-flowto\|aria-grabbed\|aria-haspopup\)\>" +syn match htmlArg contained "\<\(aria-hidden\|aria-invalid\)\>" +syn match htmlArg contained "\<\(aria-keyshortcuts\|aria-label\)\>" +syn match htmlArg contained "\<\(aria-labelledby\|aria-level\|aria-live\)\>" +syn match htmlArg contained "\<\(aria-modal\|aria-multiline\)\>" +syn match htmlArg contained "\<\(aria-multiselectable\|aria-orientation\)\>" +syn match htmlArg contained "\<\(aria-owns\|aria-placeholder\|aria-posinset\)\>" +syn match htmlArg contained "\<\(aria-pressed\|aria-readonly\|aria-relevant\)\>" +syn match htmlArg contained "\<\(aria-required\|aria-roledescription\)\>" +syn match htmlArg contained "\<\(aria-rowcount\|aria-rowindex\|aria-rowspan\)\>" +syn match htmlArg contained "\<\(aria-selected\|aria-setsize\|aria-sort\)\>" +syn match htmlArg contained "\<\(aria-valuemax\|aria-valuemin\)\>" +syn match htmlArg contained "\<\(aria-valuenow\|aria-valuetext\)\>" +syn keyword htmlArg contained role + +" Netscape extensions +syn keyword htmlTagName contained frame noframes frameset nobr blink +syn keyword htmlTagName contained layer ilayer nolayer spacer +syn keyword htmlArg     contained frameborder noresize pagex pagey above below +syn keyword htmlArg     contained left top visibility clip id noshade +syn match   htmlArg     contained "\<z-index\>" + +" Microsoft extensions +syn keyword htmlTagName contained marquee + +" html 4.0 arg names +syn match   htmlArg contained "\<\(accept-charset\|label\)\>" +syn keyword htmlArg contained abbr accept accesskey axis char charoff charset +syn keyword htmlArg contained cite classid codetype compact data datetime +syn keyword htmlArg contained declare defer dir disabled for frame +syn keyword htmlArg contained headers hreflang lang language longdesc +syn keyword htmlArg contained multiple nohref nowrap object profile readonly +syn keyword htmlArg contained rules scheme scope span standby style +syn keyword htmlArg contained summary tabindex valuetype version + +" html 5 arg names +syn keyword htmlArg contained allowfullscreen async autocomplete autofocus +syn keyword htmlArg contained autoplay challenge contenteditable contextmenu +syn keyword htmlArg contained controls crossorigin default dirname download +syn keyword htmlArg contained draggable dropzone form formaction formenctype +syn keyword htmlArg contained formmethod formnovalidate formtarget hidden +syn keyword htmlArg contained high icon inputmode keytype kind list loop low +syn keyword htmlArg contained max min minlength muted nonce novalidate open +syn keyword htmlArg contained optimum pattern placeholder poster preload +syn keyword htmlArg contained radiogroup required reversed sandbox spellcheck +syn keyword htmlArg contained sizes srcset srcdoc srclang step title translate +syn keyword htmlArg contained typemustmatch + +" special characters +syn match htmlSpecialChar "&#\=[0-9A-Za-z]\{1,8};" + +" Comments (the real ones or the old netscape ones) +if exists("html_wrong_comments") +  syn region htmlComment                start=+<!--+    end=+--\s*>+ contains=@Spell +else +  syn region htmlComment                start=+<!+      end=+>+   contains=htmlCommentPart,htmlCommentError,@Spell +  syn match  htmlCommentError contained "[^><!]" +  syn region htmlCommentPart  contained start=+--+      end=+--\s*+  contains=@htmlPreProc,@Spell +endif +syn region htmlComment                  start=+<!DOCTYPE+ keepend end=+>+ + +" server-parsed commands +syn region htmlPreProc start=+<!--#+ end=+-->+ contains=htmlPreStmt,htmlPreError,htmlPreAttr +syn match htmlPreStmt contained "<!--#\(config\|echo\|exec\|fsize\|flastmod\|include\|printenv\|set\|if\|elif\|else\|endif\|geoguide\)\>" +syn match htmlPreError contained "<!--#\S*"ms=s+4 +syn match htmlPreAttr contained "\w\+=[^"]\S\+" contains=htmlPreProcAttrError,htmlPreProcAttrName +syn region htmlPreAttr contained start=+\w\+="+ skip=+\\\\\|\\"+ end=+"+ contains=htmlPreProcAttrName keepend +syn match htmlPreProcAttrError contained "\w\+="he=e-1 +syn match htmlPreProcAttrName contained "\(expr\|errmsg\|sizefmt\|timefmt\|var\|cgi\|cmd\|file\|virtual\|value\)="he=e-1 + +if !exists("html_no_rendering") +  " rendering +  syn cluster htmlTop contains=@Spell,htmlTag,htmlEndTag,htmlSpecialChar,htmlPreProc,htmlComment,htmlLink,javaScript,@htmlPreproc + +  syn region htmlStrike start="<del\>" end="</del\_s*>"me=s-1 contains=@htmlTop +  syn region htmlStrike start="<strike\>" end="</strike\_s*>"me=s-1 contains=@htmlTop + +  syn region htmlBold start="<b\>" end="</b\_s*>"me=s-1 contains=@htmlTop,htmlBoldUnderline,htmlBoldItalic +  syn region htmlBold start="<strong\>" end="</strong\_s*>"me=s-1 contains=@htmlTop,htmlBoldUnderline,htmlBoldItalic +  syn region htmlBoldUnderline contained start="<u\>" end="</u\_s*>"me=s-1 contains=@htmlTop,htmlBoldUnderlineItalic +  syn region htmlBoldItalic contained start="<i\>" end="</i\_s*>"me=s-1 contains=@htmlTop,htmlBoldItalicUnderline +  syn region htmlBoldItalic contained start="<em\>" end="</em\_s*>"me=s-1 contains=@htmlTop,htmlBoldItalicUnderline +  syn region htmlBoldUnderlineItalic contained start="<i\>" end="</i\_s*>"me=s-1 contains=@htmlTop +  syn region htmlBoldUnderlineItalic contained start="<em\>" end="</em\_s*>"me=s-1 contains=@htmlTop +  syn region htmlBoldItalicUnderline contained start="<u\>" end="</u\_s*>"me=s-1 contains=@htmlTop,htmlBoldUnderlineItalic + +  syn region htmlUnderline start="<u\>" end="</u\_s*>"me=s-1 contains=@htmlTop,htmlUnderlineBold,htmlUnderlineItalic +  syn region htmlUnderlineBold contained start="<b\>" end="</b\_s*>"me=s-1 contains=@htmlTop,htmlUnderlineBoldItalic +  syn region htmlUnderlineBold contained start="<strong\>" end="</strong\_s*>"me=s-1 contains=@htmlTop,htmlUnderlineBoldItalic +  syn region htmlUnderlineItalic contained start="<i\>" end="</i\_s*>"me=s-1 contains=@htmlTop,htmlUnderlineItalicBold +  syn region htmlUnderlineItalic contained start="<em\>" end="</em\_s*>"me=s-1 contains=@htmlTop,htmlUnderlineItalicBold +  syn region htmlUnderlineItalicBold contained start="<b\>" end="</b\_s*>"me=s-1 contains=@htmlTop +  syn region htmlUnderlineItalicBold contained start="<strong\>" end="</strong\_s*>"me=s-1 contains=@htmlTop +  syn region htmlUnderlineBoldItalic contained start="<i\>" end="</i\_s*>"me=s-1 contains=@htmlTop +  syn region htmlUnderlineBoldItalic contained start="<em\>" end="</em\_s*>"me=s-1 contains=@htmlTop + +  syn region htmlItalic start="<i\>" end="</i\_s*>"me=s-1 contains=@htmlTop,htmlItalicBold,htmlItalicUnderline +  syn region htmlItalic start="<em\>" end="</em\_s*>"me=s-1 contains=@htmlTop +  syn region htmlItalicBold contained start="<b\>" end="</b\_s*>"me=s-1 contains=@htmlTop,htmlItalicBoldUnderline +  syn region htmlItalicBold contained start="<strong\>" end="</strong\_s*>"me=s-1 contains=@htmlTop,htmlItalicBoldUnderline +  syn region htmlItalicBoldUnderline contained start="<u\>" end="</u\_s*>"me=s-1 contains=@htmlTop +  syn region htmlItalicUnderline contained start="<u\>" end="</u\_s*>"me=s-1 contains=@htmlTop,htmlItalicUnderlineBold +  syn region htmlItalicUnderlineBold contained start="<b\>" end="</b\_s*>"me=s-1 contains=@htmlTop +  syn region htmlItalicUnderlineBold contained start="<strong\>" end="</strong\_s*>"me=s-1 contains=@htmlTop + +  syn match htmlLeadingSpace "^\s\+" contained +  syn region htmlLink start="<a\>\_[^>]*\<href\>" end="</a\_s*>"me=s-1 contains=@Spell,htmlTag,htmlEndTag,htmlSpecialChar,htmlPreProc,htmlComment,htmlLeadingSpace,javaScript,@htmlPreproc +  syn region htmlH1 start="<h1\>" end="</h1\_s*>"me=s-1 contains=@htmlTop +  syn region htmlH2 start="<h2\>" end="</h2\_s*>"me=s-1 contains=@htmlTop +  syn region htmlH3 start="<h3\>" end="</h3\_s*>"me=s-1 contains=@htmlTop +  syn region htmlH4 start="<h4\>" end="</h4\_s*>"me=s-1 contains=@htmlTop +  syn region htmlH5 start="<h5\>" end="</h5\_s*>"me=s-1 contains=@htmlTop +  syn region htmlH6 start="<h6\>" end="</h6\_s*>"me=s-1 contains=@htmlTop +  syn region htmlHead start="<head\>" end="</head\_s*>"me=s-1 end="<body\>"me=s-1 end="<h[1-6]\>"me=s-1 contains=htmlTag,htmlEndTag,htmlSpecialChar,htmlPreProc,htmlComment,htmlLink,htmlTitle,javaScript,cssStyle,@htmlPreproc +  syn region htmlTitle start="<title\>" end="</title\_s*>"me=s-1 contains=htmlTag,htmlEndTag,htmlSpecialChar,htmlPreProc,htmlComment,javaScript,@htmlPreproc +endif + +syn keyword htmlTagName         contained noscript +syn keyword htmlSpecialTagName  contained script style +if main_syntax != 'java' || exists("java_javascript") +  " JAVA SCRIPT +  syn include @htmlJavaScript syntax/javascript.vim +  unlet b:current_syntax +  syn region  javaScript start=+<script\_[^>]*>+ keepend end=+</script\_[^>]*>+me=s-1 contains=@htmlJavaScript,htmlCssStyleComment,htmlScriptTag,@htmlPreproc +  syn region  htmlScriptTag     contained start=+<script+ end=+>+ fold contains=htmlTagN,htmlString,htmlArg,htmlValue,htmlTagError,htmlEvent +  hi def link htmlScriptTag htmlTag + +  " html events (i.e. arguments that include javascript commands) +  if exists("html_extended_events") +    syn region htmlEvent        contained start=+\<on\a\+\s*=[\t ]*'+ end=+'+ contains=htmlEventSQ +    syn region htmlEvent        contained start=+\<on\a\+\s*=[\t ]*"+ end=+"+ contains=htmlEventDQ    else -    syn iskeyword @,48-57,_,192-255,- +    syn region htmlEvent        contained start=+\<on\a\+\s*=[\t ]*'+ end=+'+ keepend contains=htmlEventSQ +    syn region htmlEvent        contained start=+\<on\a\+\s*=[\t ]*"+ end=+"+ keepend contains=htmlEventDQ    endif +  syn region htmlEventSQ        contained start=+'+ms=s+1 end=+'+me=s-1 contains=@htmlJavaScript +  syn region htmlEventDQ        contained start=+"+ms=s+1 end=+"+me=s-1 contains=@htmlJavaScript +  hi def link htmlEventSQ htmlEvent +  hi def link htmlEventDQ htmlEvent + +  " a javascript expression is used as an arg value +  syn region  javaScriptExpression contained start=+&{+ keepend end=+};+ contains=@htmlJavaScript,@htmlPreproc +endif + +if main_syntax != 'java' || exists("java_vb") +  " VB SCRIPT +  syn include @htmlVbScript syntax/vb.vim +  unlet b:current_syntax +  syn region  javaScript start=+<script \_[^>]*language *=\_[^>]*vbscript\_[^>]*>+ keepend end=+</script\_[^>]*>+me=s-1 contains=@htmlVbScript,htmlCssStyleComment,htmlScriptTag,@htmlPreproc  endif -" HTML 5 tags -syn keyword htmlTagName contained article aside audio canvas command -syn keyword htmlTagName contained datalist details dialog embed figcaption figure footer -syn keyword htmlTagName contained header hgroup keygen main mark meter menu menuitem nav output -syn keyword htmlTagName contained progress ruby rt rp rb rtc section source summary time track video data -syn keyword htmlTagName contained template content shadow slot -syn keyword htmlTagName contained wbr bdi -syn keyword htmlTagName contained picture - -" SVG tags -" http://www.w3.org/TR/SVG/ -" as found in http://www.w3.org/TR/SVG/eltindex.html -syn keyword htmlTagName contained svg  -syn keyword htmlTagName contained altGlyph altGlyphDef altGlyphItem  -syn keyword htmlTagName contained animate animateColor animateMotion animateTransform  -syn keyword htmlTagName contained circle ellipse rect line polyline polygon image path -syn keyword htmlTagName contained clipPath color-profile cursor  -syn keyword htmlTagName contained defs desc g symbol view use switch foreignObject -syn keyword htmlTagName contained filter feBlend feColorMatrix feComponentTransfer feComposite feConvolveMatrix feDiffuseLighting feDisplacementMap feDistantLight feFlood feFuncA feFuncB feFuncG feFuncR feGaussianBlur feImage feMerge feMergeNode feMorphology feOffset fePointLight feSpecularLighting feSpotLight feTile feTurbulence  -syn keyword htmlTagName contained font font-face font-face-format font-face-name font-face-src font-face-uri  -syn keyword htmlTagName contained glyph glyphRef hkern  -syn keyword htmlTagName contained linearGradient marker mask pattern radialGradient set stop -syn keyword htmlTagName contained missing-glyph mpath  -syn keyword htmlTagName contained text textPath tref tspan vkern -syn keyword htmlTagName contained metadata title - -" MathML tags -" https://www.w3.org/TR/MathML3/appendixi.html#index.elem -syn keyword htmlTagName contained abs and annotation annotation-xml apply approx arccos arccosh arccot arccoth -syn keyword htmlTagName contained arccsc arccsch arcsec arcsech arcsin arcsinh arctan arctanh arg bind -syn keyword htmlTagName contained bvar card cartesianproduct cbytes ceiling cerror ci cn codomain complexes -syn keyword htmlTagName contained compose condition conjugate cos cosh cot coth cs csc csch -syn keyword htmlTagName contained csymbol curl declare degree determinant diff divergence divide domain domainofapplication -syn keyword htmlTagName contained emptyset eq equivalent eulergamma exists exp exponentiale factorial factorof false -syn keyword htmlTagName contained floor fn forall gcd geq grad gt ident image imaginary -syn keyword htmlTagName contained imaginaryi implies in infinity int integers intersect interval inverse lambda -syn keyword htmlTagName contained laplacian lcm leq limit list ln log logbase lowlimit lt -syn keyword htmlTagName contained maction maligngroup malignmark math matrix matrixrow max mean median menclose -syn keyword htmlTagName contained merror mfenced mfrac mglyph mi mi" min minus mlabeledtr mlongdiv -syn keyword htmlTagName contained mmultiscripts mn mo mode moment momentabout mover mpadded mphantom mprescripts -syn keyword htmlTagName contained mroot mrow ms mscarries mscarry msgroup msline mspace msqrt msrow -syn keyword htmlTagName contained mstack mstyle msub msubsup msup mtable mtd mtext mtr munder -syn keyword htmlTagName contained munderover naturalnumbers neq none not notanumber notin notprsubset notsubset or -syn keyword htmlTagName contained otherwise outerproduct partialdiff pi piece piecewise plus power primes product -syn keyword htmlTagName contained prsubset quotient rationals real reals reln rem root scalarproduct sdev -syn keyword htmlTagName contained sec sech selector semantics sep set setdiff share sin sinh -syn keyword htmlTagName contained span subset sum tan tanh tendsto times transpose true union -syn keyword htmlTagName contained uplimit variance vector vectorproduct xor - -" Custom Element -syn match htmlTagName contained "\<[a-z][-.0-9_a-z]*-[-.0-9_a-z]*\>" -syn match htmlTagName contained "[.0-9_a-z]\@<=-[-.0-9_a-z]*\>" - -" HTML 5 arguments -" Core Attributes -syn keyword htmlArg contained accesskey class contenteditable contextmenu dir  -syn keyword htmlArg contained draggable hidden id is lang spellcheck style tabindex title translate -" Event-handler Attributes -syn keyword htmlArg contained onabort onblur oncanplay oncanplaythrough onchange -syn keyword htmlArg contained onclick oncontextmenu ondblclick ondrag ondragend ondragenter ondragleave ondragover  -syn keyword htmlArg contained ondragstart ondrop ondurationchange onemptied onended onerror onfocus onformchange  -syn keyword htmlArg contained onforminput oninput oninvalid onkeydown onkeypress onkeyup onload onloadeddata  -syn keyword htmlArg contained onloadedmetadata onloadstart onmousedown onmousemove onmouseout onmouseover onmouseup -syn keyword htmlArg contained onmousewheel onpause onplay onplaying onprogress onratechange onreadystatechange  -syn keyword htmlArg contained onscroll onseeked onseeking onselect onshow onstalled onsubmit onsuspend ontimeupdate  -syn keyword htmlArg contained onvolumechange onwaiting -" XML Attributes -syn keyword htmlArg contained xml:lang xml:space xml:base xmlns -" new features -" <body> -syn keyword htmlArg contained onafterprint onbeforeprint onbeforeunload onblur onerror onfocus onhashchange onload  -syn keyword htmlArg contained onmessage onoffline ononline onpopstate onredo onresize onstorage onundo onunload -" <video>, <audio>, <source>, <track> -syn keyword htmlArg contained autoplay preload controls loop poster media kind charset srclang track playsinline -" <form>, <input>, <button> -syn keyword htmlArg contained form autocomplete autofocus list min max step -syn keyword htmlArg contained formaction autofocus formenctype formmethod formtarget formnovalidate -syn keyword htmlArg contained required placeholder pattern -" <command>, <details>, <time> -syn keyword htmlArg contained label icon open datetime-local pubdate -" <script> -syn keyword htmlArg contained async -" <content> -syn keyword htmlArg contained select -" <iframe> -syn keyword htmlArg contained seamless srcdoc sandbox allowfullscreen allowusermedia allowpaymentrequest allowpresentation -" <picture> -syn keyword htmlArg contained srcset sizes -" <a> -syn keyword htmlArg contained download media -" <script>, <style> -syn keyword htmlArg contained nonce -" <area>, <a>, <img>, <iframe>, <link> -syn keyword htmlArg contained referrerpolicy -" https://w3c.github.io/webappsec-subresource-integrity/#the-integrity-attribute -syn keyword htmlArg contained integrity crossorigin -" <link> -syn keyword htmlArg contained prefetch  -" syn keyword htmlArg contained preload -" <img> -syn keyword htmlArg contained decoding -" https://w3c.github.io/selection-api/#extensions-to-globaleventhandlers -syn keyword htmlArg contained onselectstart onselectionchange -" https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/loading -syn keyword htmlArg contained loading - -" Custom Data Attributes -" http://w3c.github.io/html/single-page.html#embedding-custom-non-visible-data-with-the-data-attributes -syn match   htmlArg "\<data[-.0-9_a-z]*-[-.0-9_a-z]*\>" contained - -" Vendor Extension Attributes -" http://w3c.github.io/html/single-page.html#conformance-requirements-extensibility -syn match   htmlArg "\<x[-.0-9_a-z]*-[-.0-9_a-z]*\>" contained - -" Microdata -" http://dev.w3.org/html5/md/ -syn keyword htmlArg contained itemid itemscope itemtype itemprop itemref - -" SVG -" http://www.w3.org/TR/SVG/ -" Some common attributes from http://www.w3.org/TR/SVG/attindex.html -syn keyword htmlArg contained accent-height accumulate additive alphabetic amplitude arabic-form ascent attributeName attributeType azimuth  -syn keyword htmlArg contained baseFrequency baseProfile bbox begin bias by  -syn keyword htmlArg contained calcMode cap-height class clipPathUnits contentScriptType contentStyleType cx cy  -syn keyword htmlArg contained d descent diffuseConstant divisor dur dx dy  -syn keyword htmlArg contained edgeMode elevation end exponent externalResourcesRequired  -syn keyword htmlArg contained fill filterRes filterUnits font-family font-size font-stretch font-style font-variant font-weight format format from fx fy  -syn keyword htmlArg contained g1 g2 glyph-name glyphRef gradientTransform gradientUnits  -syn keyword htmlArg contained hanging height horiz-adv-x horiz-origin-x horiz-origin-y  -syn keyword htmlArg contained id ideographic in in2 intercept  -syn keyword htmlArg contained k k1 k2 k3 k4 kernelMatrix kernelUnitLength keyPoints keySplines keyTimes  -syn keyword htmlArg contained lang lengthAdjust limitingConeAngle local  -syn keyword htmlArg contained markerHeight markerUnits markerWidth maskContentUnits maskUnits mathematical max media method min mode name  -syn keyword htmlArg contained numOctaves  -syn keyword htmlArg contained offset onabort onactivate onbegin onclick onend onerror onfocusin onfocusout onload onmousedown onmousemove onmouseout onmouseover onmouseup onrepeat onresize onscroll onunload onzoom operator order orient orientation origin overline-position overline-thickness  -syn keyword htmlArg contained panose-1 path pathLength patternContentUnits patternTransform patternUnits points pointsAtX pointsAtY pointsAtZ preserveAlpha preserveAspectRatio primitiveUnits  -syn keyword htmlArg contained r radius refX refY rendering-intent repeatCount repeatDur requiredExtensions requiredFeatures restart result rotate rx ry  -syn keyword htmlArg contained scale seed slope spacing specularConstant specularExponent spreadMethod startOffset stdDeviation stemh stemv stitchTiles strikethrough-position strikethrough-thickness string surfaceScale systemLanguage  -syn keyword htmlArg contained tableValues target targetX targetY textLength title to transform type -syn keyword htmlArg contained u1 u2 underline-position underline-thickness unicode unicode-range units-per-em  -syn keyword htmlArg contained v-alphabetic v-hanging v-ideographic v-mathematical values version vert-adv-y vert-origin-x vert-origin-y viewBox viewTarget  -syn keyword htmlArg contained width widths  -syn keyword htmlArg contained x x-height x1 x2 xChannelSelector xlink:actuate xlink:actuate xlink:arcrole xlink:href xlink:role xlink:show xlink:title xlink:type xml:base xml:lang xml:space  -syn keyword htmlArg contained y y1 y2 yChannelSelector  -syn keyword htmlArg contained z zoomAndPan  -syn keyword htmlArg contained alignment-baseline baseline-shift clip-path clip-rule clip color-interpolation-filters color-interpolation color-profile color-rendering color cursor direction display dominant-baseline enable-background fill-opacity fill-rule fill filter flood-color flood-opacity font-family font-size-adjust font-size font-stretch font-style font-variant font-weight glyph-orientation-horizontal glyph-orientation-vertical image-rendering kerning letter-spacing lighting-color marker-end marker-mid marker-start mask opacity overflow pointer-events shape-rendering stop-color stop-opacity stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width stroke text-anchor text-decoration text-rendering unicode-bidi visibility word-spacing writing-mode - -" MathML attributes -" https://www.w3.org/TR/MathML3/chapter2.html#interf.toplevel.atts -syn keyword htmlArg contained accent accentunder actiontype align alignmentscope altimg altimg-height altimg-valign altimg-width alttext -syn keyword htmlArg contained annotation-xml background base baseline bevelled cd cdgroup charalign charspacing close -syn keyword htmlArg contained closure color columnalign columnalignment columnlines columnspacing columnspan columnwidth crossout decimalpoint -syn keyword htmlArg contained definitionURL denomalign depth display displaystyle edge encoding equalcolumns equalrows fence -syn keyword htmlArg contained fontfamily fontsize fontstyle fontweight form frame framespacing groupalign height indentalign -syn keyword htmlArg contained indentalignfirst indentalignlast indentshift indentshiftfirst indentshiftlast indenttarget index infixlinebreakstyle integer largeop -syn keyword htmlArg contained leftoverhang length linebreak linebreakmultchar linebreakstyle lineleading linethickness location longdivstyle lquote -syn keyword htmlArg contained lspace ltr macros math mathbackground mathcolor mathsize mathvariant maxsize maxwidth -syn keyword htmlArg contained mediummathspace menclose minlabelspacing minsize mode movablelimits msgroup mslinethickness name nargs -syn keyword htmlArg contained newline notation numalign number occurrence open order other overflow position -syn keyword htmlArg contained rightoverhang role rowalign rowlines rowspacing rowspan rquote rspace schemaLocation scope -syn keyword htmlArg contained scriptlevel scriptminsize scriptsize scriptsizemultiplier selection separator separators shift side stackalign -syn keyword htmlArg contained stretchy subscriptshift superscriptshift symmetric thickmathspace thinmathspace type valign verythickmathspace verythinmathspace -syn keyword htmlArg contained veryverythickmathspace veryverythinmathspace voffset width xref +syn cluster htmlJavaScript      add=@htmlPreproc + +if main_syntax != 'java' || exists("java_css") +  " embedded style sheets +  syn keyword htmlArg           contained media +  syn include @htmlCss syntax/css.vim +  unlet b:current_syntax +  syn region cssStyle start=+<style+ keepend end=+</style>+ contains=@htmlCss,htmlTag,htmlEndTag,htmlCssStyleComment,@htmlPreproc +  syn match htmlCssStyleComment contained "\(<!--\|-->\)" +  syn region htmlCssDefinition matchgroup=htmlArg start='style="' keepend matchgroup=htmlString end='"' contains=css.*Attr,css.*Prop,cssComment,cssLength,cssColor,cssURL,cssImportant,cssError,cssString,@htmlPreproc +  hi def link htmlStyleArg htmlString +endif + +if main_syntax == "html" +  " synchronizing (does not always work if a comment includes legal +  " html tags, but doing it right would mean to always start +  " at the first line, which is too slow) +  syn sync match htmlHighlight groupthere NONE "<[/a-zA-Z]" +  syn sync match htmlHighlight groupthere javaScript "<script" +  syn sync match htmlHighlightSkip "^.*['\"].*$" +  syn sync minlines=10 +endif + +" The default highlighting. +hi def link htmlTag                     Function +hi def link htmlEndTag                  Identifier +hi def link htmlArg                     Type +hi def link htmlTagName                 htmlStatement +hi def link htmlSpecialTagName          Exception +hi def link htmlValue                     String +hi def link htmlSpecialChar             Special + +if !exists("html_no_rendering") +  hi def link htmlH1                      Title +  hi def link htmlH2                      htmlH1 +  hi def link htmlH3                      htmlH2 +  hi def link htmlH4                      htmlH3 +  hi def link htmlH5                      htmlH4 +  hi def link htmlH6                      htmlH5 +  hi def link htmlHead                    PreProc +  hi def link htmlTitle                   Title +  hi def link htmlBoldItalicUnderline     htmlBoldUnderlineItalic +  hi def link htmlUnderlineBold           htmlBoldUnderline +  hi def link htmlUnderlineItalicBold     htmlBoldUnderlineItalic +  hi def link htmlUnderlineBoldItalic     htmlBoldUnderlineItalic +  hi def link htmlItalicUnderline         htmlUnderlineItalic +  hi def link htmlItalicBold              htmlBoldItalic +  hi def link htmlItalicBoldUnderline     htmlBoldUnderlineItalic +  hi def link htmlItalicUnderlineBold     htmlBoldUnderlineItalic +  hi def link htmlLink                    Underlined +  hi def link htmlLeadingSpace            None +  if !exists("html_my_rendering") +    hi def htmlBold                term=bold cterm=bold gui=bold +    hi def htmlBoldUnderline       term=bold,underline cterm=bold,underline gui=bold,underline +    hi def htmlBoldItalic          term=bold,italic cterm=bold,italic gui=bold,italic +    hi def htmlBoldUnderlineItalic term=bold,italic,underline cterm=bold,italic,underline gui=bold,italic,underline +    hi def htmlUnderline           term=underline cterm=underline gui=underline +    hi def htmlUnderlineItalic     term=italic,underline cterm=italic,underline gui=italic,underline +    hi def htmlItalic              term=italic cterm=italic gui=italic +    if v:version > 800 || v:version == 800 && has("patch1038") +        hi def htmlStrike              term=strikethrough cterm=strikethrough gui=strikethrough +    else +        hi def htmlStrike              term=underline cterm=underline gui=underline +    endif +  endif +endif + +hi def link htmlPreStmt            PreProc +hi def link htmlPreError           Error +hi def link htmlPreProc            PreProc +hi def link htmlPreAttr            String +hi def link htmlPreProcAttrName    PreProc +hi def link htmlPreProcAttrError   Error +hi def link htmlSpecial            Special +hi def link htmlSpecialChar        Special +hi def link htmlString             String +hi def link htmlStatement          Statement +hi def link htmlComment            Comment +hi def link htmlCommentPart        Comment +hi def link htmlValue              String +hi def link htmlCommentError       htmlError +hi def link htmlTagError           htmlError +hi def link htmlEvent              javaScript +hi def link htmlError              Error + +hi def link javaScript             Special +hi def link javaScriptExpression   javaScript +hi def link htmlCssStyleComment    Comment +hi def link htmlCssDefinition      Special  let b:current_syntax = "html" @@ -211,5 +337,6 @@ endif  let &cpo = s:cpo_save  unlet s:cpo_save +" vim: ts=8  endif diff --git a/tests/filetypes.vim b/tests/filetypes.vim index 5676807d..1c2daaeb 100644 --- a/tests/filetypes.vim +++ b/tests/filetypes.vim @@ -112,7 +112,6 @@ call TestFiletype('haskell')  call TestFiletype('haxe')  call TestFiletype('hcl')  call TestFiletype('hive') -call TestFiletype('html')  call TestFiletype('i3config')  call TestFiletype('icalendar')  call TestFiletype('idris') @@ -632,5 +631,6 @@ call TestFiletype('logcheck')  call TestFiletype('svn')  call TestFiletype('text')  call TestFiletype('pullrequest') +call TestFiletype('html')  " DO NOT EDIT CODE ABOVE, IT IS GENERATED WITH MAKEFILE | 
