@@ -50,42 +50,46 @@ contexts:
50
50
scope : punctuation.section.group.end.powershell
51
51
pop : true
52
52
- include : main
53
- - match : ( \b(( [A-Za-z0-9\-_\.]+)\.(?i:exe|com|cmd|bat))\b)
54
- scope : support .function.powershell
55
- - match : (?<!\w|-)( (?i:begin|break|catch|continue|data|default|define|do|dynamicparam|else|elseif|end|exit|finally|for|foreach(?!-object)|from|if|in|inlinescript|parallel|param|process|return|switch|throw|trap|try|until|var|where(?!-object)|while)|%|\?)(?!\w)
53
+ - match : \b(?: [A-Za-z0-9\-_\.]+)\.(?i:exe|com|cmd|bat)\b
54
+ scope : variable .function.powershell
55
+ - match : \b(?: (?i:begin|break|catch|continue|data|default|define|do|dynamicparam|else|elseif|end|exit|finally|for|foreach(?!-object)|from|if|in|inlinescript|parallel|param|process|return|switch|throw|trap|try|until|var|where(?!-object)|while)|%|\?)(?!\w)
56
56
scope : keyword.control.powershell
57
- - match : (?<!\w)( --%) \B
57
+ - match : \B --%\B
58
58
scope : keyword.control.powershell
59
+ push :
60
+ - meta_content_scope : string.unquoted.powershell
61
+ - match : (?=\n|$)
62
+ pop : true
59
63
- match : \b(?i:hidden|static)\b
60
64
# This should only be relevant inside a class but will require a rework of how classes are matched. This is a temp fix.
61
65
scope : storage.modifier.powershell
62
- - match : (?<!\w|-) ((?i:class)|%|\?)(?:\s)+((?:\p{L}|\d|_|-|)+)\b
66
+ - match : \b ((?i:class)|%|\?)(?:\s)+((?:\p{L}|\d|_|-|)+)\b
63
67
# capture should be entity.name.type, but it doesn't provide a good color in the default schema.
64
68
captures :
65
69
1 : storage.type.class.powershell
66
70
2 : meta.class.powershell entity.name.class.powershell
67
- - match : (?<!\w) -(?i:replace )\b
68
- scope : keyword.operator.powershell
69
- - match : (?<!\w) -(?i:as)\b
71
+ - match : \B -(?i:as )\b
72
+ scope : keyword.operator.cast. powershell
73
+ - match : \B -(?i:[ic]?(?:eq|ne|[gl][te]))(?!\p{L})
70
74
scope : keyword.operator.comparison.powershell
71
- - match : (?<!\w)-(?i:[ic]?(?:eq|ne|[gl][te]))(?!\p{L})
72
- scope : keyword.operator.comparison.powershell
73
- - match : (?<!\w)-(?i:[ic]?(?:not)?(?:like|match|contains|in))(?!\p{L})
75
+ - match : \B-(?i:[ic]?(?:not)?(?:like|match|contains|in))(?!\p{L})
74
76
scope : keyword.operator.logical.powershell
75
- - match : (?<!\w) -(?i:join|split)(?!\p{L})|!
76
- scope : keyword.operator.unary .powershell
77
- - match : (?<!\w) -(?i:is(?:not)?)\b
77
+ - match : \B -(?i:join|split|replace )(?!\p{L})|!
78
+ scope : keyword.operator.string .powershell
79
+ - match : \B -(?i:is(?:not)?)\b
78
80
scope : keyword.operator.logical.powershell
79
- - match : (?<!\w) -(?i:and|or|not|xor)(?!\p{L})|!
81
+ - match : \B -(?i:and|or|not|xor)(?!\p{L})|!
80
82
scope : keyword.operator.logical.powershell
81
- - match : (?<!\w) -(?i:band|bor|bnot|bxor|sh[lr])(?!\p{L})
83
+ - match : \B -(?i:band|bor|bnot|bxor|sh[lr])(?!\p{L})
82
84
scope : keyword.operator.bitwise.powershell
83
- - match : (?<!\w) -(?i:f)(?!\p{L})
85
+ - match : \B -(?i:f)(?!\p{L})
84
86
scope : keyword.operator.string-format.powershell
85
87
- match : ' [+/*%-]?='
86
88
scope : keyword.operator.assignment.powershell
89
+ - match : (?:\+\+|--)(?![ \t]*\d)
90
+ scope : keyword.operator.assignment.powershell
87
91
- match : ' [+/*%-]'
88
- scope : keyword.operator.powershell
92
+ scope : keyword.operator.arithmetic. powershell
89
93
- match : \|\||&&
90
94
scope : keyword.operator.logical.powershell
91
95
- match : ;
@@ -126,14 +130,16 @@ contexts:
126
130
- meta_scope : meta.requires.powershell
127
131
- match : $
128
132
pop : true
133
+ - include : hashtable
129
134
- match : \-(?i:Modules|PSSnapin|RunAsAdministrator|ShellId|Version)
130
135
scope : keyword.other.powershell
131
- - match : (?<!-)\b\p{L}+|\d+(?:\.\d+)*
136
+ - match : ' -'
137
+ # Intentional no-scope match to skip leading `-`s below
138
+ - match : \b\p{L}+|\d+(?:\.\d+)*
132
139
scope : variable.parameter.powershell
133
- - include : hashtable
134
140
135
141
using-directive :
136
- - match : (?<!\w) (?i:(using))\s+(?i:(namespace|module))\s+(?i:((?:\w+(?:\.)?)+))
142
+ - match : \b (?i:(using))\s+(?i:(namespace|module))\s+(?i:((?:\w+(?:\.)?)+))
137
143
captures :
138
144
1 : keyword.control.using.powershell
139
145
2 : keyword.other.powershell
@@ -197,17 +203,23 @@ contexts:
197
203
- include : comment-embedded-docs
198
204
199
205
comment-embedded-docs :
200
- - match : (?i:\s*(\.)(COMPONENT|DESCRIPTION|EXAMPLE|EXTERNALHELP|FORWARDHELPCATEGORY|FORWARDHELPTARGETNAME|FUNCTIONALITY|INPUTS|LINK|NOTES|OUTPUTS|REMOTEHELPRUNSPACE|ROLE|SYNOPSIS))
206
+ - match : ^\s*(\.)(?i:(COMPONENT|DESCRIPTION|EXAMPLE|EXTERNALHELP|FORWARDHELPCATEGORY|FORWARDHELPTARGETNAME|FUNCTIONALITY|INPUTS|LINK|NOTES|OUTPUTS|REMOTEHELPRUNSPACE|ROLE|SYNOPSIS))
207
+ scope : comment.documentation.embedded.powershell
208
+ captures :
209
+ 1 : punctuation.definition.keyword.documentation.powershell
210
+ 2 : keyword.other.documentation.powershell
211
+ - match : ^\s*(\.)(?i:(PARAMETER)\s+([a-z0-9-_]+))
201
212
scope : comment.documentation.embedded.powershell
202
213
captures :
203
- 1 : constant.string.documentation.powershell
204
- 2 : keyword.operator.documentation.powershell
205
- - match : (?i:\s*(\.)(PARAMETER|FORWARDHELPTARGETNAME|FORWARDHELPCATEGORY|REMOTEHELPRUNSPACE|EXTERNALHELP)\s+([a-z0-9-_]+))
214
+ 1 : punctuation.definition.keyword.documentation.powershell
215
+ 2 : keyword.other.documentation.param.powershell
216
+ 3 : variable.parameter.powershell
217
+ - match : ^\s*(\.)(?i:(FORWARDHELPTARGETNAME|FORWARDHELPCATEGORY|REMOTEHELPRUNSPACE|EXTERNALHELP)\s+([a-z0-9-_]+))
206
218
scope : comment.documentation.embedded.powershell
207
219
captures :
208
- 1 : constant.string .documentation.powershell
209
- 2 : keyword.operator .documentation.powershell
210
- 3 : keyword.operator.documentation .powershell
220
+ 1 : punctuation.definition.keyword .documentation.powershell
221
+ 2 : keyword.other .documentation.powershell
222
+ 3 : markup.underline.link .powershell
211
223
212
224
comment-line :
213
225
- match : (?<![`\\-])#
@@ -257,7 +269,7 @@ contexts:
257
269
pop : true
258
270
259
271
double-quoted-string :
260
- - match : (?<!(?<!`)")"
272
+ - match : ' " '
261
273
scope : punctuation.definition.string.begin.powershell
262
274
push :
263
275
- meta_scope : string.quoted.double.powershell
@@ -300,7 +312,7 @@ contexts:
300
312
- match : \}
301
313
scope : punctuation.section.braces.end.powershell
302
314
pop : true
303
- - match : \b(['"]?)(\w+)(\1 )\s*(=)\s*
315
+ - match : \b(['"]?)(\w+)(['"]? )\s*(=)\s*
304
316
scope : meta.hashtable.assignment.powershell
305
317
captures :
306
318
1 : punctuation.definition.string.begin.powershell
@@ -337,23 +349,24 @@ contexts:
337
349
- include : interpolated-string-content
338
350
339
351
numeric-constant :
340
- - match : ((?:[-+]|\b)0(?i:x) [0-9a-fA-F_]+ (?i:u|l|ul|lu)?)({{bytes_unit}}?)\b
352
+ - match : ((?:[-+]|\b)0(?i:x[0-9a-f_]+) (?i:u|l|ul|lu)?)({{bytes_unit}}?)\b
341
353
captures :
342
354
1 : constant.numeric.integer.hexadecimal.powershell
343
355
2 : keyword.other.powershell
344
- - match : ((?:[-+]|\b)(?:[0-9_]+)?\. [0-9_]+(?:(?i:e)[0-9]+)?(?i:[fdm])?)({{bytes_unit}}?)\b
356
+ - match : ((?:[-+]|\b)(?:[0-9_]+)?(\.) [0-9_]+(?:(?i:e)[0-9]+)?(?i:[fdm])?)({{bytes_unit}}?)\b
345
357
captures :
346
- 1 : constant.numeric.integer.powershell
347
- 2 : keyword.other.powershell
348
- - match : ((?:[-+]|\b)0(?:b|B)[01_]+(?i:u|l|ul|lu)?)({{bytes_unit}}?)\b
358
+ 1 : constant.numeric.float.decimal.powershell
359
+ 2 : punctuation.separator.decimal.powershell
360
+ 3 : keyword.other.unit.powershell
361
+ - match : ((?:[-+]|\b)0[bB][01_]+(?i:u|l|ul|lu)?)({{bytes_unit}}?)\b
349
362
captures :
350
363
1 : constant.numeric.integer.binary.powershell
351
364
2 : keyword.other.powershell
352
- - match : ((?:[-+]|\b)[0-9_]+(?i:e) (?:[0-9_])?+(?i:[fdm])?)({{bytes_unit}}?)\b
365
+ - match : ((?:[-+]|\b)[0-9_]+[eE] (?:[0-9_])?+(?i:[fdm])?)({{bytes_unit}}?)\b
353
366
captures :
354
367
1 : constant.numeric.integer.powershell
355
368
2 : keyword.other.powershell
356
- - match : ((?:[-+]|\b)[0-9_]+\.(?i:e) (?:[0-9_])?+(?i:[fdm])?)({{bytes_unit}}?)\b
369
+ - match : ((?:[-+]|\b)[0-9_]+\.[eE] (?:[0-9_])?+(?i:[fdm])?)({{bytes_unit}}?)\b
357
370
captures :
358
371
1 : constant.numeric.integer.powershell
359
372
2 : keyword.other.powershell
@@ -397,45 +410,45 @@ contexts:
397
410
1 : support.constant.variable.powershell
398
411
2 : punctuation.definition.variable.powershell
399
412
3 : variable.other.member.powershell
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
413
+ - 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
401
414
captures :
402
415
1 : variable.language.powershell
403
416
2 : punctuation.definition.variable.powershell
404
417
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
418
+ - 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
406
419
comment : Style preference variables as language variables so that they stand out.
407
420
captures :
408
- 1 : punctuation.definition. variable.powershell
409
- 2 : variable.language .powershell
421
+ 1 : variable.language .powershell
422
+ 2 : punctuation.definition.variable .powershell
410
423
3 : variable.other.member.powershell
411
- - match : (?i: (\$|@)(global|local|private|script|using|workflow):( (?:\p{L}|\d|_)+))((?:\.(?:\p{L}|\d|_)+)*\b)?
424
+ - match : ((\$|@)(?i:( global|local|private|script|using|workflow):(?:\p{L}|\d|_)+))((?:\.(?:\p{L}|\d|_)+)*\b)?
412
425
captures :
413
- 1 : punctuation.definition.variable .powershell
414
- 2 : storage.modifier.scope .powershell
415
- 3 : variable.other.readwrite .powershell
426
+ 1 : variable.other.readwrite .powershell
427
+ 2 : punctuation.definition.variable .powershell
428
+ 3 : storage.modifier.scope .powershell
416
429
4 : variable.other.member.powershell
417
- - match : (?i: (\$)(\{)(global|local|private|script|using|workflow):([^}]*[^}`])(\}))((?:\.(?:\p{L}|\d|_)+)*\b)?
430
+ - match : ((\$)(\{)((?i: global|local|private|script|using|workflow) ):([^}]*[^}`])(\}))((?:\.(?:\p{L}|\d|_)+)*\b)?
418
431
captures :
419
- 1 : punctuation.definition.variable .powershell
420
- 2 : punctuation.section.braces.begin .powershell
421
- 3 : storage.modifier.scope .powershell
422
- 4 : variable.other.readwrite .powershell
423
- 5 : punctuation.section.braces.end.powershell
424
- 6 : variable.other.member.powershell
425
- - match : (?i:(\$|@)((?:\p{L}|\d|_)+:)?( (?:\p{L}|\d|_)+))((?:\.(?:\p{L}|\d|_)+)*\b)?
432
+ 1 : variable.other.readwrite .powershell
433
+ 2 : punctuation.definition.variable .powershell
434
+ 3 : punctuation.section.braces.begin .powershell
435
+ 4 : storage.modifier.scope .powershell
436
+ 6 : punctuation.section.braces.end.powershell
437
+ 7 : variable.other.member.powershell
438
+ - match : (( ?i:(\$|@)((?:\p{L}|\d|_)+:)?(?:\p{L}|\d|_)+))((?:\.(?:\p{L}|\d|_)+)*\b)?
426
439
captures :
427
- 1 : punctuation.definition.variable .powershell
428
- 2 : support.variable.drive .powershell
429
- 3 : variable.other.readwrite .powershell
440
+ 1 : variable.other.readwrite .powershell
441
+ 2 : punctuation.definition.variable .powershell
442
+ 3 : support. variable.drive .powershell
430
443
4 : variable.other.member.powershell
431
- - match : (?i:(\$)(\{)((?:\p{L}|\d|_)+:)?([^}]*[^}`])(\}))((?:\.(?:\p{L}|\d|_)+)*\b)?
444
+ - match : (( ?i:(\$)(\{)((?:\p{L}|\d|_)+:)?([^}]*[^}`])(\}) ))((?:\.(?:\p{L}|\d|_)+)*\b)?
432
445
captures :
433
- 1 : punctuation.definition.variable .powershell
434
- 2 : punctuation.section.braces.begin .powershell
435
- 3 : support.variable.drive .powershell
436
- 4 : variable.other.readwrite .powershell
437
- 5 : punctuation.section.braces.end.powershell
438
- 6 : variable.other.member.powershell
446
+ 1 : variable.other.readwrite .powershell
447
+ 2 : punctuation.definition.variable .powershell
448
+ 3 : punctuation.section.braces.begin .powershell
449
+ 4 : support. variable.drive .powershell
450
+ 6 : punctuation.section.braces.end.powershell
451
+ 7 : variable.other.member.powershell
439
452
440
453
variable-no-property :
441
454
- match : (\$)(?i:False|Null|True)\b
@@ -446,7 +459,7 @@ contexts:
446
459
scope : support.constant.variable.powershell
447
460
captures :
448
461
1 : punctuation.definition.variable.powershell
449
- - 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)\b
462
+ - 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)\b
450
463
scope : variable.language.powershell
451
464
captures :
452
465
1 : punctuation.definition.variable.powershell
0 commit comments