annotate runtime/syntax/typescriptreact.vim @ 34366:1f5f3d58ed28

Added tag v9.1.0113 for changeset 8303936dbd64eca2d06b4f57b9da7a17e7496e27
author Christian Brabandt <cb@256bit.org>
date Thu, 15 Feb 2024 20:30:06 +0100
parents 71cbad0921c9
children 5ea191f0c8a1
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
18639
cb3163d590a1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1 " Vim syntax file
cb3163d590a1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2 " Language: TypeScript with React (JSX)
32975
71cbad0921c9 runtime: Remove Brams name from a few more runtime files (#12780)
Christian Brabandt <cb@256bit.org>
parents: 29756
diff changeset
3 " Maintainer: The Vim Project <https://github.com/vim/vim>
71cbad0921c9 runtime: Remove Brams name from a few more runtime files (#12780)
Christian Brabandt <cb@256bit.org>
parents: 29756
diff changeset
4 " Last Change: 2023 Aug 13
18639
cb3163d590a1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5 " Based On: Herrington Darkholme's yats.vim
32975
71cbad0921c9 runtime: Remove Brams name from a few more runtime files (#12780)
Christian Brabandt <cb@256bit.org>
parents: 29756
diff changeset
6 " Changes: See https://github.com/HerringtonDarkholme/yats.vim
18639
cb3163d590a1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
7 " Credits: See yats.vim on github
cb3163d590a1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
8
cb3163d590a1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
9 if !exists("main_syntax")
cb3163d590a1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
10 if exists("b:current_syntax")
cb3163d590a1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
11 finish
cb3163d590a1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
12 endif
cb3163d590a1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
13 let main_syntax = 'typescriptreact'
cb3163d590a1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
14 endif
cb3163d590a1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
15
cb3163d590a1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
16 let s:cpo_save = &cpo
cb3163d590a1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
17 set cpo&vim
cb3163d590a1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
18
cb3163d590a1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
19 syntax region tsxTag
cb3163d590a1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
20 \ start=+<\([^/!?<>="':]\+\)\@=+
cb3163d590a1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
21 \ skip=+</[^ /!?<>"']\+>+
cb3163d590a1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
22 \ end=+/\@<!>+
cb3163d590a1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
23 \ end=+\(/>\)\@=+
cb3163d590a1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
24 \ contained
cb3163d590a1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
25 \ contains=tsxTagName,tsxIntrinsicTagName,tsxAttrib,tsxEscJs,
cb3163d590a1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
26 \tsxCloseString,@tsxComment
cb3163d590a1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
27
cb3163d590a1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
28 syntax match tsxTag /<>/ contained
cb3163d590a1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
29
cb3163d590a1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
30
cb3163d590a1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
31 " <tag></tag>
cb3163d590a1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
32 " s~~~~~~~~~e
cb3163d590a1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
33 " and self close tag
cb3163d590a1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
34 " <tag/>
cb3163d590a1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
35 " s~~~~e
cb3163d590a1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
36 " A big start regexp borrowed from https://git.io/vDyxc
cb3163d590a1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
37 syntax region tsxRegion
cb3163d590a1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
38 \ start=+<\_s*\z([a-zA-Z1-9\$_-]\+\(\.\k\+\)*\)+
cb3163d590a1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
39 \ skip=+<!--\_.\{-}-->+
cb3163d590a1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
40 \ end=+</\_s*\z1>+
cb3163d590a1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
41 \ matchgroup=tsxCloseString end=+/>+
cb3163d590a1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
42 \ fold
cb3163d590a1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
43 \ contains=tsxRegion,tsxCloseString,tsxCloseTag,tsxTag,tsxCommentInvalid,tsxFragment,tsxEscJs,@Spell
cb3163d590a1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
44 \ keepend
cb3163d590a1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
45 \ extend
cb3163d590a1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
46
cb3163d590a1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
47 " <> </>
cb3163d590a1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
48 " s~~~~~~e
cb3163d590a1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
49 " A big start regexp borrowed from https://git.io/vDyxc
cb3163d590a1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
50 syntax region tsxFragment
cb3163d590a1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
51 \ start=+\(\((\|{\|}\|\[\|,\|&&\|||\|?\|:\|=\|=>\|\Wreturn\|^return\|\Wdefault\|^\|>\)\_s*\)\@<=<>+
cb3163d590a1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
52 \ skip=+<!--\_.\{-}-->+
cb3163d590a1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
53 \ end=+</>+
cb3163d590a1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
54 \ fold
cb3163d590a1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
55 \ contains=tsxRegion,tsxCloseString,tsxCloseTag,tsxTag,tsxCommentInvalid,tsxFragment,tsxEscJs,@Spell
cb3163d590a1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
56 \ keepend
cb3163d590a1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
57 \ extend
cb3163d590a1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
58
cb3163d590a1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
59 " </tag>
cb3163d590a1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
60 " ~~~~~~
cb3163d590a1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
61 syntax match tsxCloseTag
cb3163d590a1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
62 \ +</\_s*[^/!?<>"']\+>+
cb3163d590a1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
63 \ contained
cb3163d590a1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
64 \ contains=tsxTagName,tsxIntrinsicTagName
cb3163d590a1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
65
cb3163d590a1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
66 syntax match tsxCloseTag +</>+ contained
cb3163d590a1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
67
cb3163d590a1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
68 syntax match tsxCloseString
cb3163d590a1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
69 \ +/>+
cb3163d590a1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
70 \ contained
cb3163d590a1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
71
cb3163d590a1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
72 " <!-- -->
cb3163d590a1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
73 " ~~~~~~~~
cb3163d590a1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
74 syntax match tsxCommentInvalid /<!--\_.\{-}-->/ display
cb3163d590a1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
75
cb3163d590a1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
76 syntax region tsxBlockComment
cb3163d590a1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
77 \ contained
cb3163d590a1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
78 \ start="/\*"
cb3163d590a1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
79 \ end="\*/"
cb3163d590a1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
80
cb3163d590a1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
81 syntax match tsxLineComment
cb3163d590a1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
82 \ "//.*$"
cb3163d590a1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
83 \ contained
cb3163d590a1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
84 \ display
cb3163d590a1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
85
cb3163d590a1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
86 syntax cluster tsxComment contains=tsxBlockComment,tsxLineComment
cb3163d590a1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
87
cb3163d590a1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
88 syntax match tsxEntity "&[^; \t]*;" contains=tsxEntityPunct
cb3163d590a1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
89 syntax match tsxEntityPunct contained "[&.;]"
cb3163d590a1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
90
cb3163d590a1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
91 " <tag key={this.props.key}>
cb3163d590a1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
92 " ~~~
cb3163d590a1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
93 syntax match tsxTagName
cb3163d590a1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
94 \ +[</]\_s*[^/!?<>"'* ]\++hs=s+1
cb3163d590a1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
95 \ contained
cb3163d590a1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
96 \ nextgroup=tsxAttrib
cb3163d590a1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
97 \ skipwhite
cb3163d590a1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
98 \ display
cb3163d590a1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
99 syntax match tsxIntrinsicTagName
cb3163d590a1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
100 \ +[</]\_s*[a-z1-9-]\++hs=s+1
cb3163d590a1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
101 \ contained
cb3163d590a1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
102 \ nextgroup=tsxAttrib
cb3163d590a1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
103 \ skipwhite
cb3163d590a1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
104 \ display
cb3163d590a1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
105
cb3163d590a1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
106 " <tag key={this.props.key}>
cb3163d590a1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
107 " ~~~
cb3163d590a1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
108 syntax match tsxAttrib
cb3163d590a1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
109 \ +[a-zA-Z_][-0-9a-zA-Z_]*+
cb3163d590a1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
110 \ nextgroup=tsxEqual skipwhite
cb3163d590a1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
111 \ contained
cb3163d590a1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
112 \ display
cb3163d590a1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
113
cb3163d590a1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
114 " <tag id="sample">
cb3163d590a1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
115 " ~
cb3163d590a1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
116 syntax match tsxEqual +=+ display contained
cb3163d590a1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
117 \ nextgroup=tsxString skipwhite
cb3163d590a1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
118
cb3163d590a1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
119 " <tag id="sample">
cb3163d590a1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
120 " s~~~~~~e
cb3163d590a1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
121 syntax region tsxString contained start=+"+ end=+"+ contains=tsxEntity,@Spell display
cb3163d590a1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
122
cb3163d590a1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
123 " <tag key={this.props.key}>
cb3163d590a1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
124 " s~~~~~~~~~~~~~~e
cb3163d590a1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
125 syntax region tsxEscJs
cb3163d590a1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
126 \ contained
cb3163d590a1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
127 \ contains=@typescriptValue,@tsxComment
cb3163d590a1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
128 \ matchgroup=typescriptBraces
cb3163d590a1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
129 \ start=+{+
cb3163d590a1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
130 \ end=+}+
cb3163d590a1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
131 \ extend
cb3163d590a1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
132
cb3163d590a1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
133
cb3163d590a1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
134 """""""""""""""""""""""""""""""""""""""""""""""""""
cb3163d590a1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
135 " Source the part common with typescriptreact.vim
29756
2acb87ee55fc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 18750
diff changeset
136 source <sfile>:h/shared/typescriptcommon.vim
18639
cb3163d590a1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
137
cb3163d590a1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
138
cb3163d590a1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
139 syntax cluster typescriptExpression add=tsxRegion,tsxFragment
cb3163d590a1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
140
cb3163d590a1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
141 hi def link tsxTag htmlTag
cb3163d590a1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
142 hi def link tsxTagName Function
cb3163d590a1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
143 hi def link tsxIntrinsicTagName htmlTagName
cb3163d590a1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
144 hi def link tsxString String
cb3163d590a1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
145 hi def link tsxNameSpace Function
cb3163d590a1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
146 hi def link tsxCommentInvalid Error
cb3163d590a1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
147 hi def link tsxBlockComment Comment
cb3163d590a1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
148 hi def link tsxLineComment Comment
cb3163d590a1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
149 hi def link tsxAttrib Type
cb3163d590a1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
150 hi def link tsxEscJs tsxEscapeJs
cb3163d590a1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
151 hi def link tsxCloseTag htmlTag
cb3163d590a1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
152 hi def link tsxCloseString Identifier
cb3163d590a1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
153
cb3163d590a1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
154 let b:current_syntax = "typescriptreact"
cb3163d590a1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
155 if main_syntax == 'typescriptreact'
cb3163d590a1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
156 unlet main_syntax
cb3163d590a1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
157 endif
cb3163d590a1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
158
cb3163d590a1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
159 let &cpo = s:cpo_save
cb3163d590a1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
160 unlet s:cpo_save