1((comment) @injection.content
2 (#set! injection.language "comment")
3)
4
5(((comment) @_jsdoc_comment
6 (#match? @_jsdoc_comment "(?s)^/[*][*][^*].*[*]/$")) @injection.content
7 (#set! injection.language "jsdoc"))
8
9(((comment) @_reference
10 (#match? @_reference "^///\\s+<reference\\s+types=\"\\S+\"\\s*/>\\s*$")) @injection.content
11 (#set! injection.language "html"))
12
13((regex) @injection.content
14 (#set! injection.language "regex"))
15
16(call_expression
17 function: (identifier) @_name (#eq? @_name "css")
18 arguments: (template_string (string_fragment) @injection.content
19 (#set! injection.language "css"))
20)
21
22(call_expression
23 function: (member_expression
24 object: (identifier) @_obj (#eq? @_obj "styled")
25 property: (property_identifier))
26 arguments: (template_string (string_fragment) @injection.content
27 (#set! injection.language "css"))
28)
29
30(call_expression
31 function: (call_expression
32 function: (identifier) @_name (#eq? @_name "styled"))
33 arguments: (template_string (string_fragment) @injection.content
34 (#set! injection.language "css"))
35)
36
37(call_expression
38 function: (identifier) @_name (#eq? @_name "html")
39 arguments: (template_string) @injection.content
40 (#set! injection.language "html")
41)
42
43(call_expression
44 function: (identifier) @_name (#eq? @_name "js")
45 arguments: (template_string (string_fragment) @injection.content
46 (#set! injection.language "javascript"))
47)
48
49(call_expression
50 function: (identifier) @_name (#eq? @_name "json")
51 arguments: (template_string (string_fragment) @injection.content
52 (#set! injection.language "json"))
53)
54
55(call_expression
56 function: (identifier) @_name (#eq? @_name "sql")
57 arguments: (template_string (string_fragment) @injection.content
58 (#set! injection.language "sql"))
59)
60
61(call_expression
62 function: (identifier) @_name (#eq? @_name "ts")
63 arguments: (template_string (string_fragment) @injection.content
64 (#set! injection.language "typescript"))
65)
66
67(call_expression
68 function: (identifier) @_name (#match? @_name "^ya?ml$")
69 arguments: (template_string (string_fragment) @injection.content
70 (#set! injection.language "yaml"))
71)
72
73(call_expression
74 function: (identifier) @_name (#match? @_name "^g(raph)?ql$")
75 arguments: (template_string (string_fragment) @injection.content
76 (#set! injection.language "graphql"))
77)
78
79(call_expression
80 function: (identifier) @_name (#match? @_name "^g(raph)?ql$")
81 arguments: (arguments (template_string (string_fragment) @injection.content
82 (#set! injection.language "graphql")))
83)
84
85(call_expression
86 function: (identifier) @_name(#match? @_name "^iso$")
87 arguments: (arguments (template_string (string_fragment) @injection.content
88 (#set! injection.language "isograph")))
89)
90
91;; Angular Component template injection
92(call_expression
93 function: [
94 (identifier) @_decorator (#eq? @_decorator "Component")
95 (member_expression property: (property_identifier) @_decorator (#eq? @_decorator "Component"))
96 ]
97 arguments: (arguments (object
98 (pair
99 key: (property_identifier) @_prop (#eq? @_prop "template")
100 value: [
101 (string) @injection.content
102 (template_string) @injection.content
103 (template_string (string_fragment) @injection.content)
104 ]
105 )))
106 (#set! injection.language "angular"))
107
108;; Angular Component styles injection
109(call_expression
110 function: [
111 (identifier) @_decorator (#eq? @_decorator "Component")
112 (member_expression property: (property_identifier) @_decorator (#eq? @_decorator "Component"))
113 ]
114 arguments: (arguments (object
115 (pair
116 key: (property_identifier) @_prop (#eq? @_prop "styles")
117 value: [
118 (string) @injection.content
119 (template_string) @injection.content
120 (template_string (string_fragment) @injection.content)
121 (array (string) @injection.content)
122 (array (template_string) @injection.content)
123 (array (template_string (string_fragment)) @injection.content)
124 ]
125 )))
126 (#set! injection.language "css"))
127
128; Parse the contents of strings and tagged template
129; literals with leading ECMAScript comments:
130; '/* html */' or '/*html*/'
131(
132 ((comment) @_ecma_comment [
133 (string (string_fragment) @injection.content)
134 (template_string (string_fragment) @injection.content)
135 ])
136 (#match? @_ecma_comment "^\\/\\*\\s*html\\s*\\*\\/")
137 (#set! injection.language "html")
138)
139
140; '/* sql */' or '/*sql*/'
141(
142 ((comment) @_ecma_comment [
143 (string (string_fragment) @injection.content)
144 (template_string (string_fragment) @injection.content)
145 ])
146 (#match? @_ecma_comment "^\\/\\*\\s*sql\\s*\\*\\/")
147 (#set! injection.language "sql")
148)
149
150; '/* gql */' or '/*gql*/'
151; '/* graphql */' or '/*graphql*/'
152(
153 ((comment) @_ecma_comment [
154 (string (string_fragment) @injection.content)
155 (template_string (string_fragment) @injection.content)
156 ])
157 (#match? @_ecma_comment "^\\/\\*\\s*(gql|graphql)\\s*\\*\\/")
158 (#set! injection.language "graphql")
159)
160
161; '/* css */' or '/*css*/'
162(
163 ((comment) @_ecma_comment [
164 (string (string_fragment) @injection.content)
165 (template_string (string_fragment) @injection.content)
166 ])
167 (#match? @_ecma_comment "^\\/\\*\\s*(css)\\s*\\*\\/")
168 (#set! injection.language "css")
169)