diff options
author | Adam Stankiewicz <sheerun@sher.pl> | 2019-11-04 09:04:28 +0100 |
---|---|---|
committer | Adam Stankiewicz <sheerun@sher.pl> | 2019-11-04 09:04:28 +0100 |
commit | 4e95df7c7e12cb76e781f2dacf1c07f8984cce58 (patch) | |
tree | af9230137ec342d4bed0a68a9ccb49ed3303b3d0 /syntax/typescriptreact.vim | |
parent | 31c55b85a03d96252bba14d64911cc78a20369a1 (diff) | |
download | vim-polyglot-4e95df7c7e12cb76e781f2dacf1c07f8984cce58.tar.gz vim-polyglot-4e95df7c7e12cb76e781f2dacf1c07f8984cce58.zip |
Update
Diffstat (limited to 'syntax/typescriptreact.vim')
-rw-r--r-- | syntax/typescriptreact.vim | 145 |
1 files changed, 145 insertions, 0 deletions
diff --git a/syntax/typescriptreact.vim b/syntax/typescriptreact.vim new file mode 100644 index 00000000..7d55769b --- /dev/null +++ b/syntax/typescriptreact.vim @@ -0,0 +1,145 @@ +if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'typescript') == -1 + +if !exists("main_syntax") + if exists("b:current_syntax") + finish + endif + let main_syntax = 'typescriptreact' +endif + +syntax region tsxTag + \ start=+<\([^/!?<>="':]\+\)\@=+ + \ skip=+</[^ /!?<>"']\+>+ + \ end=+/\@<!>+ + \ end=+\(/>\)\@=+ + \ contained + \ contains=tsxTagName,tsxIntrinsicTagName,tsxAttrib,tsxEscJs, + \tsxCloseString,@tsxComment + +syntax match tsxTag /<>/ contained + + +" <tag></tag> +" s~~~~~~~~~e +" and self close tag +" <tag/> +" s~~~~e +" A big start regexp borrowed from https://git.io/vDyxc +syntax region tsxRegion + \ start=+<\_s*\z([a-zA-Z1-9\$_-]\+\(\.\k\+\)*\)+ + \ skip=+<!--\_.\{-}-->+ + \ end=+</\_s*\z1>+ + \ matchgroup=tsxCloseString end=+/>+ + \ fold + \ contains=tsxRegion,tsxCloseString,tsxCloseTag,tsxTag,tsxCommentInvalid,tsxFragment,tsxEscJs,@Spell + \ keepend + \ extend + +" <> </> +" s~~~~~~e +" A big start regexp borrowed from https://git.io/vDyxc +syntax region tsxFragment + \ start=+\(\((\|{\|}\|\[\|,\|&&\|||\|?\|:\|=\|=>\|\Wreturn\|^return\|\Wdefault\|^\|>\)\_s*\)\@<=<>+ + \ skip=+<!--\_.\{-}-->+ + \ end=+</>+ + \ fold + \ contains=tsxRegion,tsxCloseString,tsxCloseTag,tsxTag,tsxCommentInvalid,tsxFragment,tsxEscJs,@Spell + \ keepend + \ extend + +" </tag> +" ~~~~~~ +syntax match tsxCloseTag + \ +</\_s*[^/!?<>"']\+>+ + \ contained + \ contains=tsxTagName,tsxIntrinsicTagName + +syntax match tsxCloseTag +</>+ contained + +syntax match tsxCloseString + \ +/>+ + \ contained + +" <!-- --> +" ~~~~~~~~ +syntax match tsxCommentInvalid /<!--\_.\{-}-->/ display + +syntax region tsxBlockComment + \ contained + \ start="/\*" + \ end="\*/" + +syntax match tsxLineComment + \ "//.*$" + \ contained + \ display + +syntax cluster tsxComment contains=tsxBlockComment,tsxLineComment + +syntax match tsxEntity "&[^; \t]*;" contains=tsxEntityPunct +syntax match tsxEntityPunct contained "[&.;]" + +" <tag key={this.props.key}> +" ~~~ +syntax match tsxTagName + \ +[</]\_s*[^/!?<>"'* ]\++hs=s+1 + \ contained + \ nextgroup=tsxAttrib + \ skipwhite + \ display +syntax match tsxIntrinsicTagName + \ +[</]\_s*[a-z1-9-]\++hs=s+1 + \ contained + \ nextgroup=tsxAttrib + \ skipwhite + \ display + +" <tag key={this.props.key}> +" ~~~ +syntax match tsxAttrib + \ +[a-zA-Z_][-0-9a-zA-Z_]*+ + \ nextgroup=tsxEqual skipwhite + \ contained + \ display + +" <tag id="sample"> +" ~ +syntax match tsxEqual +=+ display contained + \ nextgroup=tsxString skipwhite + +" <tag id="sample"> +" s~~~~~~e +syntax region tsxString contained start=+"+ end=+"+ contains=tsxEntity,@Spell display + +" <tag key={this.props.key}> +" s~~~~~~~~~~~~~~e +syntax region tsxEscJs + \ contained + \ contains=@typescriptValue,@tsxComment + \ matchgroup=typescriptBraces + \ start=+{+ + \ end=+}+ + \ extend + +runtime syntax/common.vim + +syntax cluster typescriptExpression add=tsxRegion,tsxFragment + +highlight def link tsxTag htmlTag +highlight def link tsxTagName Function +highlight def link tsxIntrinsicTagName htmlTagName +highlight def link tsxString String +highlight def link tsxNameSpace Function +highlight def link tsxCommentInvalid Error +highlight def link tsxBlockComment Comment +highlight def link tsxLineComment Comment +highlight def link tsxAttrib Type +highlight def link tsxEscJs tsxEscapeJs +highlight def link tsxCloseTag htmlTag +highlight def link tsxCloseString Identifier + +let b:current_syntax = "typescriptreact" +if main_syntax == 'typescriptreact' + unlet main_syntax +endif +endif |