From 9bbd52c6a373d765f1d6e4e444292e7b4eb00d1e Mon Sep 17 00:00:00 2001 From: ManjaroOne666 Date: Thu, 14 Sep 2017 00:47:21 +0100 Subject: [PATCH] html data attribute highlighting added --- vim/syntax/html_custom.vim | 83 +++++++++++++++++++++++++++----------- 1 file changed, 60 insertions(+), 23 deletions(-) diff --git a/vim/syntax/html_custom.vim b/vim/syntax/html_custom.vim index 4bea760..0c022de 100644 --- a/vim/syntax/html_custom.vim +++ b/vim/syntax/html_custom.vim @@ -27,38 +27,75 @@ syn case ignore syn match htmlError "[<>&]" -syn region htmlString contained start=+"+ end=+"+ contains=htmlSpecialChar,javaScriptExpression,@htmlPreproc -syn region htmlString contained start=+'+ end=+'+ contains=htmlSpecialChar,javaScriptExpression,@htmlPreproc - - -syn region cssClassRegion contained start=+class="+hs=s+7 end=+"+he=e-1 contains=htmlSpecialChar,cssClassAttr,cssAttrNoise,cssClassName keepend -syn region cssClassRegion contained start=+class='+hs=s+7 end=+'+he=e-1 contains=htmlSpecialChar,cssClassAttr,cssAttrNoise,cssClassName keepend - -syn region cssIdRegion contained start=+id="+hs=s+4 end=+"+he=e-1 contains=htmlSpecialChar,cssIdentifierAttr,cssAttrNoise,cssIdentifier keepend -syn region cssIdRegion contained start=+id='+hs=s+4 end=+'+he=e-1 contains=htmlSpecialChar,cssIdentifierAttr,cssAttrNoise,cssIdentifier keepend +syn region htmlString contained start=+"+ end=+"+ contains=htmlSpecialChar,javaScriptExpression,@htmlPreproc keepend +syn region htmlString contained start=+'+ end=+'+ contains=htmlSpecialChar,javaScriptExpression,@htmlPreproc keepend +" css classes +syn region cssClassRegion contained start=+class="+hs=s+7 end=+"+he=e-1 contains=htmlSpecialChar,cssClassAttr,cssAttrNoise,cssClassName keepend +syn region cssClassRegion contained start=+class='+hs=s+7 end=+'+he=e-1 contains=htmlSpecialChar,cssClassAttr,cssAttrNoise,cssClassName keepend syn region cssClassName contained start=+"+hs=s+1 end=+"+he=e-1 contains=cssAttrNoise keepend -syn region cssIdentifier contained start=+"+hs=s+1 end=+"+he=s-1 contains=cssAttrNoise keepend - syn match cssClassAttr "class" contained + +" css IDs +syn region cssIdRegion contained start=+id="+hs=s+4 end=+"+he=e-1 contains=htmlSpecialChar,cssIdentifierAttr,cssAttrNoise,cssIdentifier keepend +syn region cssIdRegion contained start=+id='+hs=s+4 end=+'+he=e-1 contains=htmlSpecialChar,cssIdentifierAttr,cssAttrNoise,cssIdentifier keepend +syn region cssIdentifier contained start=+"+hs=s+1 end=+"+he=s-1 contains=cssAttrNoise keepend syn match cssIdentifierAttr "id" contained +" img arguments +syn region htmlArgRegion contained start=+src="+hs=s+5 end=+"+he=e-1 contains=htmlSpecialChar,cssAttrNoise,htmlSrcArg,htmlSrcValue keepend +syn region htmlArgRegion contained start=+src='+hs=s+5 end=+'+he=e-1 contains=htmlSpecialChar,cssAttrNoise,htmlSrcArg,htmlSrcValue keepend +syn region htmlSrcValue contained start=+"+hs=s+1 end=+"+he=s-1 contains=cssAttrNoise keepend +syn match htmlSrcArg "src" contained + +syn region htmlArgRegion contained start=+srcset="+hs=s+8 end=+"+he=e-1 contains=htmlSpecialChar,htmlSrcsetArg,htmlSrcsetValue,cssAttrNoise keepend +syn region htmlArgRegion contained start=+srcset='+hs=s+8 end=+'+he=e-1 contains=htmlSpecialChar,htmlSrcsetArg,htmlSrcsetValue,cssAttrNoise keepend +syn region htmlSrcsetValue contained start=+"+hs=s+1 end=+"+he=s-1 contains=cssAttrNoise keepend +syn match htmlSrcsetArg "srcset" contained + +syn region htmlArgRegion contained start=+alt="+hs=s+5 end=+"+he=e-1 contains=htmlSpecialChar,htmlAltArg,htmlAltValue,cssAttrNoise keepend +syn region htmlArgRegion contained start=+alt='+hs=s+5 end=+'+he=e-1 contains=htmlSpecialChar,htmlAltArg,htmlAltValue,cssAttrNoise keepend +syn region htmlAltValue contained start=+"+hs=s+1 end=+"+he=s-1 contains=cssAttrNoise keepend +syn match htmlAltArg "alt" contained + +" data-* +syn region htmlArgRegion contained start=+data.*="+hs=s+5 end=+"+he=e-1 contains=htmlDataArg,htmlDataValue,cssAttrNoise keepend +"syn region htmlArgRegion contained start=+alt='+hs=s+5 end=+'+he=e-1 contains=htmlSpecialChar,htmlAltArg,htmlAltValue,cssAttrNoise keepend +syn region htmlDataValue contained start=+"+hs=s+1 end=+"+me=e-1 contains=cssAttrNoise keepend +syn match htmlDataArg +data.*="+me=e-2 contained +hi htmlDataValue ctermfg=163 +hi htmlDataArg ctermfg=56 + + + syn match cssAttrNoise +=+ contained -hi def link cssAttrNoise htmlTag -hi def link cssClassName identifier -hi def link cssIdentifier identifier -hi def link cssClassAttr identifier -hi def link cssIdentifierAttr identifier -"syn region + +hi def link cssAttrNoise htmlTag +" TODO better linking groups +hi def link cssClassName Identifier +hi def link cssClassAttr Type +hi def link cssIdentifier Identifier +hi def link cssIdentifierAttr Type +hi def link htmlSrcValue htmlImgValue +hi def link htmlSrcArg htmlImgArg +hi def link htmlSrcsetValue htmlImgValue +hi def link htmlSrcsetArg htmlImgArg +hi def link htmlAltValue htmlImgValue +hi def link htmlAltArg htmlImgArg +hi def link htmlImgValue Identifier +hi def link htmlImgArg Type +hi def link htmlDataValue Identifier +hi def link htmlDataArg Special + syn region htmlIdString contained start=+id="+ end=+"+ contains=htmlSpecialChar syn region htmlIdString contained start=+id='+ end=+'+ contains=htmlSpecialChar syn match htmlValue contained "=[\t ]*[^'" \t>][^ \t>]*"hs=s+1 contains=javaScriptExpression,@htmlPreproc syn region htmlEndTag start=++ contains=htmlTagN,htmlTagError -syn region htmlTag start=+<[^/]+ end=+>+ fold contains=htmlTagN,htmlString,cssClassRegion,cssIdRegion,htmlArg,htmlValue,htmlTagError,htmlEvent,htmlCssDefinition,@htmlPreproc,@htmlArgCluster +syn region htmlTag start=+<[^/]+ end=+>+ fold contains=htmlTagN,htmlString,cssClassRegion,cssIdRegion,htmlArgregion,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 +]<"ms=s+1 @@ -81,7 +118,7 @@ syn keyword htmlTagName contained colgroup del 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 article aside audio bdi canvas syn keyword htmlTagName contained datalist details embed figcaption figure syn keyword htmlTagName contained footer header hgroup keygen main mark syn keyword htmlTagName contained menuitem meter nav output picture @@ -90,7 +127,7 @@ syn keyword htmlTagName contained slot source template time track video wbr " legal arg names syn keyword htmlArg contained action -syn keyword htmlArg contained align alink alt archive background bgcolor +syn keyword htmlArg contained align alink archive background bgcolor syn keyword htmlArg contained border bordercolor cellpadding syn keyword htmlArg contained cellspacing checked clear code codebase color syn keyword htmlArg contained cols colspan content coords enctype face @@ -98,7 +135,7 @@ syn keyword htmlArg contained gutter height hspace 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 size 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 @@ -117,7 +154,7 @@ 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 cite classid codetype compact 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 @@ -134,7 +171,7 @@ 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 sizes srcdoc srclang step title translate syn keyword htmlArg contained typemustmatch " special characters