crates/highlight/syntaxes/yaml.json 16.1 KiB raw
1
{
2
  "displayName": "YAML",
3
  "fileTypes": [
4
    "yaml",
5
    "yml",
6
    "rviz",
7
    "reek",
8
    "clang-format",
9
    "yaml-tmlanguage",
10
    "syntax",
11
    "sublime-syntax"
12
  ],
13
  "firstLineMatch": "^%YAML( ?1.\\d+)?",
14
  "name": "yaml",
15
  "patterns": [
16
    {
17
      "include": "#comment"
18
    },
19
    {
20
      "include": "#property"
21
    },
22
    {
23
      "include": "#directive"
24
    },
25
    {
26
      "match": "^---",
27
      "name": "entity.other.document.begin.yaml"
28
    },
29
    {
30
      "match": "^\\.{3}",
31
      "name": "entity.other.document.end.yaml"
32
    },
33
    {
34
      "include": "#node"
35
    }
36
  ],
37
  "repository": {
38
    "block-collection": {
39
      "patterns": [
40
        {
41
          "include": "#block-sequence"
42
        },
43
        {
44
          "include": "#block-mapping"
45
        }
46
      ]
47
    },
48
    "block-mapping": {
49
      "patterns": [
50
        {
51
          "include": "#block-pair"
52
        }
53
      ]
54
    },
55
    "block-node": {
56
      "patterns": [
57
        {
58
          "include": "#prototype"
59
        },
60
        {
61
          "include": "#block-scalar"
62
        },
63
        {
64
          "include": "#block-collection"
65
        },
66
        {
67
          "include": "#flow-scalar-plain-out"
68
        },
69
        {
70
          "include": "#flow-node"
71
        }
72
      ]
73
    },
74
    "block-pair": {
75
      "patterns": [
76
        {
77
          "begin": "\\?",
78
          "beginCaptures": {
79
            "1": {
80
              "name": "punctuation.definition.key-value.begin.yaml"
81
            }
82
          },
83
          "end": "(?=\\?)|^ *(:)|(:)",
84
          "endCaptures": {
85
            "1": {
86
              "name": "punctuation.separator.key-value.mapping.yaml"
87
            },
88
            "2": {
89
              "name": "invalid.illegal.expected-newline.yaml"
90
            }
91
          },
92
          "name": "meta.block-mapping.yaml",
93
          "patterns": [
94
            {
95
              "include": "#block-node"
96
            }
97
          ]
98
        },
99
        {
100
          "begin": "(?=(?:[^-\\]!\"#%\\&'*,:>?@\\[`{|}\\s]|[-:?]\\S)([^:\\s]|:\\S|\\s+(?![#\\s]))*\\s*:(\\s|$))",
101
          "end": "(?=\\s*$|\\s+#|\\s*:(\\s|$))",
102
          "patterns": [
103
            {
104
              "include": "#flow-scalar-plain-out-implicit-type"
105
            },
106
            {
107
              "begin": "[^-\\]!\"#%\\&'*,:>?@\\[`{|}\\s]|[-:?]\\S",
108
              "beginCaptures": {
109
                "0": {
110
                  "name": "entity.name.tag.yaml"
111
                }
112
              },
113
              "contentName": "entity.name.tag.yaml",
114
              "end": "(?=\\s*$|\\s+#|\\s*:(\\s|$))",
115
              "name": "string.unquoted.plain.out.yaml"
116
            }
117
          ]
118
        },
119
        {
120
          "match": ":(?=\\s|$)",
121
          "name": "punctuation.separator.key-value.mapping.yaml"
122
        }
123
      ]
124
    },
125
    "block-scalar": {
126
      "begin": "(?:(\\|)|(>))([1-9])?([-+])?(.*\\n?)",
127
      "beginCaptures": {
128
        "1": {
129
          "name": "keyword.control.flow.block-scalar.literal.yaml"
130
        },
131
        "2": {
132
          "name": "keyword.control.flow.block-scalar.folded.yaml"
133
        },
134
        "3": {
135
          "name": "constant.numeric.indentation-indicator.yaml"
136
        },
137
        "4": {
138
          "name": "storage.modifier.chomping-indicator.yaml"
139
        },
140
        "5": {
141
          "patterns": [
142
            {
143
              "include": "#comment"
144
            },
145
            {
146
              "match": ".+",
147
              "name": "invalid.illegal.expected-comment-or-newline.yaml"
148
            }
149
          ]
150
        }
151
      },
152
      "end": "^(?=\\S)|(?!\\G)",
153
      "patterns": [
154
        {
155
          "begin": "^( +)(?! )",
156
          "end": "^(?!\\1|\\s*$)",
157
          "name": "string.unquoted.block.yaml"
158
        }
159
      ]
160
    },
161
    "block-sequence": {
162
      "match": "(-)(?!\\S)",
163
      "name": "punctuation.definition.block.sequence.item.yaml"
164
    },
165
    "comment": {
166
      "begin": "(?:^([\\t ]*)|[\\t ]+)(?=#\\p{print}*$)",
167
      "beginCaptures": {
168
        "1": {
169
          "name": "punctuation.whitespace.comment.leading.yaml"
170
        }
171
      },
172
      "end": "(?!\\G)",
173
      "patterns": [
174
        {
175
          "begin": "#",
176
          "beginCaptures": {
177
            "0": {
178
              "name": "punctuation.definition.comment.yaml"
179
            }
180
          },
181
          "end": "\\n",
182
          "name": "comment.line.number-sign.yaml"
183
        }
184
      ]
185
    },
186
    "directive": {
187
      "begin": "^%",
188
      "beginCaptures": {
189
        "0": {
190
          "name": "punctuation.definition.directive.begin.yaml"
191
        }
192
      },
193
      "end": "(?=$|[\\t ]+($|#))",
194
      "name": "meta.directive.yaml",
195
      "patterns": [
196
        {
197
          "captures": {
198
            "1": {
199
              "name": "keyword.other.directive.yaml.yaml"
200
            },
201
            "2": {
202
              "name": "constant.numeric.yaml-version.yaml"
203
            }
204
          },
205
          "match": "\\G(YAML)[\\t ]+(\\d+\\.\\d+)"
206
        },
207
        {
208
          "captures": {
209
            "1": {
210
              "name": "keyword.other.directive.tag.yaml"
211
            },
212
            "2": {
213
              "name": "storage.type.tag-handle.yaml"
214
            },
215
            "3": {
216
              "name": "support.type.tag-prefix.yaml"
217
            }
218
          },
219
          "match": "\\G(TAG)(?:[\\t ]+(!(?:[-0-9A-Za-z]*!)?)(?:[\\t ]+(!(?:%\\h{2}|[]!#$\\&-;=?-\\[_a-z~])*|(?![]!,\\[{}])(?:%\\h{2}|[]!#$\\&-;=?-\\[_a-z~])+))?)?"
220
        },
221
        {
222
          "captures": {
223
            "1": {
224
              "name": "support.other.directive.reserved.yaml"
225
            },
226
            "2": {
227
              "name": "string.unquoted.directive-name.yaml"
228
            },
229
            "3": {
230
              "name": "string.unquoted.directive-parameter.yaml"
231
            }
232
          },
233
          "match": "\\G(\\w+)(?:[\\t ]+(\\w+)(?:[\\t ]+(\\w+))?)?"
234
        },
235
        {
236
          "match": "\\S+",
237
          "name": "invalid.illegal.unrecognized.yaml"
238
        }
239
      ]
240
    },
241
    "flow-alias": {
242
      "captures": {
243
        "1": {
244
          "name": "keyword.control.flow.alias.yaml"
245
        },
246
        "2": {
247
          "name": "punctuation.definition.alias.yaml"
248
        },
249
        "3": {
250
          "name": "variable.other.alias.yaml"
251
        },
252
        "4": {
253
          "name": "invalid.illegal.character.anchor.yaml"
254
        }
255
      },
256
      "match": "((\\*))([^],/\\[{}\\s]+)([^],}\\s]\\S*)?"
257
    },
258
    "flow-collection": {
259
      "patterns": [
260
        {
261
          "include": "#flow-sequence"
262
        },
263
        {
264
          "include": "#flow-mapping"
265
        }
266
      ]
267
    },
268
    "flow-mapping": {
269
      "begin": "\\{",
270
      "beginCaptures": {
271
        "0": {
272
          "name": "punctuation.definition.mapping.begin.yaml"
273
        }
274
      },
275
      "end": "}",
276
      "endCaptures": {
277
        "0": {
278
          "name": "punctuation.definition.mapping.end.yaml"
279
        }
280
      },
281
      "name": "meta.flow-mapping.yaml",
282
      "patterns": [
283
        {
284
          "include": "#prototype"
285
        },
286
        {
287
          "match": ",",
288
          "name": "punctuation.separator.mapping.yaml"
289
        },
290
        {
291
          "include": "#flow-pair"
292
        }
293
      ]
294
    },
295
    "flow-node": {
296
      "patterns": [
297
        {
298
          "include": "#prototype"
299
        },
300
        {
301
          "include": "#flow-alias"
302
        },
303
        {
304
          "include": "#flow-collection"
305
        },
306
        {
307
          "include": "#flow-scalar"
308
        }
309
      ]
310
    },
311
    "flow-pair": {
312
      "patterns": [
313
        {
314
          "begin": "\\?",
315
          "beginCaptures": {
316
            "0": {
317
              "name": "punctuation.definition.key-value.begin.yaml"
318
            }
319
          },
320
          "end": "(?=[],}])",
321
          "name": "meta.flow-pair.explicit.yaml",
322
          "patterns": [
323
            {
324
              "include": "#prototype"
325
            },
326
            {
327
              "include": "#flow-pair"
328
            },
329
            {
330
              "include": "#flow-node"
331
            },
332
            {
333
              "begin": ":(?=\\s|$|[],\\[{}])",
334
              "beginCaptures": {
335
                "0": {
336
                  "name": "punctuation.separator.key-value.mapping.yaml"
337
                }
338
              },
339
              "end": "(?=[],}])",
340
              "patterns": [
341
                {
342
                  "include": "#flow-value"
343
                }
344
              ]
345
            }
346
          ]
347
        },
348
        {
349
          "begin": "(?=(?:[^-\\]!\"#%\\&'*,:>?@\\[`{|}\\s]|[-:?][^],\\[{}\\s])([^],:\\[{}\\s]|:[^],\\[{}\\s]|\\s+(?![#\\s]))*\\s*:(\\s|$))",
350
          "end": "(?=\\s*$|\\s+#|\\s*:(\\s|$)|\\s*:[],\\[{}]|\\s*[],\\[{}])",
351
          "name": "meta.flow-pair.key.yaml",
352
          "patterns": [
353
            {
354
              "include": "#flow-scalar-plain-in-implicit-type"
355
            },
356
            {
357
              "begin": "[^-\\]!\"#%\\&'*,:>?@\\[`{|}\\s]|[-:?][^],\\[{}\\s]",
358
              "beginCaptures": {
359
                "0": {
360
                  "name": "entity.name.tag.yaml"
361
                }
362
              },
363
              "contentName": "entity.name.tag.yaml",
364
              "end": "(?=\\s*$|\\s+#|\\s*:(\\s|$)|\\s*:[],\\[{}]|\\s*[],\\[{}])",
365
              "name": "string.unquoted.plain.in.yaml"
366
            }
367
          ]
368
        },
369
        {
370
          "include": "#flow-node"
371
        },
372
        {
373
          "begin": ":(?=\\s|$|[],\\[{}])",
374
          "captures": {
375
            "0": {
376
              "name": "punctuation.separator.key-value.mapping.yaml"
377
            }
378
          },
379
          "end": "(?=[],}])",
380
          "name": "meta.flow-pair.yaml",
381
          "patterns": [
382
            {
383
              "include": "#flow-value"
384
            }
385
          ]
386
        }
387
      ]
388
    },
389
    "flow-scalar": {
390
      "patterns": [
391
        {
392
          "include": "#flow-scalar-double-quoted"
393
        },
394
        {
395
          "include": "#flow-scalar-single-quoted"
396
        },
397
        {
398
          "include": "#flow-scalar-plain-in"
399
        }
400
      ]
401
    },
402
    "flow-scalar-double-quoted": {
403
      "begin": "\"",
404
      "beginCaptures": {
405
        "0": {
406
          "name": "punctuation.definition.string.begin.yaml"
407
        }
408
      },
409
      "end": "\"",
410
      "endCaptures": {
411
        "0": {
412
          "name": "punctuation.definition.string.end.yaml"
413
        }
414
      },
415
      "name": "string.quoted.double.yaml",
416
      "patterns": [
417
        {
418
          "match": "\\\\([ \"/0LN\\\\_abefnprtv]|x\\d\\d|u\\d{4}|U\\d{8})",
419
          "name": "constant.character.escape.yaml"
420
        },
421
        {
422
          "match": "\\\\\\n",
423
          "name": "constant.character.escape.double-quoted.newline.yaml"
424
        }
425
      ]
426
    },
427
    "flow-scalar-plain-in": {
428
      "patterns": [
429
        {
430
          "include": "#flow-scalar-plain-in-implicit-type"
431
        },
432
        {
433
          "begin": "[^-\\]!\"#%\\&'*,:>?@\\[`{|}\\s]|[-:?][^],\\[{}\\s]",
434
          "end": "(?=\\s*$|\\s+#|\\s*:(\\s|$)|\\s*:[],\\[{}]|\\s*[],\\[{}])",
435
          "name": "string.unquoted.plain.in.yaml"
436
        }
437
      ]
438
    },
439
    "flow-scalar-plain-in-implicit-type": {
440
      "patterns": [
441
        {
442
          "captures": {
443
            "1": {
444
              "name": "constant.language.null.yaml"
445
            },
446
            "2": {
447
              "name": "constant.language.boolean.yaml"
448
            },
449
            "3": {
450
              "name": "constant.numeric.integer.yaml"
451
            },
452
            "4": {
453
              "name": "constant.numeric.float.yaml"
454
            },
455
            "5": {
456
              "name": "constant.other.timestamp.yaml"
457
            },
458
            "6": {
459
              "name": "constant.language.value.yaml"
460
            },
461
            "7": {
462
              "name": "constant.language.merge.yaml"
463
            }
464
          },
465
          "match": "(?:(null|Null|NULL|~)|([Yy]|yes|Yes|YES|[Nn]|no|No|NO|true|True|TRUE|false|False|FALSE|on|On|ON|off|Off|OFF)|([-+]?0b[01_]+|[-+]?0[0-7_]+|[-+]?(?:0|[1-9][0-9_]*)|[-+]?0x[_\\h]+|[-+]?[1-9][0-9_]*(?::[0-5]?[0-9])+)|([-+]?(?:[0-9][0-9_]*)?\\.[.0-9]*(?:[Ee][-+][0-9]+)?|[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+\\.[0-9_]*|[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))|(\\d{4}-\\d{2}-\\d{2}|\\d{4}-\\d{1,2}-\\d{1,2}(?:[Tt]|[\\t ]+)\\d{1,2}:\\d{2}:\\d{2}(?:\\.\\d*)?(?:[\\t ]*Z|[-+]\\d{1,2}(?::\\d{1,2})?)?)|(=)|(<<))(?=\\s*$|\\s+#|\\s*:(\\s|$)|\\s*:[],\\[{}]|\\s*[],\\[{}])"
466
        }
467
      ]
468
    },
469
    "flow-scalar-plain-out": {
470
      "patterns": [
471
        {
472
          "include": "#flow-scalar-plain-out-implicit-type"
473
        },
474
        {
475
          "begin": "[^-\\]!\"#%\\&'*,:>?@\\[`{|}\\s]|[-:?]\\S",
476
          "end": "(?=\\s*$|\\s+#|\\s*:(\\s|$))",
477
          "name": "string.unquoted.plain.out.yaml"
478
        }
479
      ]
480
    },
481
    "flow-scalar-plain-out-implicit-type": {
482
      "patterns": [
483
        {
484
          "captures": {
485
            "1": {
486
              "name": "constant.language.null.yaml"
487
            },
488
            "2": {
489
              "name": "constant.language.boolean.yaml"
490
            },
491
            "3": {
492
              "name": "constant.numeric.integer.yaml"
493
            },
494
            "4": {
495
              "name": "constant.numeric.float.yaml"
496
            },
497
            "5": {
498
              "name": "constant.other.timestamp.yaml"
499
            },
500
            "6": {
501
              "name": "constant.language.value.yaml"
502
            },
503
            "7": {
504
              "name": "constant.language.merge.yaml"
505
            }
506
          },
507
          "match": "(?:(null|Null|NULL|~)|([Yy]|yes|Yes|YES|[Nn]|no|No|NO|true|True|TRUE|false|False|FALSE|on|On|ON|off|Off|OFF)|([-+]?0b[01_]+|[-+]?0[0-7_]+|[-+]?(?:0|[1-9][0-9_]*)|[-+]?0x[_\\h]+|[-+]?[1-9][0-9_]*(?::[0-5]?[0-9])+)|([-+]?(?:[0-9][0-9_]*)?\\.[.0-9]*(?:[Ee][-+][0-9]+)?|[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+\\.[0-9_]*|[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))|(\\d{4}-\\d{2}-\\d{2}|\\d{4}-\\d{1,2}-\\d{1,2}(?:[Tt]|[\\t ]+)\\d{1,2}:\\d{2}:\\d{2}(?:\\.\\d*)?(?:[\\t ]*Z|[-+]\\d{1,2}(?::\\d{1,2})?)?)|(=)|(<<))(?=\\s*$|\\s+#|\\s*:(\\s|$))"
508
        }
509
      ]
510
    },
511
    "flow-scalar-single-quoted": {
512
      "begin": "'",
513
      "beginCaptures": {
514
        "0": {
515
          "name": "punctuation.definition.string.begin.yaml"
516
        }
517
      },
518
      "end": "'(?!')",
519
      "endCaptures": {
520
        "0": {
521
          "name": "punctuation.definition.string.end.yaml"
522
        }
523
      },
524
      "name": "string.quoted.single.yaml",
525
      "patterns": [
526
        {
527
          "match": "''",
528
          "name": "constant.character.escape.single-quoted.yaml"
529
        }
530
      ]
531
    },
532
    "flow-sequence": {
533
      "begin": "\\[",
534
      "beginCaptures": {
535
        "0": {
536
          "name": "punctuation.definition.sequence.begin.yaml"
537
        }
538
      },
539
      "end": "]",
540
      "endCaptures": {
541
        "0": {
542
          "name": "punctuation.definition.sequence.end.yaml"
543
        }
544
      },
545
      "name": "meta.flow-sequence.yaml",
546
      "patterns": [
547
        {
548
          "include": "#prototype"
549
        },
550
        {
551
          "match": ",",
552
          "name": "punctuation.separator.sequence.yaml"
553
        },
554
        {
555
          "include": "#flow-pair"
556
        },
557
        {
558
          "include": "#flow-node"
559
        }
560
      ]
561
    },
562
    "flow-value": {
563
      "patterns": [
564
        {
565
          "begin": "\\G(?![],}])",
566
          "end": "(?=[],}])",
567
          "name": "meta.flow-pair.value.yaml",
568
          "patterns": [
569
            {
570
              "include": "#flow-node"
571
            }
572
          ]
573
        }
574
      ]
575
    },
576
    "node": {
577
      "patterns": [
578
        {
579
          "include": "#block-node"
580
        }
581
      ]
582
    },
583
    "property": {
584
      "begin": "(?=[!\\&])",
585
      "end": "(?!\\G)",
586
      "name": "meta.property.yaml",
587
      "patterns": [
588
        {
589
          "captures": {
590
            "1": {
591
              "name": "keyword.control.property.anchor.yaml"
592
            },
593
            "2": {
594
              "name": "punctuation.definition.anchor.yaml"
595
            },
596
            "3": {
597
              "name": "entity.name.type.anchor.yaml"
598
            },
599
            "4": {
600
              "name": "invalid.illegal.character.anchor.yaml"
601
            }
602
          },
603
          "match": "\\G((&))([^],/\\[{}\\s]+)(\\S+)?"
604
        },
605
        {
606
          "match": "\\G!(?:<(?:%\\h{2}|[]!#$\\&-;=?-\\[_a-z~])+>|(?:[-0-9A-Za-z]*!)?(?:%\\h{2}|[#$\\&-+\\--;=?-Z_a-z~])+|)(?=[\\t ]|$)",
607
          "name": "storage.type.tag-handle.yaml"
608
        },
609
        {
610
          "match": "\\S+",
611
          "name": "invalid.illegal.tag-handle.yaml"
612
        }
613
      ]
614
    },
615
    "prototype": {
616
      "patterns": [
617
        {
618
          "include": "#comment"
619
        },
620
        {
621
          "include": "#property"
622
        }
623
      ]
624
    }
625
  },
626
  "scopeName": "source.yaml"
627
}