@@ -9,12 +9,14 @@ file_extensions:
9
9
- psm1
10
10
- psd1
11
11
12
+ variables :
13
+ bytes_unit : (?i:[kmgtp]b)
14
+
12
15
contexts :
13
16
14
17
main :
15
18
- include : comments
16
- - match : ' [2-6]>&1|>>|>|<<|<|>|>\||[1-6]>|[1-6]>>'
17
- scope : keyword.operator.redirection.powershell
19
+ - include : redirection
18
20
- include : commands
19
21
- include : variable
20
22
- include : interpolated-string-content
@@ -60,19 +62,23 @@ contexts:
60
62
- match : (?<!\w|-)((?i:class)|%|\?)(?:\s)+((?:\p{L}|\d|_|-|)+)\b
61
63
# capture should be entity.name.type, but it doesn't provide a good color in the default schema.
62
64
captures :
63
- 1 : storage.type.powershell
64
- 2 : entity.name.function
65
+ 1 : storage.type.class.powershell
66
+ 2 : meta.class.powershell entity.name.class.powershell
67
+ - match : (?<!\w)-(?i:replace)\b
68
+ scope : keyword.operator.powershell
65
69
- match : (?<!\w)-(?i:as)\b
66
70
scope : keyword.operator.comparison.powershell
67
- - match : (?<!\w)-(?i:[ic]?(?:eq|ne|[gl][te]|(?:not)?(?:like|match|contains|in)|replace ))(?!\p{L})
71
+ - match : (?<!\w)-(?i:[ic]?(?:eq|ne|[gl][te]))(?!\p{L})
68
72
scope : keyword.operator.comparison.powershell
73
+ - match : (?<!\w)-(?i:[ic]?(?:not)?(?:like|match|contains|in))(?!\p{L})
74
+ scope : keyword.operator.logical.powershell
69
75
- match : (?<!\w)-(?i:join|split)(?!\p{L})|!
70
76
scope : keyword.operator.unary.powershell
71
77
- match : (?<!\w)-(?i:is(?:not)?)\b
72
78
scope : keyword.operator.logical.powershell
73
79
- match : (?<!\w)-(?i:and|or|not|xor)(?!\p{L})|!
74
80
scope : keyword.operator.logical.powershell
75
- - match : (?<!\w)-(?i:band|bor|bnot|bxor)(?!\p{L})
81
+ - match : (?<!\w)-(?i:band|bor|bnot|bxor|sh[lr] )(?!\p{L})
76
82
scope : keyword.operator.bitwise.powershell
77
83
- match : (?<!\w)-(?i:f)(?!\p{L})
78
84
scope : keyword.operator.string-format.powershell
@@ -100,6 +106,19 @@ contexts:
100
106
- include : comment-block
101
107
- include : comment-line
102
108
109
+ redirection :
110
+ - match : ([2-6])(>&)(1)|([1-6])(>)|([1-6])(>>)
111
+ captures :
112
+ 1 : constant.numeric.decimal.file-descriptor.powershell
113
+ 2 : keyword.operator.redirection.powershell
114
+ 3 : constant.numeric.decimal.file-descriptor.powershell
115
+ 4 : constant.numeric.decimal.file-descriptor.powershell
116
+ 5 : keyword.operator.redirection.powershell
117
+ 6 : constant.numeric.decimal.file-descriptor.powershell
118
+ 7 : keyword.operator.redirection.powershell
119
+ - match : ' >>?|<<?|>\|'
120
+ scope : keyword.operator.redirection.powershell
121
+
103
122
requires-directive :
104
123
- match : (?<=#)(?i:requires)\s
105
124
scope : keyword.control.requires.powershell
@@ -131,12 +150,10 @@ contexts:
131
150
scope : punctuation.section.bracket.end.powershell
132
151
pop : true
133
152
- match : \(
134
- captures :
135
- 0 : punctuation.section.group.begin.powershell
153
+ scope : punctuation.section.group.begin.powershell
136
154
push :
137
155
- match : \)
138
- captures :
139
- 0 : punctuation.section.group.end.powershell
156
+ scope : punctuation.section.group.end.powershell
140
157
pop : true
141
158
- include : variable
142
159
- include : variable-no-property
@@ -171,13 +188,11 @@ contexts:
171
188
172
189
comment-block :
173
190
- match : <#
174
- captures :
175
- 0 : punctuation.definition.comment.block.begin.powershell
191
+ scope : punctuation.definition.comment.block.begin.powershell
176
192
push :
177
193
- meta_scope : comment.block.powershell
178
194
- match : ' #>'
179
- captures :
180
- 0 : punctuation.definition.comment.block.end.powershell
195
+ scope : punctuation.definition.comment.block.end.powershell
181
196
pop : true
182
197
- include : comment-embedded-docs
183
198
@@ -211,17 +226,21 @@ contexts:
211
226
- include : double-quoted-string
212
227
- include : single-quoted-string
213
228
- match : \@"(?=$)
229
+ scope : punctuation.definition.string.begin.powershell
214
230
push :
215
231
- meta_scope : string.quoted.double.heredoc.powershell
216
232
- match : ^"@
233
+ scope : punctuation.definition.string.end.powershell
217
234
pop : true
218
235
- include : variable-no-property
219
236
- include : double-quoted-string-escapes
220
237
- include : interpolation
221
238
- match : \@'(?=$)
239
+ scope : punctuation.definition.string.begin.powershell
222
240
push :
223
241
- meta_scope : string.quoted.single.heredoc.powershell
224
242
- match : ^'@
243
+ scope : punctuation.definition.string.end.powershell
225
244
pop : true
226
245
- match : " ''"
227
246
scope : constant.character.escape.powershell
@@ -306,7 +325,7 @@ contexts:
306
325
interpolation :
307
326
- match : (\$)(\()
308
327
captures :
309
- 1 : keyword.other .variable.definition .powershell
328
+ 1 : punctuation.definition .variable.powershell
310
329
2 : punctuation.section.group.begin.powershell
311
330
push :
312
331
- meta_content_scope : interpolated.complex.source.powershell
@@ -318,31 +337,31 @@ contexts:
318
337
- include : interpolated-string-content
319
338
320
339
numeric-constant :
321
- - match : ((?:[-+]|\b)0(?i:x)[0-9a-fA-F_]+(?i:u|l|ul|lu)?)((?i:[kmgtp]b) ?)\b
340
+ - match : ((?:[-+]|\b)0(?i:x)[0-9a-fA-F_]+(?i:u|l|ul|lu)?)({{bytes_unit}} ?)\b
322
341
captures :
323
- 1 : constant.numeric.hex .powershell
342
+ 1 : constant.numeric.integer.hexadecimal .powershell
324
343
2 : keyword.other.powershell
325
- - match : ((?:[-+]|\b)(?:[0-9_]+)?\.[0-9_]+(?:(?i:e)[0-9]+)?(?i:[fdm])?)((?i:[kmgtp]b) ?)\b
344
+ - match : ((?:[-+]|\b)(?:[0-9_]+)?\.[0-9_]+(?:(?i:e)[0-9]+)?(?i:[fdm])?)({{bytes_unit}} ?)\b
326
345
captures :
327
346
1 : constant.numeric.integer.powershell
328
347
2 : keyword.other.powershell
329
- - match : ((?:[-+]|\b)0(?:b|B)[01_]+(?i:u|l|ul|lu)?)((?i:[kmgtp]b) ?)\b
348
+ - match : ((?:[-+]|\b)0(?:b|B)[01_]+(?i:u|l|ul|lu)?)({{bytes_unit}} ?)\b
330
349
captures :
331
- 1 : constant.numeric.octal .powershell
350
+ 1 : constant.numeric.integer.binary .powershell
332
351
2 : keyword.other.powershell
333
- - match : ((?:[-+]|\b)[0-9_]+(?:e|E )(?:[0-9_])?+(?i:[fdm])?)((?i:[kmgtp]b) ?)\b
352
+ - match : ((?:[-+]|\b)[0-9_]+(?i:e )(?:[0-9_])?+(?i:[fdm])?)({{bytes_unit}} ?)\b
334
353
captures :
335
354
1 : constant.numeric.integer.powershell
336
355
2 : keyword.other.powershell
337
- - match : ((?:[-+]|\b)[0-9_]+\.(?:e|E )(?:[0-9_])?+(?i:[fdm])?)((?i:[kmgtp]b) ?)\b
356
+ - match : ((?:[-+]|\b)[0-9_]+\.(?i:e )(?:[0-9_])?+(?i:[fdm])?)({{bytes_unit}} ?)\b
338
357
captures :
339
358
1 : constant.numeric.integer.powershell
340
359
2 : keyword.other.powershell
341
- - match : ((?:[-+]|\b)[0-9_]+[\.]?(?i:[fdm]))((?i:[kmgtp]b)?)\b'
360
+ - match : ((?:[-+]|\b)[0-9_]+[\.]?(?i:[fdm]))({{bytes_unit}}?)\b
342
361
captures :
343
362
1 : constant.numeric.integer.powershell
344
363
2 : keyword.other.powershell
345
- - match : ((?:[-+]|\b)[0-9_]+[\.]?(?i:u|l|ul|lu)?)((?i:[kmgtp]b) ?)\b
364
+ - match : ((?:[-+]|\b)[0-9_]+[\.]?(?i:u|l|ul|lu)?)({{bytes_unit}} ?)\b
346
365
captures :
347
366
1 : constant.numeric.integer.powershell
348
367
2 : keyword.other.powershell
@@ -377,52 +396,52 @@ contexts:
377
396
captures :
378
397
1 : support.constant.variable.powershell
379
398
2 : punctuation.definition.variable.powershell
380
- 3 : entity.name.function.invocation .powershell
399
+ 3 : variable.other.member .powershell
381
400
- match : ((\$)(?i:\$|\^|\?|_|Args|ConsoleFileName|Event|EventArgs|EventSubscriber|ForEach|Input|LastExitCode|Matches|MyInvocation|NestedPromptLevel|Profile|PSBoundParameters|PsCmdlet|PsCulture|PSDebugContext|PSItem|PSCommandPath|PSScriptRoot|PsUICulture|Pwd|Sender|SourceArgs|SourceEventArgs|StackTrace|Switch|This))((?:\.(?:\p{L}|\d|_)+)*\b)?\b
382
401
captures :
383
402
1 : variable.language.powershell
384
403
2 : punctuation.definition.variable.powershell
385
- 3 : entity.name.function.invocation .powershell
386
- - match : (\$) (?i:(ConfirmPreference|DebugPreference|ErrorActionPreference|ErrorView|FormatEnumerationLimit|MaximumAliasCount|MaximumDriveCount|MaximumErrorCount|MaximumFunctionCount|MaximumHistoryCount|MaximumVariableCount|OFS|OutputEncoding|ProgressPreference|PsCulture|PSDebugContext|PSDefaultParameterValues|PSEmailServer|PSItem|PSModuleAutoloadingPreference|PSSenderInfo|PSSessionApplicationName|PSSessionConfigurationName|PSSessionOption|VerbosePreference|WarningPreference|WhatIfPreference))((?:\.(?:\p{L}|\d|_)+)*\b)?\b
404
+ 3 : variable.other.member .powershell
405
+ - match : (\$(?i:(ConfirmPreference|DebugPreference|ErrorActionPreference|ErrorView|FormatEnumerationLimit|MaximumAliasCount|MaximumDriveCount|MaximumErrorCount|MaximumFunctionCount|MaximumHistoryCount|MaximumVariableCount|OFS|OutputEncoding|ProgressPreference|PsCulture|PSDebugContext|PSDefaultParameterValues|PSEmailServer|PSItem|PSModuleAutoloadingPreference|PSSenderInfo|PSSessionApplicationName|PSSessionConfigurationName|PSSessionOption|VerbosePreference|WarningPreference|WhatIfPreference) ))((?:\.(?:\p{L}|\d|_)+)*\b)?\b
387
406
comment : Style preference variables as language variables so that they stand out.
388
407
captures :
389
408
1 : punctuation.definition.variable.powershell
390
409
2 : variable.language.powershell
391
- 3 : entity.name.function.invocation .powershell
410
+ 3 : variable.other.member .powershell
392
411
- match : (?i:(\$|@)(global|local|private|script|using|workflow):((?:\p{L}|\d|_)+))((?:\.(?:\p{L}|\d|_)+)*\b)?
393
412
captures :
394
413
1 : punctuation.definition.variable.powershell
395
414
2 : storage.modifier.scope.powershell
396
415
3 : variable.other.readwrite.powershell
397
- 4 : entity.name.function.invocation .powershell
416
+ 4 : variable.other.member .powershell
398
417
- match : (?i:(\$)(\{)(global|local|private|script|using|workflow):([^}]*[^}`])(\}))((?:\.(?:\p{L}|\d|_)+)*\b)?
399
418
captures :
400
419
1 : punctuation.definition.variable.powershell
401
420
2 : punctuation.section.braces.begin.powershell
402
421
3 : storage.modifier.scope.powershell
403
422
4 : variable.other.readwrite.powershell
404
423
5 : punctuation.section.braces.end.powershell
405
- 6 : entity.name.function.invocation .powershell
424
+ 6 : variable.other.member .powershell
406
425
- match : (?i:(\$|@)((?:\p{L}|\d|_)+:)?((?:\p{L}|\d|_)+))((?:\.(?:\p{L}|\d|_)+)*\b)?
407
426
captures :
408
427
1 : punctuation.definition.variable.powershell
409
428
2 : support.variable.drive.powershell
410
429
3 : variable.other.readwrite.powershell
411
- 4 : entity.name.function.invocation .powershell
430
+ 4 : variable.other.member .powershell
412
431
- match : (?i:(\$)(\{)((?:\p{L}|\d|_)+:)?([^}]*[^}`])(\}))((?:\.(?:\p{L}|\d|_)+)*\b)?
413
432
captures :
414
433
1 : punctuation.definition.variable.powershell
415
434
2 : punctuation.section.braces.begin.powershell
416
435
3 : support.variable.drive.powershell
417
436
4 : variable.other.readwrite.powershell
418
437
5 : punctuation.section.braces.end.powershell
419
- 6 : entity.name.function.invocation .powershell
438
+ 6 : variable.other.member .powershell
420
439
421
440
variable-no-property :
422
441
- match : (\$)(?i:False|Null|True)\b
423
442
scope : constant.language.powershell
424
443
captures :
425
- 1 : keyword.other .variable.definition .powershell
444
+ 1 : punctuation.definition .variable.powershell
426
445
- match : (\$)(?i:Error|ExecutionContext|Host|Home|PID|PsHome|PsVersionTable|ShellID)\b
427
446
scope : support.constant.variable.powershell
428
447
captures :
@@ -448,11 +467,11 @@ contexts:
448
467
3 : variable.other.readwrite.powershell
449
468
4 : keyword.other.powershell
450
469
5 : entity.name.function.invocation.powershell
451
- - match : (?i:(\$)((?:\p{L}|\d|_)+:)?((?:\p{L}|\d|_)+))
470
+ - match : (?i:(\$)((?:\p{L}|\d|_)+:)?(?:\p{L}|\d|_)+)
471
+ scope : variable.other.readwrite.powershell
452
472
captures :
453
473
1 : punctuation.definition.variable.powershell
454
474
2 : support.variable.drive.powershell
455
- 3 : variable.other.readwrite.powershell
456
475
- match : (?i:(\$)(\{)((?:\p{L}|\d|_)+:)?([^}]*[^}`])(\}))
457
476
captures :
458
477
1 : punctuation.definition.variable.powershell
0 commit comments