crates/highlight/syntaxes/toml.json 11.5 KiB raw
1
{
2
  "displayName": "TOML",
3
  "fileTypes": [
4
    "toml"
5
  ],
6
  "name": "toml",
7
  "patterns": [
8
    {
9
      "include": "#comments"
10
    },
11
    {
12
      "include": "#groups"
13
    },
14
    {
15
      "include": "#key_pair"
16
    },
17
    {
18
      "include": "#invalid"
19
    }
20
  ],
21
  "repository": {
22
    "comments": {
23
      "begin": "(^[\\t ]+)?(?=#)",
24
      "beginCaptures": {
25
        "1": {
26
          "name": "punctuation.whitespace.comment.leading.toml"
27
        }
28
      },
29
      "end": "(?!\\G)",
30
      "patterns": [
31
        {
32
          "begin": "#",
33
          "beginCaptures": {
34
            "0": {
35
              "name": "punctuation.definition.comment.toml"
36
            }
37
          },
38
          "end": "\\n",
39
          "name": "comment.line.number-sign.toml"
40
        }
41
      ]
42
    },
43
    "groups": {
44
      "patterns": [
45
        {
46
          "captures": {
47
            "1": {
48
              "name": "punctuation.definition.section.begin.toml"
49
            },
50
            "2": {
51
              "patterns": [
52
                {
53
                  "match": "[^.\\s]+",
54
                  "name": "entity.name.section.toml"
55
                }
56
              ]
57
            },
58
            "3": {
59
              "name": "punctuation.definition.section.begin.toml"
60
            }
61
          },
62
          "match": "^\\s*(\\[)([^]\\[]*)(])",
63
          "name": "meta.group.toml"
64
        },
65
        {
66
          "captures": {
67
            "1": {
68
              "name": "punctuation.definition.section.begin.toml"
69
            },
70
            "2": {
71
              "patterns": [
72
                {
73
                  "match": "[^.\\s]+",
74
                  "name": "entity.name.section.toml"
75
                }
76
              ]
77
            },
78
            "3": {
79
              "name": "punctuation.definition.section.begin.toml"
80
            }
81
          },
82
          "match": "^\\s*(\\[\\[)([^]\\[]*)(]])",
83
          "name": "meta.group.double.toml"
84
        }
85
      ]
86
    },
87
    "invalid": {
88
      "match": "\\S+(\\s*(?=\\S))?",
89
      "name": "invalid.illegal.not-allowed-here.toml"
90
    },
91
    "key_pair": {
92
      "patterns": [
93
        {
94
          "begin": "([-0-9A-Z_a-z]+)\\s*(=)\\s*",
95
          "captures": {
96
            "1": {
97
              "name": "variable.other.key.toml"
98
            },
99
            "2": {
100
              "name": "punctuation.separator.key-value.toml"
101
            }
102
          },
103
          "end": "(?<=\\S)(?<!=)|$",
104
          "patterns": [
105
            {
106
              "include": "#primatives"
107
            }
108
          ]
109
        },
110
        {
111
          "begin": "((\")(.*?)(\"))\\s*(=)\\s*",
112
          "captures": {
113
            "1": {
114
              "name": "variable.other.key.toml"
115
            },
116
            "2": {
117
              "name": "punctuation.definition.variable.begin.toml"
118
            },
119
            "3": {
120
              "patterns": [
121
                {
122
                  "match": "\\\\([\"\\\\bfnrt]|u\\h{4}|U\\h{8})",
123
                  "name": "constant.character.escape.toml"
124
                },
125
                {
126
                  "match": "\\\\[^\"\\\\bfnrt]",
127
                  "name": "invalid.illegal.escape.toml"
128
                },
129
                {
130
                  "match": "\"",
131
                  "name": "invalid.illegal.not-allowed-here.toml"
132
                }
133
              ]
134
            },
135
            "4": {
136
              "name": "punctuation.definition.variable.end.toml"
137
            },
138
            "5": {
139
              "name": "punctuation.separator.key-value.toml"
140
            }
141
          },
142
          "end": "(?<=\\S)(?<!=)|$",
143
          "patterns": [
144
            {
145
              "include": "#primatives"
146
            }
147
          ]
148
        },
149
        {
150
          "begin": "((')([^']*)('))\\s*(=)\\s*",
151
          "captures": {
152
            "1": {
153
              "name": "variable.other.key.toml"
154
            },
155
            "2": {
156
              "name": "punctuation.definition.variable.begin.toml"
157
            },
158
            "4": {
159
              "name": "punctuation.definition.variable.end.toml"
160
            },
161
            "5": {
162
              "name": "punctuation.separator.key-value.toml"
163
            }
164
          },
165
          "end": "(?<=\\S)(?<!=)|$",
166
          "patterns": [
167
            {
168
              "include": "#primatives"
169
            }
170
          ]
171
        },
172
        {
173
          "begin": "(((?:[-0-9A-Z_a-z]+|\"(?:[^\"\\\\]|\\\\.)*\"|'[^']*')(?:\\s*\\.\\s*|(?=\\s*=))){2,})\\s*(=)\\s*",
174
          "captures": {
175
            "1": {
176
              "name": "variable.other.key.toml",
177
              "patterns": [
178
                {
179
                  "match": "\\.",
180
                  "name": "punctuation.separator.variable.toml"
181
                },
182
                {
183
                  "captures": {
184
                    "1": {
185
                      "name": "punctuation.definition.variable.begin.toml"
186
                    },
187
                    "2": {
188
                      "patterns": [
189
                        {
190
                          "match": "\\\\([\"\\\\bfnrt]|u\\h{4}|U\\h{8})",
191
                          "name": "constant.character.escape.toml"
192
                        },
193
                        {
194
                          "match": "\\\\[^\"\\\\bfnrt]",
195
                          "name": "invalid.illegal.escape.toml"
196
                        }
197
                      ]
198
                    },
199
                    "3": {
200
                      "name": "punctuation.definition.variable.end.toml"
201
                    }
202
                  },
203
                  "match": "(\")((?:[^\"\\\\]|\\\\.)*)(\")"
204
                },
205
                {
206
                  "captures": {
207
                    "1": {
208
                      "name": "punctuation.definition.variable.begin.toml"
209
                    },
210
                    "2": {
211
                      "name": "punctuation.definition.variable.end.toml"
212
                    }
213
                  },
214
                  "match": "(')[^']*(')"
215
                }
216
              ]
217
            },
218
            "3": {
219
              "name": "punctuation.separator.key-value.toml"
220
            }
221
          },
222
          "end": "(?<=\\S)(?<!=)|$",
223
          "patterns": [
224
            {
225
              "include": "#primatives"
226
            }
227
          ]
228
        }
229
      ]
230
    },
231
    "primatives": {
232
      "patterns": [
233
        {
234
          "begin": "\\G\"\"\"",
235
          "beginCaptures": {
236
            "0": {
237
              "name": "punctuation.definition.string.begin.toml"
238
            }
239
          },
240
          "end": "\"{3,5}",
241
          "endCaptures": {
242
            "0": {
243
              "name": "punctuation.definition.string.end.toml"
244
            }
245
          },
246
          "name": "string.quoted.triple.double.toml",
247
          "patterns": [
248
            {
249
              "match": "\\\\([\"\\\\bfnrt]|u\\h{4}|U\\h{8})",
250
              "name": "constant.character.escape.toml"
251
            },
252
            {
253
              "match": "\\\\[^\\n\"\\\\bfnrt]",
254
              "name": "invalid.illegal.escape.toml"
255
            }
256
          ]
257
        },
258
        {
259
          "begin": "\\G\"",
260
          "beginCaptures": {
261
            "0": {
262
              "name": "punctuation.definition.string.begin.toml"
263
            }
264
          },
265
          "end": "\"",
266
          "endCaptures": {
267
            "0": {
268
              "name": "punctuation.definition.string.end.toml"
269
            }
270
          },
271
          "name": "string.quoted.double.toml",
272
          "patterns": [
273
            {
274
              "match": "\\\\([\"\\\\bfnrt]|u\\h{4}|U\\h{8})",
275
              "name": "constant.character.escape.toml"
276
            },
277
            {
278
              "match": "\\\\[^\"\\\\bfnrt]",
279
              "name": "invalid.illegal.escape.toml"
280
            }
281
          ]
282
        },
283
        {
284
          "begin": "\\G'''",
285
          "beginCaptures": {
286
            "0": {
287
              "name": "punctuation.definition.string.begin.toml"
288
            }
289
          },
290
          "end": "'{3,5}",
291
          "endCaptures": {
292
            "0": {
293
              "name": "punctuation.definition.string.end.toml"
294
            }
295
          },
296
          "name": "string.quoted.triple.single.toml"
297
        },
298
        {
299
          "begin": "\\G'",
300
          "beginCaptures": {
301
            "0": {
302
              "name": "punctuation.definition.string.begin.toml"
303
            }
304
          },
305
          "end": "'",
306
          "endCaptures": {
307
            "0": {
308
              "name": "punctuation.definition.string.end.toml"
309
            }
310
          },
311
          "name": "string.quoted.single.toml"
312
        },
313
        {
314
          "match": "\\G[0-9]{4}-(0[1-9]|1[012])-(?!00|3[2-9])[0-3][0-9]([ Tt](?!2[5-9])[012][0-9]:[0-5][0-9]:(?!6[1-9])[0-6][0-9](\\.[0-9]+)?(Z|[-+](?!2[5-9])[012][0-9]:[0-5][0-9])?)?",
315
          "name": "constant.other.date.toml"
316
        },
317
        {
318
          "match": "\\G(?!2[5-9])[012][0-9]:[0-5][0-9]:(?!6[1-9])[0-6][0-9](\\.[0-9]+)?",
319
          "name": "constant.other.time.toml"
320
        },
321
        {
322
          "match": "\\G(true|false)",
323
          "name": "constant.language.boolean.toml"
324
        },
325
        {
326
          "match": "\\G0x\\h(_??\\h)*",
327
          "name": "constant.numeric.hex.toml"
328
        },
329
        {
330
          "match": "\\G0o[0-7]([0-7]|_[0-7])*",
331
          "name": "constant.numeric.octal.toml"
332
        },
333
        {
334
          "match": "\\G0b[01]([01]|_[01])*",
335
          "name": "constant.numeric.binary.toml"
336
        },
337
        {
338
          "match": "\\G[-+]?(inf|nan)",
339
          "name": "constant.numeric.toml"
340
        },
341
        {
342
          "match": "\\G([-+]?(0|([1-9](([0-9]|_[0-9])+)?)))(?=[.Ee])(\\.([0-9](([0-9]|_[0-9])+)?))?([Ee]([-+]?[0-9](([0-9]|_[0-9])+)?))?",
343
          "name": "constant.numeric.float.toml"
344
        },
345
        {
346
          "match": "\\G([-+]?(0|([1-9](([0-9]|_[0-9])+)?)))",
347
          "name": "constant.numeric.integer.toml"
348
        },
349
        {
350
          "begin": "\\G\\[",
351
          "beginCaptures": {
352
            "0": {
353
              "name": "punctuation.definition.array.begin.toml"
354
            }
355
          },
356
          "end": "]",
357
          "endCaptures": {
358
            "0": {
359
              "name": "punctuation.definition.array.end.toml"
360
            }
361
          },
362
          "name": "meta.array.toml",
363
          "patterns": [
364
            {
365
              "begin": "(?=[\"']|[-+]?[0-9]|[-+]?(inf|nan)|true|false|[\\[{])",
366
              "end": ",|(?=])",
367
              "endCaptures": {
368
                "0": {
369
                  "name": "punctuation.separator.array.toml"
370
                }
371
              },
372
              "patterns": [
373
                {
374
                  "include": "#primatives"
375
                },
376
                {
377
                  "include": "#comments"
378
                },
379
                {
380
                  "include": "#invalid"
381
                }
382
              ]
383
            },
384
            {
385
              "include": "#comments"
386
            },
387
            {
388
              "include": "#invalid"
389
            }
390
          ]
391
        },
392
        {
393
          "begin": "\\G\\{",
394
          "beginCaptures": {
395
            "0": {
396
              "name": "punctuation.definition.inline-table.begin.toml"
397
            }
398
          },
399
          "end": "}",
400
          "endCaptures": {
401
            "0": {
402
              "name": "punctuation.definition.inline-table.end.toml"
403
            }
404
          },
405
          "name": "meta.inline-table.toml",
406
          "patterns": [
407
            {
408
              "begin": "(?=\\S)",
409
              "end": ",|(?=})",
410
              "endCaptures": {
411
                "0": {
412
                  "name": "punctuation.separator.inline-table.toml"
413
                }
414
              },
415
              "patterns": [
416
                {
417
                  "include": "#key_pair"
418
                }
419
              ]
420
            },
421
            {
422
              "include": "#comments"
423
            }
424
          ]
425
        }
426
      ]
427
    }
428
  },
429
  "scopeName": "source.toml"
430
}