-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathd2.tmLanguage.yaml
296 lines (294 loc) · 9.94 KB
/
d2.tmLanguage.yaml
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
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
# This file is not autogenerated. This field is to make it clear that the
# d2.tmLanguage.json is autogenerated. See d2.tmLanguage.json
"comment": "*************** AUTO GENERATED DO NOT EDIT BY HAND, SEE d2.tmLanguage.yaml ****************"
# Only the following scopes are relevant for color schemes:
#
# invalid.illegal for errors
# punctuation for punctuation
# string for strings
# constant.character.escape for escapes
# entity.name.tag for keys
# keyword for keywords
# keyword.operator for * $ &
# constant.numeric for numbers
# constant.language.boolean for booleans
# constant.language.null for null
# comment for comments
#
# To inspect the colors of the current theme at the above scopes uncomment debug in
# patterns and then paste the above block into a new .d2 file. Remember to disable debug
# before committing!
#
# Search the below scopes for more specific theming requirements if necessary. For
# example, meta.key.edge.d2 lets you style edge hyphens and arrows. Or meta.key.group.d2
# to style parenthesis in key groups.
name: d2
scopeName: source.d2
patterns:
# - include: '#debug'
- include: "#block_comment"
- include: "#comment"
- include: "#semicolon"
- include: "#spread_substitution"
- include: "#spread_import"
- include: "#key_value"
- include: "#key"
- include: "#error"
repository:
error:
name: invalid.illegal.d2
match: '\S[^;\n]*'
string:
patterns:
- name: meta.string.quoted.single.d2
contentName: string.quoted.single.d2
captures: { 0: { name: punctuation.quote.single.d2 } }
begin: "'"
end: '''|(?=\n)'
patterns:
- include: "#escape"
- name: meta.string.quoted.double.d2
contentName: string.quoted.double.d2
captures: { 0: { name: punctuation.quote.double.d2 } }
begin: '"'
end: '"|(?=\n)'
patterns:
- include: "#escape"
- name: meta.string.block.shellscript.d2
captures: { 0: { name: punctuation.block.d2 } }
begin: '\|([^[:alnum:]]*)sh[\n[:space:]]'
end: '\1\|'
patterns:
- include: source.shell
- name: meta.string.block.markdown.d2
captures: { 0: { name: punctuation.block.d2 } }
begin: '\|([^[:alnum:]]*)md[\n[:space:]]'
end: '\1\|'
patterns:
- include: text.html.markdown.d2
- name: meta.string.block.js.d2
captures: { 0: { name: punctuation.block.d2 } }
begin: '\|([^[:alnum:]]*)js[\n[:space:]]'
end: '\1\|'
patterns:
- include: source.js
- name: meta.string.block.go.d2
captures: { 0: { name: punctuation.block.d2 } }
begin: '\|([^[:alnum:]]*)go[\n[:space:]]'
end: '\1\|'
patterns:
- include: source.go
- name: meta.string.block.text.d2
captures: { 0: { name: punctuation.block.d2 } }
begin: '\|([^[:alnum:]]*)text[\n[:space:]]'
end: '\1\|'
- name: meta.string.block.d2.d2
captures: { 0: { name: punctuation.block.d2 } }
begin: '\|([^[:alnum:]]*)d2[\n[:space:]]'
end: '\1\|'
patterns:
- include: source.d2
- name: meta.string.block.markdown.d2
captures: { 0: { name: punctuation.block.d2 } }
begin: '\|([^[:alnum:]]*)[\n[:space:]]'
end: '\1\|'
patterns:
- include: text.html.markdown.d2
- name: meta.string.block.d2
captures: { 0: { name: punctuation.block.d2 } }
begin: '\|([^[:alnum:]]*)[^[:space:]]+[\n[:space:]]'
end: '\1\|'
- name: string.unquoted.d2
begin: '(?=[^[:space:]\n#;\[\]{}|$''"])'
end: '(?=\s*[\n#;\[\]{}])'
patterns:
- include: "#escape"
escape:
patterns:
- name: constant.character.escape.d2
match: '\\U\h{8}'
- name: constant.character.escape.d2
match: '\\u\h{4}'
- name: constant.character.escape.d2
match: '\\[0-7]{3}'
- name: constant.character.escape.d2
match: '\\x\h{2}'
- name: constant.character.escape.d2
match: '\\.'
- name: constant.character.escape.d2
match: '\\\n'
line_continuation:
name: constant.character.escape.d2
match: '\\\n'
key:
patterns:
- name: meta.key.quoted.single.d2
contentName: entity.name.tag.quoted.single.d2
captures: { 0: { name: punctuation.quote.single.d2 } }
begin: "'"
end: '''|(?=\n)'
patterns:
- include: "#escape"
- name: meta.key.quoted.double.d2
contentName: entity.name.tag.quoted.double.d2
captures: { 0: { name: punctuation.quote.double.d2 } }
begin: '"'
end: '"|(?=\n)'
patterns:
- include: "#escape"
- name: meta.key.group.d2
captures: { 0: { name: punctuation.parenthesis.d2 } }
begin: '\('
end: '\)(?:\[(?:[0-9_]+|\*)\])?'
patterns:
- include: "#key"
- include: "#error"
- name: keyword.reserved.d2
match: '(?:grid\-gap|vertical\-gap|horizontal\-gap|classes|direction|grid\-columns|grid\-rows|text\-transform|shape|layers|steps|tooltip|font|bold|italic|underline|top|left|icon|constraint|near|opacity|stroke|fill\-pattern|fill|filled|stroke\-width|width|height|double\-border|border\-radius|source\-arrowhead|target\-arrowhead|link|stroke\-dash|font\-size|font\-color|shadow|multiple|3d|animated|class|label|style|vars|scenarios|on_click|src|dst)(?=\s*[\n#;\[\]{}|$''":.<>*&()]|-+-|-+>|-+\*)'
- name: punctuation.period.d2
match: '\.'
- name: keyword.operator.glob.d2
match: '\*'
- name: keyword.operator.double_glob.d2
match: '\*\*'
- name: keyword.operator.ampersand.d2
match: "&"
- name: keyword.operator.not_ampersand.d2
match: "!&"
- name: entity.name.tag.unquoted.d2
begin: '(?=[^[:space:]\n#;\[\]{}|$''":.<>*&()])(?!-+-)(?!-+>)(?!-+\*)'
end: '(?=\s*[\n#;\[\]{}|$:.<>*&()]|-+-|-+>|-+\*)'
patterns:
- include: "#escape"
- name: meta.key.edge.d2
captures: { 0: { name: punctuation.edge.d2 } }
begin: '[\-<>]+'
end: '(?=[^\-<>])'
patterns:
- include: "#line_continuation"
null:
name: constant.language.null.d2
match: 'null(?=\s|\n)'
boolean:
name: constant.language.boolean.d2
match: '(?:true|false)(?=\s|\n)'
number:
patterns:
- name: constant.numeric.hexadecimal.d2
match: '[+-]?0[xX][[:xdigit:]_]*\.?[[:xdigit:]_]*(?:[eEpP][+-]?[0-9_]*)?(?=\s|\n)'
- name: constant.numeric.binary.d2
match: '[+-]?0[bB][01_]*\.?[01_]*(?:[eEpP][+-]?[0-9_]*)?(?=\s|\n)'
- name: constant.numeric.octal.d2
match: '[+-]?0[oO]?[0-7_]*\.?[0-7_]*(?=\s|\n)'
- name: constant.numeric.decimal.d2
match: '[+-]?[0-9_]+(?:[eEpP][+-]?[0-9_]*)?(?=\s|\n)'
- name: constant.numeric.decimal.d2
match: '[+-]?[0-9_]*\.[0-9_]+(?:[eEpP][+-]?[0-9_]*)?(?=\s|\n)'
substitution:
name: meta.operator.substitution.d2
captures: { 0: { name: keyword.operator.substitution.d2 } }
begin: '\$\{'
end: '\}'
patterns:
- include: "#key"
import:
name: meta.operator.import.d2
captures: { 0: { name: keyword.operator.import.d2 } }
begin: '@'
end: '(?=\s*[\n#;\[\]{}|$])'
patterns:
- include: "#key"
spread_substitution:
name: meta.operator.substitution.d2
captures: { 0: { name: keyword.operator.substitution.d2 } }
begin: '\.\.\.\$\{'
end: '\}'
patterns:
- include: "#key"
spread_import:
name: meta.operator.import.d2
captures: { 0: { name: keyword.operator.import.d2 } }
begin: '\.\.\.@'
end: '(?=\s*[\n#;\[\]{}|$])'
patterns:
- include: "#key"
array:
name: meta.array.d2
captures: { 0: { name: punctuation.array.d2 } }
begin: '\['
end: '\]'
patterns:
- include: "#block_comment"
- include: "#comment"
- include: "#semicolon"
- include: "#substitution"
- include: "#import"
- include: "#spread_substitution"
- include: "#spread_import"
- include: "#value"
- include: "#error"
map:
name: meta.map.d2
captures: { 0: { name: punctuation.map.d2 } }
begin: '\{'
end: '\}'
patterns:
- include: $self
key_value:
name: meta.key_value.d2
beginCaptures: { 0: { name: punctuation.colon.d2 } }
begin: ":"
end: '(?=\s*[\n#;\]}])'
patterns:
- include: "#value"
- include: "#error"
value:
patterns:
- include: "#boolean"
- include: "#null"
- include: "#number"
- include: "#substitution"
- include: "#import"
- include: "#array"
- include: "#map"
- include: "#string"
semicolon:
name: punctuation.semicolon.d2
match: ";"
# Single line comment
comment:
name: comment.line.number-sign.d2
match: "#.*$"
# Multi line comment
block_comment:
patterns:
- name: comment.block.d2
begin: '"""'
end: '"""'
beginCaptures: { 0: { name: punctuation.comment.start.d2 }}
endCaptures: { 0: { name: punctuation.comment.end.d2 }}
# See comment near top for debug's purpose.
debug:
patterns:
- name: invalid.illegal
match: '.*invalid\.illegal.*'
- name: punctuation
match: ".*punctuation.*"
- name: string
match: ".*string.*"
- name: constant.character.escape
match: '.*constant\.character\.escape.*'
- name: entity.name.tag
match: '.*entity\.name\.tag.*'
- name: keyword
match: ".*keyword.*"
- name: keyword.operator
match: '.*keyword\.operator.*'
- name: constant.numeric
match: '.*constant\.numeric.*'
- name: constant.language.boolean
match: '.*constant\.language\.boolean.*'
- name: constant.language.null
match: '.*constant\.language\.null.*'
- name: comment
match: ".*comment.*"