diff options
author | Jan Edmund Lazo <jan.lazo@mail.utoronto.ca> | 2020-10-03 09:43:02 -0400 |
---|---|---|
committer | Jan Edmund Lazo <jan.lazo@mail.utoronto.ca> | 2020-10-05 23:20:45 -0400 |
commit | 0f1d679531e56c5cb8180abc56b466668e68800f (patch) | |
tree | 59dcf587c799503f4787f10e17b6ecca81e3cc6e /runtime/syntax/typescriptreact.vim | |
parent | 8810973da40e9e4c886f000cebb8f74c5c65ad48 (diff) | |
download | rneovim-0f1d679531e56c5cb8180abc56b466668e68800f.tar.gz rneovim-0f1d679531e56c5cb8180abc56b466668e68800f.tar.bz2 rneovim-0f1d679531e56c5cb8180abc56b466668e68800f.zip |
runtime/typescript: 09c6f265b21065ffa9437837b1d0955137175e45
Port typescript syntax files only.
Close https://github.com/neovim/neovim/issues/12125
https://github.com/vim/vim/commit/09c6f265b21065ffa9437837b1d0955137175e45
Diffstat (limited to 'runtime/syntax/typescriptreact.vim')
-rw-r--r-- | runtime/syntax/typescriptreact.vim | 160 |
1 files changed, 160 insertions, 0 deletions
diff --git a/runtime/syntax/typescriptreact.vim b/runtime/syntax/typescriptreact.vim new file mode 100644 index 0000000000..5a521c9fbc --- /dev/null +++ b/runtime/syntax/typescriptreact.vim @@ -0,0 +1,160 @@ +" Vim syntax file +" Language: TypeScript with React (JSX) +" Maintainer: Bram Moolenaar +" Last Change: 2019 Nov 17 +" Based On: Herrington Darkholme's yats.vim +" Changes: See https:github.com/HerringtonDarkholme/yats.vim +" Credits: See yats.vim on github + +if !exists("main_syntax") + if exists("b:current_syntax") + finish + endif + let main_syntax = 'typescriptreact' +endif + +let s:cpo_save = &cpo +set cpo&vim + +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 + + +""""""""""""""""""""""""""""""""""""""""""""""""""" +" Source the part common with typescriptreact.vim +source <sfile>:h/typescriptcommon.vim + + +syntax cluster typescriptExpression add=tsxRegion,tsxFragment + +hi def link tsxTag htmlTag +hi def link tsxTagName Function +hi def link tsxIntrinsicTagName htmlTagName +hi def link tsxString String +hi def link tsxNameSpace Function +hi def link tsxCommentInvalid Error +hi def link tsxBlockComment Comment +hi def link tsxLineComment Comment +hi def link tsxAttrib Type +hi def link tsxEscJs tsxEscapeJs +hi def link tsxCloseTag htmlTag +hi def link tsxCloseString Identifier + +let b:current_syntax = "typescriptreact" +if main_syntax == 'typescriptreact' + unlet main_syntax +endif + +let &cpo = s:cpo_save +unlet s:cpo_save |