@@ -12,8 +12,8 @@ file_extensions:
1212variables :
1313 dec_digits : (?:[\d_]*\d)
1414 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?)
1717 bytes_unit : (?i:[kmgtp]b)
1818
1919contexts :
@@ -155,7 +155,8 @@ contexts:
155155 # scope: invalid.illegal.powershell
156156
157157 requires-directive :
158- - match : (?<=#)(?i:requires)\s
158+ # TODO: add back `(?<=#)`-equivalent match
159+ - match : (?i:requires)\s
159160 scope : keyword.control.requires.powershell
160161 push :
161162 - meta_scope : meta.requires.powershell
@@ -253,14 +254,11 @@ contexts:
253254 3 : markup.underline.link.powershell
254255
255256 comment-line :
256- - match : (?<![`\\-])#
257- captures :
258- 0 : punctuation.definition.comment.powershell
257+ - match : ' #'
258+ scope : punctuation.definition.comment.powershell
259259 push :
260260 - meta_scope : comment.line.powershell
261- - match : $
262- captures :
263- 0 : punctuation.definition.comment.powershell
261+ - match : \n|$
264262 pop : true
265263 - include : comment-embedded-docs
266264 - include : requires-directive
@@ -316,13 +314,15 @@ contexts:
316314 scope : keyword.other.powershell
317315
318316 double-quoted-string-escapes :
319- - match : ' `[0abnfrvt"'' $`]'
317+ - match : ' `[0abenfrvt"'' $`]'
318+ scope : constant.character.escape.powershell
319+ - match : ' `u\{\h+\}'
320320 scope : constant.character.escape.powershell
321321 - match : ' ""'
322322 scope : constant.character.escape.powershell
323323
324324 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|_|-|\.)+)
326326 scope : meta.function.powershell
327327 captures :
328328 1 : storage.type.powershell
@@ -398,16 +398,18 @@ contexts:
398398 \b{{dec_digits}}
399399 (?:
400400 (?:
401- (?:(\.(?!\.))\d*){{dec_exponent}}? # No `_` after the `.`
401+ (?:(\.(?!\.))\d*) # No `_` after the `.`
402+ {{dec_exponent}}?
402403 |{{dec_exponent}}
403404 )
404405 ({{float_suffix}})?
405406 |({{float_suffix}})
406407 )
408+ |\b{{dec_digits}}\.(?!\.)
407409 |(\.)\d+
408410 )
409- ({{bytes_unit}})?
410- )\b
411+ ({{bytes_unit}}\b )?
412+ )
411413 captures:
412414 1: constant.numeric.float.decimal.powershell
413415 2: punctuation.separator.decimal.powershell
@@ -443,27 +445,32 @@ contexts:
443445 - include : main
444446
445447 variable :
446- - match : (\$)(?i:False|Null|True )\b
448+ - match : (\$)(?i:True| False|Null)\b
447449 scope : constant.language.powershell
448450 captures :
449451 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+ )
451461 captures:
452462 1: support.constant.variable.powershell
453463 2: punctuation.definition.variable.powershell
454464 3: variable.other.member.powershell
455465 - match : |-
456- (?x:
457- (
466+ (?x:(
458467 (\$)
459468 (?:
460469 [$^?_]
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
467474 )
468475 )
469476 ((?:\.\w+)*\b)?
@@ -472,7 +479,21 @@ contexts:
472479 1: variable.language.powershell
473480 2: punctuation.definition.variable.powershell
474481 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+ )
476497 comment: Style preference variables as language variables so that they stand out.
477498 captures:
478499 1: variable.language.powershell
@@ -508,11 +529,18 @@ contexts:
508529 7 : variable.other.member.powershell
509530
510531 variable-no-property :
511- - match : (\$)(?i:False|Null|True )\b
532+ - match : (\$)(?i:True| False|Null)\b
512533 scope : constant.language.powershell
513534 captures :
514535 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+ )
516544 scope: support.constant.variable.powershell
517545 captures:
518546 1: punctuation.definition.variable.powershell
@@ -521,17 +549,28 @@ contexts:
521549 (\$)
522550 (?:
523551 [$^?_]
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
529556 )
530557 )
531558 scope: variable.language.powershell
532559 captures:
533560 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
535574 scope: variable.language.powershell
536575 captures:
537576 1: punctuation.definition.variable.powershell
0 commit comments