@@ -54,7 +54,7 @@ contexts:
5454 scope : punctuation.section.group.end.powershell
5555 pop : true
5656 - include : main
57- - match : \b(?:[A-Za-z0-9\-_\.]+) \.(?i:exe|com|cmd|bat)\b
57+ - match : \b[\w.-]+ \.(?i:exe|com|cmd|bat)\b
5858 scope : variable.function.powershell
5959 - 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)
6060 scope : keyword.control.powershell
@@ -67,46 +67,49 @@ contexts:
6767 - match : \b(?i:hidden|static)\b
6868 # This should only be relevant inside a class but will require a rework of how classes are matched. This is a temp fix.
6969 scope : storage.modifier.powershell
70- - match : \b((?i:class)|%|\?)(?:\s)+((?:\p{L}|\d|_|-|) +)\b
70+ - match : \b((?i:class)|%|\?)(?:\s)+([\w-] +)\b
7171 captures :
7272 1 : storage.type.class.powershell
7373 2 : meta.class.powershell entity.name.class.powershell
74+ # Operators...
7475 - match : \B(-)(?i:as)\b
7576 scope : keyword.operator.cast.powershell
7677 captures :
7778 1 : punctuation.definition.keyword.powershell
78- - match : \B(-)(?i:[ic]?(?:eq|ne|[gl][te]))(?!\p{L})
79+ - match : \B(-)(?i:[ic]?(?:eq|ne|[gl][te]))\b
7980 scope : keyword.operator.comparison.powershell
8081 captures :
8182 1 : punctuation.definition.keyword.powershell
82- - match : \B(-)(?i:[ic]?(?:not)?(?:like|match|contains|in))(?!\p{L})
83+ - match : \B(-)(?i:[ic]?(?:not)?(?:like|match|contains|in))\b
8384 scope : keyword.operator.logical.powershell
8485 captures :
8586 1 : punctuation.definition.keyword.powershell
86- - match : \B(-)(?i:join|split|replace)(?!\p{L})|!
87+ - match : \B(-)(?i:join|split|replace)\b
8788 scope : keyword.operator.string.powershell
8889 captures :
8990 1 : punctuation.definition.keyword.powershell
9091 - match : \B(-)(?i:is(?:not)?)\b
9192 scope : keyword.operator.logical.powershell
9293 captures :
9394 1 : punctuation.definition.keyword.powershell
94- - match : \B(-)(?i:and|or|not|xor)(?!\p{L}) |!
95+ - match : \B(-)(?i:and|or|not|xor)\b |!
9596 scope : keyword.operator.logical.powershell
9697 captures :
9798 1 : punctuation.definition.keyword.powershell
98- - match : \B(-)(?i:band|bor|bnot|bxor|sh[lr])(?!\p{L})
99+ - match : \B(-)(?i:band|bor|bnot|bxor|sh[lr])\b
99100 scope : keyword.operator.bitwise.powershell
100101 captures :
101102 1 : punctuation.definition.keyword.powershell
102- - match : \B(-)(?i:f)(?!\p{L})
103+ - match : \B(-)(?i:f)\b
103104 scope : keyword.operator.string-format.powershell
104105 captures :
105106 1 : punctuation.definition.keyword.powershell
107+ # Flags/Options/Parameters
106108 - match : \B([-/])[\p{L}](?:[\w-]*\w)?
107109 scope : variable.parameter.option.powershell
108110 captures :
109111 1 : punctuation.definition.parameter.powershell
112+ # operators continue...
110113 - match : ' [+/*%-]?='
111114 scope : keyword.operator.assignment.powershell
112115 - match : (?:\+\+|--)(?![ \t]*\d)
@@ -117,14 +120,14 @@ contexts:
117120 scope : keyword.operator.arithmetic.powershell
118121 - match : \|\||&&
119122 scope : keyword.operator.logical.powershell
123+ - match : \|
124+ scope : keyword.operator.logical.pipe.powershell
120125 - match : ;
121126 scope : punctuation.terminator.statement.powershell
122127 - match : \`
123128 scope : punctuation.separator.continuation.line.powershell
124129 - match : ' ,'
125130 scope : punctuation.separator.sequence.powershell
126- - match : \|
127- scope : keyword.operator.logical.pipe.powershell
128131 - match : ' &|\B\.(?= )'
129132 scope : keyword.operator.other.powershell
130133 - match : \.\.(?=\-?\d|\(|\$)
@@ -213,7 +216,7 @@ contexts:
213216 pop : true
214217
215218 commands :
216- - match : (?:(\p{L}|\d|_|-|\\|\:) *\\)?\b(?i:Add|Approve|Assert|Backup|Block|Build|Checkpoint|Clear|Close|Compare|Complete|Compress|Confirm|Connect|Convert|ConvertFrom|ConvertTo|Copy|Debug|Deny|Deploy|Disable|Disconnect|Dismount|Edit|Enable|Enter|Exit|Expand|Export|Find|Format|Get|Grant|Group|Hide|Import|Initialize|Install|Invoke|Join|Limit|Lock|Measure|Merge|Mount|Move|New|Open|Optimize|Out|Ping|Pop|Protect|Publish|Push|Read|Receive|Redo|Register|Remove|Rename|Repair|Request|Reset|Resize|Resolve|Restart|Restore|Resume|Revoke|Save|Search|Select|Send|Set|Show|Skip|Split|Start|Step|Stop|Submit|Suspend|Switch|Sync|Test|Trace|Unblock|Undo|Uninstall|Unlock|Unprotect|Unpublish|Unregister|Update|Use|Wait|Watch|Write)\-.+?(?:\.(?i:exe|cmd|bat|ps1))?\b
219+ - match : (?:[\w\\:-] *\\)?\b(?i:Add|Approve|Assert|Backup|Block|Build|Checkpoint|Clear|Close|Compare|Complete|Compress|Confirm|Connect|Convert|ConvertFrom|ConvertTo|Copy|Debug|Deny|Deploy|Disable|Disconnect|Dismount|Edit|Enable|Enter|Exit|Expand|Export|Find|Format|Get|Grant|Group|Hide|Import|Initialize|Install|Invoke|Join|Limit|Lock|Measure|Merge|Mount|Move|New|Open|Optimize|Out|Ping|Pop|Protect|Publish|Push|Read|Receive|Redo|Register|Remove|Rename|Repair|Request|Reset|Resize|Resolve|Restart|Restore|Resume|Revoke|Save|Search|Select|Send|Set|Show|Skip|Split|Start|Step|Stop|Submit|Suspend|Switch|Sync|Test|Trace|Unblock|Undo|Uninstall|Unlock|Unprotect|Unpublish|Unregister|Update|Use|Wait|Watch|Write)\-.+?(?:\.(?i:exe|cmd|bat|ps1))?\b
217220 # "Verb-Noun pattern:"
218221 scope : support.function.powershell
219222 - match : \b(?i:(?:foreach|where|sort|tee)-object)\b
@@ -391,16 +394,17 @@ contexts:
391394 4 : keyword.other.unit.powershell
392395 - match : |-
393396 (?x:
394- \b (
395- {{dec_digits}}
397+ (
398+ \b {{dec_digits}}
396399 (?:
397400 (?:
398- (?:(\.(?!\.)){{dec_digits}}? ){{dec_exponent}}?
401+ (?:(\.(?!\.))\d* ){{dec_exponent}}? # No `_` after the `.`
399402 |{{dec_exponent}}
400403 )
401404 ({{float_suffix}})?
402405 |({{float_suffix}})
403406 )
407+ |(\.)\d+
404408 )
405409 ({{bytes_unit}})?
406410 )\b
@@ -409,7 +413,8 @@ contexts:
409413 2: punctuation.separator.decimal.powershell
410414 3: storage.type.numeric.powershell
411415 4: storage.type.numeric.powershell
412- 5: keyword.other.unit.powershell
416+ 5: punctuation.separator.decimal.powershell
417+ 6: keyword.other.unit.powershell
413418 - match : \b((?:0|[1-9]{{dec_digits}}?)({{integer_suffix}})?)({{bytes_unit}})?\b
414419 captures :
415420 1 : constant.numeric.integer.decimal.powershell
@@ -433,7 +438,7 @@ contexts:
433438 - match : \]
434439 scope : punctuation.section.bracket.end.powershell
435440 pop : true
436- - match : (?!\d+|\.)(?: \p{L}| \p{N}|\.) +
441+ - match : (?!\d+|\.)[ \p{L}\p{N}.] +
437442 scope : storage.type.powershell
438443 - include : main
439444
@@ -442,7 +447,7 @@ contexts:
442447 scope : constant.language.powershell
443448 captures :
444449 1 : punctuation.definition.variable.powershell
445- - match : ((\$)(?i:Error|ExecutionContext|Host|Home|PID|PsHome|PsVersionTable|ShellID))((?:\.(?:\p{L}|\d|_) +)*\b)?\b
450+ - match : ((\$)(?i:Error|ExecutionContext|Host|Home|PID|PsHome|PsVersionTable|ShellID))((?:\.\w +)*\b)?\b
446451 captures :
447452 1 : support.constant.variable.powershell
448453 2 : punctuation.definition.variable.powershell
@@ -461,39 +466,39 @@ contexts:
461466 )\b
462467 )
463468 )
464- ((?:\.(?:\p{L}|\d|_) +)*\b)?
469+ ((?:\.\w +)*\b)?
465470 )
466471 captures:
467472 1: variable.language.powershell
468473 2: punctuation.definition.variable.powershell
469474 3: variable.other.member.powershell
470- - 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
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
471476 comment : Style preference variables as language variables so that they stand out.
472477 captures :
473478 1 : variable.language.powershell
474479 2 : punctuation.definition.variable.powershell
475480 3 : variable.other.member.powershell
476- - match : ((\$|@)(?i:(global|local|private|script|using|workflow):(?:\p{L}|\d|_) +))((?:\.(?:\p{L}|\d|_) +)*\b)?
481+ - match : ((\$|@)(?i:(global|local|private|script|using|workflow):\w +))((?:\.\w +)*\b)?
477482 captures :
478483 1 : variable.other.readwrite.powershell
479484 2 : punctuation.definition.variable.powershell
480485 3 : storage.modifier.scope.powershell
481486 4 : variable.other.member.powershell
482- - match : ((\$)(\{)((?i:global|local|private|script|using|workflow)):([^}]*[^}`])(\}))((?:\.(?:\p{L}|\d|_) +)*\b)?
487+ - match : ((\$)(\{)((?i:global|local|private|script|using|workflow)):([^}]*[^}`])(\}))((?:\.\w +)*\b)?
483488 captures :
484489 1 : variable.other.readwrite.powershell
485490 2 : punctuation.definition.variable.powershell
486491 3 : punctuation.section.braces.begin.powershell
487492 4 : storage.modifier.scope.powershell
488493 6 : punctuation.section.braces.end.powershell
489494 7 : variable.other.member.powershell
490- - match : ((?i:(\$|@)((?:\p{L}|\d|_) +:)?(?:\p{L}|\d|_) +))((?:\.(?:\p{L}|\d|_) +)*\b)?
495+ - match : ((?i:(\$|@)(\w +:)?\w +))((?:\.\w +)*\b)?
491496 captures :
492497 1 : variable.other.readwrite.powershell
493498 2 : punctuation.definition.variable.powershell
494499 3 : support.variable.drive.powershell
495500 4 : variable.other.member.powershell
496- - match : ((?i:(\$)(\{)((?:\p{L}|\d|_) +:)?([^}]*[^}`])(\})))((?:\.(?:\p{L}|\d|_) +)*\b)?
501+ - match : ((?i:(\$)(\{)(\w +:)?([^}]*[^}`])(\})))((?:\.\w +)*\b)?
497502 captures :
498503 1 : variable.other.readwrite.powershell
499504 2 : punctuation.definition.variable.powershell
@@ -530,7 +535,7 @@ contexts:
530535 scope : variable.language.powershell
531536 captures :
532537 1 : punctuation.definition.variable.powershell
533- - match : (?i:(\$|@)(global|local|private|script|using|workflow):((?:\p{L}|\d|_) +))
538+ - match : (?i:(\$|@)(global|local|private|script|using|workflow):(\w +))
534539 captures :
535540 1 : punctuation.definition.variable.powershell
536541 2 : storage.modifier.scope.powershell
@@ -543,12 +548,12 @@ contexts:
543548 3 : variable.other.readwrite.powershell
544549 4 : keyword.other.powershell
545550 5 : entity.name.function.invocation.powershell
546- - match : (?i:(\$)((?:\p{L}|\d|_) +:)?(?:\p{L}|\d|_) +)
551+ - match : (?i:(\$)(\w +:)?\w +)
547552 scope : variable.other.readwrite.powershell
548553 captures :
549554 1 : punctuation.definition.variable.powershell
550555 2 : support.variable.drive.powershell
551- - match : (?i:(\$)(\{)((?:\p{L}|\d|_) +:)?([^}]*[^}`])(\}))
556+ - match : (?i:(\$)(\{)(\w +:)?([^}]*[^}`])(\}))
552557 captures :
553558 1 : punctuation.definition.variable.powershell
554559 2 : punctuation.section.braces.begin
0 commit comments