crates/highlight/syntaxes/make.json 15.5 KiB raw
1
{
2
  "displayName": "Makefile",
3
  "name": "make",
4
  "patterns": [
5
    {
6
      "include": "#comment"
7
    },
8
    {
9
      "include": "#variables"
10
    },
11
    {
12
      "include": "#variable-assignment"
13
    },
14
    {
15
      "include": "#directives"
16
    },
17
    {
18
      "include": "#recipe"
19
    },
20
    {
21
      "include": "#target"
22
    }
23
  ],
24
  "repository": {
25
    "another-variable-braces": {
26
      "patterns": [
27
        {
28
          "begin": "(?<=\\{)(?!})",
29
          "end": "(?=}|((?<!\\\\)\\n))",
30
          "name": "variable.other.makefile",
31
          "patterns": [
32
            {
33
              "include": "#variables"
34
            },
35
            {
36
              "match": "\\\\\\n",
37
              "name": "constant.character.escape.continuation.makefile"
38
            }
39
          ]
40
        }
41
      ]
42
    },
43
    "another-variable-parentheses": {
44
      "patterns": [
45
        {
46
          "begin": "(?<=\\()(?!\\))",
47
          "end": "(?=\\)|((?<!\\\\)\\n))",
48
          "name": "variable.other.makefile",
49
          "patterns": [
50
            {
51
              "include": "#variables"
52
            },
53
            {
54
              "match": "\\\\\\n",
55
              "name": "constant.character.escape.continuation.makefile"
56
            }
57
          ]
58
        }
59
      ]
60
    },
61
    "braces-interpolation": {
62
      "begin": "\\{",
63
      "end": "}",
64
      "patterns": [
65
        {
66
          "include": "#variables"
67
        },
68
        {
69
          "include": "#interpolation"
70
        }
71
      ]
72
    },
73
    "builtin-variable-braces": {
74
      "patterns": [
75
        {
76
          "match": "(?<=\\{)(MAKEFILES|VPATH|SHELL|MAKESHELL|MAKE|MAKELEVEL|MAKEFLAGS|MAKECMDGOALS|CURDIR|SUFFIXES|\\.LIBPATTERNS)(?=\\s*})",
77
          "name": "variable.language.makefile"
78
        }
79
      ]
80
    },
81
    "builtin-variable-parentheses": {
82
      "patterns": [
83
        {
84
          "match": "(?<=\\()(MAKEFILES|VPATH|SHELL|MAKESHELL|MAKE|MAKELEVEL|MAKEFLAGS|MAKECMDGOALS|CURDIR|SUFFIXES|\\.LIBPATTERNS)(?=\\s*\\))",
85
          "name": "variable.language.makefile"
86
        }
87
      ]
88
    },
89
    "comma": {
90
      "match": ",",
91
      "name": "punctuation.separator.delimeter.comma.makefile"
92
    },
93
    "comment": {
94
      "begin": "(^ +)?((?<!\\\\)(\\\\\\\\)*)(?=#)",
95
      "beginCaptures": {
96
        "1": {
97
          "name": "punctuation.whitespace.comment.leading.makefile"
98
        }
99
      },
100
      "end": "(?!\\G)",
101
      "patterns": [
102
        {
103
          "begin": "#",
104
          "beginCaptures": {
105
            "0": {
106
              "name": "punctuation.definition.comment.makefile"
107
            }
108
          },
109
          "end": "(?=[^\\\\])$",
110
          "name": "comment.line.number-sign.makefile",
111
          "patterns": [
112
            {
113
              "match": "\\\\\\n",
114
              "name": "constant.character.escape.continuation.makefile"
115
            }
116
          ]
117
        }
118
      ]
119
    },
120
    "directives": {
121
      "patterns": [
122
        {
123
          "begin": "^ *([-s]?include)\\b",
124
          "beginCaptures": {
125
            "1": {
126
              "name": "keyword.control.include.makefile"
127
            }
128
          },
129
          "end": "^",
130
          "patterns": [
131
            {
132
              "include": "#comment"
133
            },
134
            {
135
              "include": "#variables"
136
            },
137
            {
138
              "match": "%",
139
              "name": "constant.other.placeholder.makefile"
140
            }
141
          ]
142
        },
143
        {
144
          "begin": "^ *(vpath)\\b",
145
          "beginCaptures": {
146
            "1": {
147
              "name": "keyword.control.vpath.makefile"
148
            }
149
          },
150
          "end": "^",
151
          "patterns": [
152
            {
153
              "include": "#comment"
154
            },
155
            {
156
              "include": "#variables"
157
            },
158
            {
159
              "match": "%",
160
              "name": "constant.other.placeholder.makefile"
161
            }
162
          ]
163
        },
164
        {
165
          "begin": "^\\s*(?:(override)\\s*)?(define)\\s*(\\S+)\\s*([+:?]??=)?(?=\\s)",
166
          "captures": {
167
            "1": {
168
              "name": "keyword.control.override.makefile"
169
            },
170
            "2": {
171
              "name": "keyword.control.define.makefile"
172
            },
173
            "3": {
174
              "name": "variable.other.makefile"
175
            },
176
            "4": {
177
              "name": "punctuation.separator.key-value.makefile"
178
            }
179
          },
180
          "end": "^\\s*(endef)\\b",
181
          "name": "meta.scope.conditional.makefile",
182
          "patterns": [
183
            {
184
              "begin": "\\G(?!\\n)",
185
              "end": "^",
186
              "patterns": [
187
                {
188
                  "include": "#comment"
189
                }
190
              ]
191
            },
192
            {
193
              "include": "#variables"
194
            },
195
            {
196
              "include": "#directives"
197
            }
198
          ]
199
        },
200
        {
201
          "begin": "^ *(export)\\b",
202
          "beginCaptures": {
203
            "1": {
204
              "name": "keyword.control.$1.makefile"
205
            }
206
          },
207
          "end": "^",
208
          "patterns": [
209
            {
210
              "include": "#comment"
211
            },
212
            {
213
              "include": "#variable-assignment"
214
            },
215
            {
216
              "match": "\\S+",
217
              "name": "variable.other.makefile"
218
            }
219
          ]
220
        },
221
        {
222
          "begin": "^ *(override|private)\\b",
223
          "beginCaptures": {
224
            "1": {
225
              "name": "keyword.control.$1.makefile"
226
            }
227
          },
228
          "end": "^",
229
          "patterns": [
230
            {
231
              "include": "#comment"
232
            },
233
            {
234
              "include": "#variable-assignment"
235
            }
236
          ]
237
        },
238
        {
239
          "begin": "^ *(un(?:export|define))\\b",
240
          "beginCaptures": {
241
            "1": {
242
              "name": "keyword.control.$1.makefile"
243
            }
244
          },
245
          "end": "^",
246
          "patterns": [
247
            {
248
              "include": "#comment"
249
            },
250
            {
251
              "match": "\\S+",
252
              "name": "variable.other.makefile"
253
            }
254
          ]
255
        },
256
        {
257
          "begin": "^\\s*(ifn??(?:eq|def))(?=\\s)",
258
          "captures": {
259
            "1": {
260
              "name": "keyword.control.$1.makefile"
261
            }
262
          },
263
          "end": "^\\s*(endif)\\b",
264
          "name": "meta.scope.conditional.makefile",
265
          "patterns": [
266
            {
267
              "begin": "\\G",
268
              "end": "^",
269
              "name": "meta.scope.condition.makefile",
270
              "patterns": [
271
                {
272
                  "include": "#comma"
273
                },
274
                {
275
                  "include": "#variables"
276
                },
277
                {
278
                  "include": "#comment"
279
                }
280
              ]
281
            },
282
            {
283
              "begin": "^\\s*else(?=\\s)\\s*(ifn??(?:eq|def))*(?=\\s)",
284
              "beginCaptures": {
285
                "0": {
286
                  "name": "keyword.control.else.makefile"
287
                }
288
              },
289
              "end": "^",
290
              "patterns": [
291
                {
292
                  "include": "#comma"
293
                },
294
                {
295
                  "include": "#variables"
296
                },
297
                {
298
                  "include": "#comment"
299
                }
300
              ]
301
            },
302
            {
303
              "include": "$self"
304
            }
305
          ]
306
        }
307
      ]
308
    },
309
    "flavor-variable-braces": {
310
      "patterns": [
311
        {
312
          "begin": "(?<=\\{)(origin|flavor)\\s(?=[^}\\s]+\\s*})",
313
          "beginCaptures": {
314
            "1": {
315
              "name": "support.function.$1.makefile"
316
            }
317
          },
318
          "contentName": "variable.other.makefile",
319
          "end": "(?=})",
320
          "name": "meta.scope.function-call.makefile",
321
          "patterns": [
322
            {
323
              "include": "#variables"
324
            }
325
          ]
326
        }
327
      ]
328
    },
329
    "flavor-variable-parentheses": {
330
      "patterns": [
331
        {
332
          "begin": "(?<=\\()(origin|flavor)\\s(?=[^)\\s]+\\s*\\))",
333
          "beginCaptures": {
334
            "1": {
335
              "name": "support.function.$1.makefile"
336
            }
337
          },
338
          "contentName": "variable.other.makefile",
339
          "end": "(?=\\))",
340
          "name": "meta.scope.function-call.makefile",
341
          "patterns": [
342
            {
343
              "include": "#variables"
344
            }
345
          ]
346
        }
347
      ]
348
    },
349
    "function-variable-braces": {
350
      "patterns": [
351
        {
352
          "begin": "(?<=\\{)(subst|patsubst|strip|findstring|filter(-out)?|sort|word(list)?|firstword|lastword|dir|notdir|suffix|basename|addsuffix|addprefix|join|wildcard|realpath|abspath|info|error|warning|shell|foreach|if|or|and|call|eval|value|file|guile)\\s",
353
          "beginCaptures": {
354
            "1": {
355
              "name": "support.function.$1.makefile"
356
            }
357
          },
358
          "end": "(?=}|((?<!\\\\)\\n))",
359
          "name": "meta.scope.function-call.makefile",
360
          "patterns": [
361
            {
362
              "include": "#comma"
363
            },
364
            {
365
              "include": "#variables"
366
            },
367
            {
368
              "include": "#interpolation"
369
            },
370
            {
371
              "match": "[%*]",
372
              "name": "constant.other.placeholder.makefile"
373
            },
374
            {
375
              "match": "\\\\\\n",
376
              "name": "constant.character.escape.continuation.makefile"
377
            }
378
          ]
379
        }
380
      ]
381
    },
382
    "function-variable-parentheses": {
383
      "patterns": [
384
        {
385
          "begin": "(?<=\\()(subst|patsubst|strip|findstring|filter(-out)?|sort|word(list)?|firstword|lastword|dir|notdir|suffix|basename|addsuffix|addprefix|join|wildcard|realpath|abspath|info|error|warning|shell|foreach|if|or|and|call|eval|value|file|guile)\\s",
386
          "beginCaptures": {
387
            "1": {
388
              "name": "support.function.$1.makefile"
389
            }
390
          },
391
          "end": "(?=\\)|((?<!\\\\)\\n))",
392
          "name": "meta.scope.function-call.makefile",
393
          "patterns": [
394
            {
395
              "include": "#comma"
396
            },
397
            {
398
              "include": "#variables"
399
            },
400
            {
401
              "include": "#interpolation"
402
            },
403
            {
404
              "match": "[%*]",
405
              "name": "constant.other.placeholder.makefile"
406
            },
407
            {
408
              "match": "\\\\\\n",
409
              "name": "constant.character.escape.continuation.makefile"
410
            }
411
          ]
412
        }
413
      ]
414
    },
415
    "interpolation": {
416
      "patterns": [
417
        {
418
          "include": "#parentheses-interpolation"
419
        },
420
        {
421
          "include": "#braces-interpolation"
422
        }
423
      ]
424
    },
425
    "parentheses-interpolation": {
426
      "begin": "\\(",
427
      "end": "\\)",
428
      "patterns": [
429
        {
430
          "include": "#variables"
431
        },
432
        {
433
          "include": "#interpolation"
434
        }
435
      ]
436
    },
437
    "recipe": {
438
      "begin": "^\\t([-+@]*)",
439
      "beginCaptures": {
440
        "1": {
441
          "name": "keyword.control.$1.makefile"
442
        }
443
      },
444
      "end": "[^\\\\]$",
445
      "name": "meta.scope.recipe.makefile",
446
      "patterns": [
447
        {
448
          "match": "\\\\\\n",
449
          "name": "constant.character.escape.continuation.makefile"
450
        },
451
        {
452
          "include": "#variables"
453
        }
454
      ]
455
    },
456
    "simple-variable": {
457
      "patterns": [
458
        {
459
          "match": "\\$[^(){}]",
460
          "name": "variable.language.makefile"
461
        }
462
      ]
463
    },
464
    "target": {
465
      "begin": "^(?!\\t)([^:]*)(:)(?!=)",
466
      "beginCaptures": {
467
        "1": {
468
          "patterns": [
469
            {
470
              "captures": {
471
                "1": {
472
                  "name": "support.function.target.$1.makefile"
473
                }
474
              },
475
              "match": "^\\s*(\\.(PHONY|SUFFIXES|DEFAULT|PRECIOUS|INTERMEDIATE|SECONDARY|SECONDEXPANSION|DELETE_ON_ERROR|IGNORE|LOW_RESOLUTION_TIME|SILENT|EXPORT_ALL_VARIABLES|NOTPARALLEL|ONESHELL|POSIX))\\s*$"
476
            },
477
            {
478
              "begin": "(?=\\S)",
479
              "end": "(?=\\s|$)",
480
              "name": "entity.name.function.target.makefile",
481
              "patterns": [
482
                {
483
                  "include": "#variables"
484
                },
485
                {
486
                  "match": "%",
487
                  "name": "constant.other.placeholder.makefile"
488
                }
489
              ]
490
            }
491
          ]
492
        },
493
        "2": {
494
          "name": "punctuation.separator.key-value.makefile"
495
        }
496
      },
497
      "end": "[^\\\\]$",
498
      "name": "meta.scope.target.makefile",
499
      "patterns": [
500
        {
501
          "begin": "\\G",
502
          "end": "(?=[^\\\\])$",
503
          "name": "meta.scope.prerequisites.makefile",
504
          "patterns": [
505
            {
506
              "match": "\\\\\\n",
507
              "name": "constant.character.escape.continuation.makefile"
508
            },
509
            {
510
              "match": "[%*]",
511
              "name": "constant.other.placeholder.makefile"
512
            },
513
            {
514
              "include": "#comment"
515
            },
516
            {
517
              "include": "#variables"
518
            }
519
          ]
520
        }
521
      ]
522
    },
523
    "variable-assignment": {
524
      "begin": "(^ *|\\G\\s*)([^#:=\\s]+)\\s*((?:(?<![!+:?])|[!+:?])=)",
525
      "beginCaptures": {
526
        "2": {
527
          "name": "variable.other.makefile",
528
          "patterns": [
529
            {
530
              "include": "#variables"
531
            }
532
          ]
533
        },
534
        "3": {
535
          "name": "punctuation.separator.key-value.makefile"
536
        }
537
      },
538
      "end": "\\n",
539
      "patterns": [
540
        {
541
          "match": "\\\\\\n",
542
          "name": "constant.character.escape.continuation.makefile"
543
        },
544
        {
545
          "include": "#comment"
546
        },
547
        {
548
          "include": "#variables"
549
        }
550
      ]
551
    },
552
    "variable-braces": {
553
      "patterns": [
554
        {
555
          "begin": "\\$\\{",
556
          "captures": {
557
            "0": {
558
              "name": "punctuation.definition.variable.makefile"
559
            }
560
          },
561
          "end": "}|((?<!\\\\)\\n)",
562
          "name": "string.interpolated.makefile",
563
          "patterns": [
564
            {
565
              "include": "#variables"
566
            },
567
            {
568
              "include": "#builtin-variable-braces"
569
            },
570
            {
571
              "include": "#function-variable-braces"
572
            },
573
            {
574
              "include": "#flavor-variable-braces"
575
            },
576
            {
577
              "include": "#another-variable-braces"
578
            }
579
          ]
580
        }
581
      ]
582
    },
583
    "variable-parentheses": {
584
      "patterns": [
585
        {
586
          "begin": "\\$\\(",
587
          "captures": {
588
            "0": {
589
              "name": "punctuation.definition.variable.makefile"
590
            }
591
          },
592
          "end": "\\)|((?<!\\\\)\\n)",
593
          "name": "string.interpolated.makefile",
594
          "patterns": [
595
            {
596
              "include": "#variables"
597
            },
598
            {
599
              "include": "#builtin-variable-parentheses"
600
            },
601
            {
602
              "include": "#function-variable-parentheses"
603
            },
604
            {
605
              "include": "#flavor-variable-parentheses"
606
            },
607
            {
608
              "include": "#another-variable-parentheses"
609
            }
610
          ]
611
        }
612
      ]
613
    },
614
    "variables": {
615
      "patterns": [
616
        {
617
          "include": "#simple-variable"
618
        },
619
        {
620
          "include": "#variable-parentheses"
621
        },
622
        {
623
          "include": "#variable-braces"
624
        }
625
      ]
626
    }
627
  },
628
  "scopeName": "source.makefile"
629
}