@@ -12,8 +12,8 @@ file_extensions:
12
12
variables :
13
13
dec_digits : (?:[\d_]*\d)
14
14
dec_exponent : (?:[eE][-+]?{{dec_digits}})
15
- float_suffix : ' (?i:[fdm])'
16
- integer_suffix : ' (?i:ul?|lu?)'
15
+ float_suffix : (?i:[fdm])
16
+ integer_suffix : (?i:ul?|lu?)
17
17
bytes_unit : (?i:[kmgtp]b)
18
18
19
19
contexts :
@@ -155,7 +155,8 @@ contexts:
155
155
# scope: invalid.illegal.powershell
156
156
157
157
requires-directive :
158
- - match : (?<=#)(?i:requires)\s
158
+ # TODO: add back `(?<=#)`-equivalent match
159
+ - match : (?i:requires)\s
159
160
scope : keyword.control.requires.powershell
160
161
push :
161
162
- meta_scope : meta.requires.powershell
@@ -253,14 +254,11 @@ contexts:
253
254
3 : markup.underline.link.powershell
254
255
255
256
comment-line :
256
- - match : (?<![`\\-])#
257
- captures :
258
- 0 : punctuation.definition.comment.powershell
257
+ - match : ' #'
258
+ scope : punctuation.definition.comment.powershell
259
259
push :
260
260
- meta_scope : comment.line.powershell
261
- - match : $
262
- captures :
263
- 0 : punctuation.definition.comment.powershell
261
+ - match : \n|$
264
262
pop : true
265
263
- include : comment-embedded-docs
266
264
- include : requires-directive
@@ -316,13 +314,15 @@ contexts:
316
314
scope : keyword.other.powershell
317
315
318
316
double-quoted-string-escapes :
319
- - match : ' `[0abnfrvt"'' $`]'
317
+ - match : ' `[0abenfrvt"'' $`]'
318
+ scope : constant.character.escape.powershell
319
+ - match : ' `u\{\h+\}'
320
320
scope : constant.character.escape.powershell
321
321
- match : ' ""'
322
322
scope : constant.character.escape.powershell
323
323
324
324
function :
325
- - match : ^(?:\s*+ )(?i)(function|filter|configuration|workflow)\s+(?:(global|local|script|private):)?((?:\p{L}|\d|_|-|\.)+)
325
+ - match : ^(?:\s*)(?i)(function|filter|configuration|workflow)\s+(?:(global|local|script|private):)?((?:\p{L}|\d|_|-|\.)+)
326
326
scope : meta.function.powershell
327
327
captures :
328
328
1 : storage.type.powershell
@@ -398,16 +398,18 @@ contexts:
398
398
\b{{dec_digits}}
399
399
(?:
400
400
(?:
401
- (?:(\.(?!\.))\d*){{dec_exponent}}? # No `_` after the `.`
401
+ (?:(\.(?!\.))\d*) # No `_` after the `.`
402
+ {{dec_exponent}}?
402
403
|{{dec_exponent}}
403
404
)
404
405
({{float_suffix}})?
405
406
|({{float_suffix}})
406
407
)
408
+ |\b{{dec_digits}}\.(?!\.)
407
409
|(\.)\d+
408
410
)
409
- ({{bytes_unit}})?
410
- )\b
411
+ ({{bytes_unit}}\b )?
412
+ )
411
413
captures:
412
414
1: constant.numeric.float.decimal.powershell
413
415
2: punctuation.separator.decimal.powershell
@@ -443,27 +445,32 @@ contexts:
443
445
- include : main
444
446
445
447
variable :
446
- - match : (\$)(?i:False|Null|True )\b
448
+ - match : (\$)(?i:True| False|Null)\b
447
449
scope : constant.language.powershell
448
450
captures :
449
451
1 : punctuation.definition.variable.powershell
450
- - match : ((\$)(?i:Error|ExecutionContext|Host|Home|PID|PsHome|PsVersionTable|ShellID))((?:\.\w+)*\b)?\b
452
+ - match : |-
453
+ (?x:(
454
+ (\$)
455
+ (?i:ExecutionContext|Host|Home|Is(?:CoreCLR|Linux|Windows|MacOS)
456
+ |PID|Profile|Ps(?:CommandPath|Home|ScriptRoot|UiCulture|VersionTable)
457
+ |ShellID)
458
+ )
459
+ ((?:\.\w+)*\b)?\b
460
+ )
451
461
captures:
452
462
1: support.constant.variable.powershell
453
463
2: punctuation.definition.variable.powershell
454
464
3: variable.other.member.powershell
455
465
- match : |-
456
- (?x:
457
- (
466
+ (?x:(
458
467
(\$)
459
468
(?:
460
469
[$^?_]
461
- |(?i:Args|ConsoleFileName|Event|EventArgs|EventSubscriber|ForEach
462
- |Input|LastExitCode|Matches|MyInvocation|NestedPromptLevel|Profile
463
- |PSBoundParameters|PsCmdlet|PsCulture|PSDebugContext|PSItem
464
- |PSCommandPath|PSScriptRoot|PsUICulture|Pwd|Sender|SourceArgs
465
- |SourceEventArgs|StackTrace|Switch|This
466
- )\b
470
+ |(?i:Args|ConsoleFileName|Error|Event|EventArgs|EventSubscriber
471
+ |ForEach|Input|LastExitCode|Matches|MyInvocation|NestedPromptLevel
472
+ |Ps(?:BoundParameters|Cmdlet|Culture|DebugContext|Item)|Pwd
473
+ |Sender|SourceArgs|SourceEventArgs|StackTrace|Switch|This)\b
467
474
)
468
475
)
469
476
((?:\.\w+)*\b)?
@@ -472,7 +479,21 @@ contexts:
472
479
1: variable.language.powershell
473
480
2: punctuation.definition.variable.powershell
474
481
3: variable.other.member.powershell
475
- - 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))((?:\.\w+)*\b)?\b
482
+ - match : |-
483
+ (?x:(
484
+ (\$)
485
+ (?i:
486
+ (?:Confirm|Debug|ErrorAction|Information|Progress|Verbose|Warning # *Preference
487
+ |WhatIf)Preference
488
+ |Maximum(?:Alias|Drive|Error|Function|History|Variable)Count # Maximum*Count
489
+ |Log(?:Command|Engine|Provider)(?:Health|Lifecycle)Event # Log*Event
490
+ |Ps(?:DebugContext|DefaultParameterValues|EmailServer # Ps*
491
+ |ModuleAutoloadingPreference|SenderInfo|SessionApplicationName
492
+ |SessionConfigurationName|SessionOption)
493
+ |ErrorView|FormatEnumerationLimit|OFS|OutputEncoding)
494
+ )
495
+ ((?:\.\w+)*\b)?\b
496
+ )
476
497
comment: Style preference variables as language variables so that they stand out.
477
498
captures:
478
499
1: variable.language.powershell
@@ -508,11 +529,18 @@ contexts:
508
529
7 : variable.other.member.powershell
509
530
510
531
variable-no-property :
511
- - match : (\$)(?i:False|Null|True )\b
532
+ - match : (\$)(?i:True| False|Null)\b
512
533
scope : constant.language.powershell
513
534
captures :
514
535
1 : punctuation.definition.variable.powershell
515
- - match : (\$)(?i:Error|ExecutionContext|Host|Home|PID|PsHome|PsVersionTable|ShellID)\b
536
+ - match : |-
537
+ (?x:
538
+ (\$)
539
+ (?i:ExecutionContext|Host|Home|Is(?:CoreCLR|Linux|Windows|MacOS)
540
+ |PID|Profile|Ps(?:CommandPath|Home|ScriptRoot|UiCulture|VersionTable)
541
+ |ShellID
542
+ )\b
543
+ )
516
544
scope: support.constant.variable.powershell
517
545
captures:
518
546
1: punctuation.definition.variable.powershell
@@ -521,17 +549,28 @@ contexts:
521
549
(\$)
522
550
(?:
523
551
[$^?_]
524
- |(?i:Args|ConsoleFileName|Event|EventArgs|EventSubscriber|ForEach
525
- |Input|LastExitCode|Matches|MyInvocation|NestedPromptLevel|Profile
526
- |PSBoundParameters|PsCmdlet|PsCulture|PSDebugContext|PSItem
527
- |PSCommandPath|PSScriptRoot|PsUICulture|Pwd|Sender|SourceArgs
528
- |SourceEventArgs|StackTrace|Switch|This)\b
552
+ |(?i:Args|ConsoleFileName|Error|Event|EventArgs|EventSubscriber
553
+ |ForEach|Input|LastExitCode|Matches|MyInvocation|NestedPromptLevel
554
+ |Ps(?:BoundParameters|Cmdlet|Culture|DebugContext|Item)|Pwd
555
+ |Sender|SourceArgs|SourceEventArgs|StackTrace|Switch|This)\b
529
556
)
530
557
)
531
558
scope: variable.language.powershell
532
559
captures:
533
560
1: punctuation.definition.variable.powershell
534
- - 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)\b
561
+ - match : |-
562
+ (?x:
563
+ (\$)
564
+ (?i:
565
+ (?:Confirm|Debug|ErrorAction|Information|Progress|Verbose|Warning # *Preference
566
+ |WhatIf)Preference
567
+ |Maximum(?:Alias|Drive|Error|Function|History|Variable)Count # Maximum*Count
568
+ |Log(?:Command|Engine|Provider)(?:Health|Lifecycle)Event # Log*Event
569
+ |Ps(?:DebugContext|DefaultParameterValues|EmailServer # Ps*
570
+ |ModuleAutoloadingPreference|SenderInfo|SessionApplicationName
571
+ |SessionConfigurationName|SessionOption)
572
+ |ErrorView|FormatEnumerationLimit|OFS|OutputEncoding)
573
+ )\b
535
574
scope: variable.language.powershell
536
575
captures:
537
576
1: punctuation.definition.variable.powershell
0 commit comments