2
2
%TAG ! tag:yaml-macros:yamlmacros.lib.arguments,yamlmacros.lib.include:
3
3
---
4
4
contexts:
5
- literal-string-template :
5
+ expression-begin :
6
6
- meta_prepend: true
7
- - include: literal-string-template-custom-comments
8
7
- include: literal-string-template-custom-tags
9
8
- include: styled-components
10
9
11
- expression-begin:
12
- - meta_prepend: true
13
- # Keep the slow backreferences out of this frequently-used context.
14
10
- match: (?=`)
15
11
set:
12
+ # Keep the slow lookbehinds out of this frequently-used context.
16
13
- include: literal-string-template-custom-comments
17
- - include: literal-string-template-custom-lookahead
18
14
- include: custom-templates-default
15
+ - include: else-pop
19
16
20
- custom-templates-default: !if
21
- - !argument default
22
- - !with
23
- - include: !argument default
24
- - !include_resource Packages/JSCustom/extensions/custom_templates/template.yaml
25
- - - include: literal-string-template
17
+ custom-templates-default:
18
+ - match: '`'
19
+ scope: string.quoted.other.js punctuation.definition.string.begin.js
20
+ push:
21
+ - - include: immediately-pop
22
+ - custom-templates-closing-quote
23
+ - custom-templates-clear-scopes
24
+ - - meta_include_prototype: false
25
+ - include: literal-string-template-custom-lookahead
26
+ - !if
27
+ - !argument default
28
+ - match: (?=\s*\S)
29
+ set: !argument default
30
+ with_prototype:
31
+ - include: custom-templates-prototype
32
+ - match: (?=\s*\S)
33
+ set:
34
+ - meta_scope: string.quoted.other.js
35
+ - meta_include_prototype: false
36
+ - include: custom-templates-prototype
37
+
38
+ literal-string-template-custom-lookahead: !foreach
39
+ in: !argument [lookaheads, {}]
40
+ as: [lookahead, include]
41
+ value:
42
+ match: !format '(?=\s*(?:{lookahead}))'
43
+ set: !argument include
44
+ with_prototype:
45
+ - include: custom-templates-prototype
26
46
27
47
literal-string-template-custom-tags: !foreach
28
48
in: !argument [tags, {}]
29
49
as: [tag, include]
30
50
value:
31
51
match: !format '(?:{tag})(?=\s*`)'
32
52
scope: variable.function.tagged-template.js
33
- set: !include_resource Packages/JSCustom/extensions/custom_templates/template.yaml
53
+ set:
54
+ - !include_resource Packages/JSCustom/extensions/custom_templates/template.yaml
55
+ - include: else-pop
34
56
35
57
literal-string-template-custom-comments: !foreach
36
58
in: !argument [comments, {}]
37
59
as: [tag, include]
38
60
value:
39
61
match: !format '(?<=/\*(?:{tag})\*/|/\* (?:{tag}) \*/)'
40
- scope: variable.function.tagged-template.js
41
- set: !include_resource Packages/JSCustom/extensions/custom_templates/template.yaml
42
-
43
- literal-string-template-custom-lookahead: !foreach
44
- in: !argument [lookaheads, {}]
45
- as: [lookahead, include]
46
- value:
47
- match: !format '(?=`(?:{lookahead}))'
48
- scope: variable.function.tagged-template.js
49
- set: !include_resource Packages/JSCustom/extensions/custom_templates/template.yaml
62
+ set:
63
+ - !include_resource Packages/JSCustom/extensions/custom_templates/template.yaml
64
+ - include: else-pop
50
65
51
66
styled-components: !if
52
67
- !argument styled_components
@@ -65,18 +80,16 @@ contexts:
65
80
scope: punctuation.accessor.dot.js
66
81
push: styled-component-begin
67
82
68
- - match: (?=`)
69
- set: !with
70
- - include: scope:source.js.css
71
- - !include_resource Packages/JSCustom/extensions/custom_templates/template.yaml
83
+ - !with
84
+ - include: scope:source.js.css
85
+ - !include_resource Packages/JSCustom/extensions/custom_templates/template.yaml
72
86
73
87
- include: expression-end
74
88
75
89
styled-component-keyframes-end:
76
- - match: (?=`)
77
- push: !with
78
- - include: scope:source.js.css#at-keyframe-block-content
79
- - !include_resource Packages/JSCustom/extensions/custom_templates/template.yaml
90
+ - !with
91
+ - include: scope:source.js.css#at-keyframe-block-content
92
+ - !include_resource Packages/JSCustom/extensions/custom_templates/template.yaml
80
93
- include: else-pop
81
94
82
95
styled-component-begin:
@@ -95,3 +108,32 @@ contexts:
95
108
pop: true
96
109
97
110
- include: else-pop
111
+
112
+ custom-templates-closing-quote:
113
+ - meta_include_prototype: false
114
+ - meta_scope: meta.string.js string.quoted.other.js
115
+ - match: "`"
116
+ scope: punctuation.definition.string.end.js
117
+ pop: true
118
+ - include: immediately-pop
119
+
120
+ custom-templates-clear-scopes:
121
+ - meta_include_prototype: false
122
+ - clear_scopes: !if [!argument clear_all_scopes, true, 1]
123
+ - include: immediately-pop
124
+
125
+ custom-templates-prototype:
126
+ - match: (?=`)
127
+ pop: true
128
+ - match: '\$\{'
129
+ scope: punctuation.section.interpolation.begin.js
130
+ push:
131
+ - clear_scopes: !if [!argument clear_all_scopes, true, 1]
132
+ - meta_scope: meta.interpolation.js
133
+ - meta_content_scope: source.js.embedded.expression
134
+ - match: '\}'
135
+ scope: punctuation.section.interpolation.end.js
136
+ pop: true
137
+ - match: (?=\S)
138
+ push: expression
139
+ - include: string-content
0 commit comments