@@ -9,12 +9,14 @@ file_extensions:
99 - psm1
1010 - psd1
1111
12+ variables :
13+ bytes_unit : (?i:[kmgtp]b)
14+
1215contexts :
1316
1417 main :
1518 - include : comments
16- - match : ' [2-6]>&1|>>|>|<<|<|>|>\||[1-6]>|[1-6]>>'
17- scope : keyword.operator.redirection.powershell
19+ - include : redirection
1820 - include : commands
1921 - include : variable
2022 - include : interpolated-string-content
@@ -60,19 +62,23 @@ contexts:
6062 - match : (?<!\w|-)((?i:class)|%|\?)(?:\s)+((?:\p{L}|\d|_|-|)+)\b
6163 # capture should be entity.name.type, but it doesn't provide a good color in the default schema.
6264 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
6569 - match : (?<!\w)-(?i:as)\b
6670 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})
6872 scope : keyword.operator.comparison.powershell
73+ - match : (?<!\w)-(?i:[ic]?(?:not)?(?:like|match|contains|in))(?!\p{L})
74+ scope : keyword.operator.logical.powershell
6975 - match : (?<!\w)-(?i:join|split)(?!\p{L})|!
7076 scope : keyword.operator.unary.powershell
7177 - match : (?<!\w)-(?i:is(?:not)?)\b
7278 scope : keyword.operator.logical.powershell
7379 - match : (?<!\w)-(?i:and|or|not|xor)(?!\p{L})|!
7480 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})
7682 scope : keyword.operator.bitwise.powershell
7783 - match : (?<!\w)-(?i:f)(?!\p{L})
7884 scope : keyword.operator.string-format.powershell
@@ -100,6 +106,19 @@ contexts:
100106 - include : comment-block
101107 - include : comment-line
102108
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+
103122 requires-directive :
104123 - match : (?<=#)(?i:requires)\s
105124 scope : keyword.control.requires.powershell
@@ -131,12 +150,10 @@ contexts:
131150 scope : punctuation.section.bracket.end.powershell
132151 pop : true
133152 - match : \(
134- captures :
135- 0 : punctuation.section.group.begin.powershell
153+ scope : punctuation.section.group.begin.powershell
136154 push :
137155 - match : \)
138- captures :
139- 0 : punctuation.section.group.end.powershell
156+ scope : punctuation.section.group.end.powershell
140157 pop : true
141158 - include : variable
142159 - include : variable-no-property
@@ -171,13 +188,11 @@ contexts:
171188
172189 comment-block :
173190 - match : <#
174- captures :
175- 0 : punctuation.definition.comment.block.begin.powershell
191+ scope : punctuation.definition.comment.block.begin.powershell
176192 push :
177193 - meta_scope : comment.block.powershell
178194 - match : ' #>'
179- captures :
180- 0 : punctuation.definition.comment.block.end.powershell
195+ scope : punctuation.definition.comment.block.end.powershell
181196 pop : true
182197 - include : comment-embedded-docs
183198
@@ -211,17 +226,21 @@ contexts:
211226 - include : double-quoted-string
212227 - include : single-quoted-string
213228 - match : \@"(?=$)
229+ scope : punctuation.definition.string.begin.powershell
214230 push :
215231 - meta_scope : string.quoted.double.heredoc.powershell
216232 - match : ^"@
233+ scope : punctuation.definition.string.end.powershell
217234 pop : true
218235 - include : variable-no-property
219236 - include : double-quoted-string-escapes
220237 - include : interpolation
221238 - match : \@'(?=$)
239+ scope : punctuation.definition.string.begin.powershell
222240 push :
223241 - meta_scope : string.quoted.single.heredoc.powershell
224242 - match : ^'@
243+ scope : punctuation.definition.string.end.powershell
225244 pop : true
226245 - match : " ''"
227246 scope : constant.character.escape.powershell
@@ -306,7 +325,7 @@ contexts:
306325 interpolation :
307326 - match : (\$)(\()
308327 captures :
309- 1 : keyword.other .variable.definition .powershell
328+ 1 : punctuation.definition .variable.powershell
310329 2 : punctuation.section.group.begin.powershell
311330 push :
312331 - meta_content_scope : interpolated.complex.source.powershell
@@ -318,31 +337,31 @@ contexts:
318337 - include : interpolated-string-content
319338
320339 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
322341 captures :
323- 1 : constant.numeric.hex .powershell
342+ 1 : constant.numeric.integer.hexadecimal .powershell
324343 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
326345 captures :
327346 1 : constant.numeric.integer.powershell
328347 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
330349 captures :
331- 1 : constant.numeric.octal .powershell
350+ 1 : constant.numeric.integer.binary .powershell
332351 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
334353 captures :
335354 1 : constant.numeric.integer.powershell
336355 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
338357 captures :
339358 1 : constant.numeric.integer.powershell
340359 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
342361 captures :
343362 1 : constant.numeric.integer.powershell
344363 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
346365 captures :
347366 1 : constant.numeric.integer.powershell
348367 2 : keyword.other.powershell
@@ -377,52 +396,52 @@ contexts:
377396 captures :
378397 1 : support.constant.variable.powershell
379398 2 : punctuation.definition.variable.powershell
380- 3 : entity.name.function.invocation .powershell
399+ 3 : variable.other.member .powershell
381400 - 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
382401 captures :
383402 1 : variable.language.powershell
384403 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
387406 comment : Style preference variables as language variables so that they stand out.
388407 captures :
389408 1 : punctuation.definition.variable.powershell
390409 2 : variable.language.powershell
391- 3 : entity.name.function.invocation .powershell
410+ 3 : variable.other.member .powershell
392411 - match : (?i:(\$|@)(global|local|private|script|using|workflow):((?:\p{L}|\d|_)+))((?:\.(?:\p{L}|\d|_)+)*\b)?
393412 captures :
394413 1 : punctuation.definition.variable.powershell
395414 2 : storage.modifier.scope.powershell
396415 3 : variable.other.readwrite.powershell
397- 4 : entity.name.function.invocation .powershell
416+ 4 : variable.other.member .powershell
398417 - match : (?i:(\$)(\{)(global|local|private|script|using|workflow):([^}]*[^}`])(\}))((?:\.(?:\p{L}|\d|_)+)*\b)?
399418 captures :
400419 1 : punctuation.definition.variable.powershell
401420 2 : punctuation.section.braces.begin.powershell
402421 3 : storage.modifier.scope.powershell
403422 4 : variable.other.readwrite.powershell
404423 5 : punctuation.section.braces.end.powershell
405- 6 : entity.name.function.invocation .powershell
424+ 6 : variable.other.member .powershell
406425 - match : (?i:(\$|@)((?:\p{L}|\d|_)+:)?((?:\p{L}|\d|_)+))((?:\.(?:\p{L}|\d|_)+)*\b)?
407426 captures :
408427 1 : punctuation.definition.variable.powershell
409428 2 : support.variable.drive.powershell
410429 3 : variable.other.readwrite.powershell
411- 4 : entity.name.function.invocation .powershell
430+ 4 : variable.other.member .powershell
412431 - match : (?i:(\$)(\{)((?:\p{L}|\d|_)+:)?([^}]*[^}`])(\}))((?:\.(?:\p{L}|\d|_)+)*\b)?
413432 captures :
414433 1 : punctuation.definition.variable.powershell
415434 2 : punctuation.section.braces.begin.powershell
416435 3 : support.variable.drive.powershell
417436 4 : variable.other.readwrite.powershell
418437 5 : punctuation.section.braces.end.powershell
419- 6 : entity.name.function.invocation .powershell
438+ 6 : variable.other.member .powershell
420439
421440 variable-no-property :
422441 - match : (\$)(?i:False|Null|True)\b
423442 scope : constant.language.powershell
424443 captures :
425- 1 : keyword.other .variable.definition .powershell
444+ 1 : punctuation.definition .variable.powershell
426445 - match : (\$)(?i:Error|ExecutionContext|Host|Home|PID|PsHome|PsVersionTable|ShellID)\b
427446 scope : support.constant.variable.powershell
428447 captures :
@@ -448,11 +467,11 @@ contexts:
448467 3 : variable.other.readwrite.powershell
449468 4 : keyword.other.powershell
450469 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
452472 captures :
453473 1 : punctuation.definition.variable.powershell
454474 2 : support.variable.drive.powershell
455- 3 : variable.other.readwrite.powershell
456475 - match : (?i:(\$)(\{)((?:\p{L}|\d|_)+:)?([^}]*[^}`])(\}))
457476 captures :
458477 1 : punctuation.definition.variable.powershell
0 commit comments