-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathHTML (Datastar).sublime-syntax
195 lines (169 loc) · 6.36 KB
/
HTML (Datastar).sublime-syntax
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
%YAML 1.2
---
# https://data-star.dev/
# https://www.sublimetext.com/docs/syntax.html
name: HTML (Datastar)
scope: text.html.datastar
version: 2
extends: Packages/HTML/HTML.sublime-syntax
contexts:
tag-attributes:
- meta_prepend: true
- include: tag-data-attributes
###[ DATASTAR ATTRIBUTES ]####################################################
tag-data-attributes:
# data binding
- match: data-(?:bind|indicator|ref)(?:-|{{attribute_name_break}})
push:
- tag-data-bind-meta
- tag-data-bind-assignment
- tag-data-attribute-modifier
- tag-data-bind-name
# computed signals
- match: data-(?:computed|on-signal-change|signals)(?:-|{{attribute_name_break}})
push:
- tag-data-bind-meta
- tag-data-attribute-assignment
- tag-data-attribute-modifier
- tag-data-bind-name
# event binding
- match: data-on(?:-|{{attribute_name_break}})
push:
- tag-data-event-meta
- tag-data-attribute-assignment
- tag-data-attribute-modifier
- tag-data-attribute-name
# events and other datastar attributes
- match: data-
push:
- tag-data-attribute-meta
- tag-data-attribute-assignment
- tag-data-attribute-modifier
- tag-data-attribute-name
###[ DATASTAR BINDING ]#######################################################
tag-data-bind-meta:
- meta_include_prototype: false
- meta_scope: meta.directive.binding.datastar
- include: immediately-pop
tag-data-bind-name:
- meta_content_scope: variable.other.signal.datastar
- include: tag-data-attribute-name
tag-data-bind-assignment:
- meta_include_prototype: false
- match: =
scope: punctuation.separator.key-value.html
set: tag-data-bind-value
# don't leak meta scope to following whitespace if assignment is absent
- match: (?=\s*[^=])
pop: 1
tag-data-bind-value:
- meta_include_prototype: false
- match: \"
scope:
meta.string.html string.quoted.double.html
punctuation.definition.string.begin.html
set: tag-data-bind-value-double-quoted-content
- match: \'
scope:
meta.string.html string.quoted.single.html
punctuation.definition.string.begin.html
set: tag-data-bind-value-single-quoted-content
- match: '{{unquoted_attribute_start}}'
set: tag-data-bind-value-unquoted-content
- include: else-pop
tag-data-bind-value-double-quoted-content:
- meta_include_prototype: false
- meta_content_scope: meta.string.html variable.other.signal.datastar
- include: strings-double-quoted-end
tag-data-bind-value-single-quoted-content:
- meta_include_prototype: false
- meta_content_scope: meta.string.html variable.other.signal.datastar
- include: strings-single-quoted-end
tag-data-bind-value-unquoted-content:
- meta_include_prototype: false
- meta_content_scope: meta.string.html variable.other.signal.datastar
- include: tag-attribute-value-unquoted-end
###[ DATASTAR EVENTS ]########################################################
tag-data-event-meta:
- meta_include_prototype: false
- meta_scope: meta.directive.event.datastar
- include: immediately-pop
###[ DATASTAR ATTRIBUTES ]####################################################
tag-data-attribute-meta:
- meta_include_prototype: false
- meta_scope: meta.directive.other.datastar
- include: immediately-pop
tag-data-attribute-name:
# use branching and dedicated contexts to enable (e.g.: PHP tags) in names,
# starting with identifier assuming qualifier being less likely
- meta_include_prototype: false
- match: ''
branch_point: tag-data-attribute-name
branch:
- tag-data-attribute-identifier
- tag-data-attribute-qualifier
tag-data-attribute-identifier:
- match: (?=__|{{attribute_name_break_char}})
pop: 2
- match: (?=\.)
fail: tag-data-attribute-name
- include: tag-data-attribute-name-content
tag-data-attribute-qualifier:
- clear_scopes: 1
- meta_content_scope: variable.namespace.datastar
- match: \.
scope: punctuation.accessor.dot.datastar
pop: 1
- include: tag-data-attribute-name-content
tag-data-attribute-name-content:
- match: \*{1,2}
scope: constant.other.wildcard.asterisk.datastar
- match: '["''`<]'
scope: invalid.illegal.attribute-name.html
tag-data-attribute-modifier:
# https://data-star.dev/reference/attribute_plugins#modifiers-5
- meta_include_prototype: false
- meta_scope: entity.other.attribute-name.datastar.html
- match: __
scope: punctuation.separator.modifier.datastar
push: tag-data-attribute-modifier-name
- match: \.
scope: punctuation.separator.key-value.datastar
push: tag-data-attribute-modifier-value
- include: immediately-pop
tag-data-attribute-modifier-name:
- meta_content_scope: storage.modifier.datastar
- match: (?=__|[.{{attribute_name_break_char}}])
pop: 1
tag-data-attribute-modifier-value:
- meta_content_scope: constant.other.value.datastar
- match: (?=__|{{attribute_name_break_char}})
pop: 1
tag-data-attribute-assignment:
- meta_include_prototype: false
- match: =
scope: punctuation.separator.key-value.html
set:
- immediately-pop # workaround https://github.com/sublimehq/sublime_text/issues/4069
- tag-data-attribute-value
# don't leak meta scope to following whitespace if assignment is absent
- match: (?=\s*[^=])
pop: 1
tag-data-attribute-value:
- match: \"
scope: meta.string.html string.quoted.double.html punctuation.definition.string.begin.html
embed: scope:source.js.embedded.html.datastar#expressions
embed_scope: meta.string.html meta.embedded.datastar source.js.embedded.html
escape: \"
escape_captures:
0: meta.string.html string.quoted.double.html punctuation.definition.string.end.html
pop: 1
- match: \'
scope: meta.string.html string.quoted.single.html punctuation.definition.string.begin.html
embed: scope:source.js.embedded.html.datastar#expressions
embed_scope: meta.string.html meta.embedded.datastar source.js.embedded.html
escape: \'
escape_captures:
0: meta.string.html string.quoted.single.html punctuation.definition.string.end.html
pop: 1
- include: else-pop