@@ -10,6 +10,10 @@ file_extensions:
10
10
- psd1
11
11
12
12
variables :
13
+ dec_digits : (?:[\d_]*\d)
14
+ dec_exponent : (?:[eE][-+]?{{dec_digits}})
15
+ float_suffix : ' (?i:[fdm])'
16
+ integer_suffix : ' (?i:ul?|lu?)'
13
17
bytes_unit : (?i:[kmgtp]b)
14
18
15
19
contexts :
@@ -64,30 +68,51 @@ contexts:
64
68
# This should only be relevant inside a class but will require a rework of how classes are matched. This is a temp fix.
65
69
scope : storage.modifier.powershell
66
70
- match : \b((?i:class)|%|\?)(?:\s)+((?:\p{L}|\d|_|-|)+)\b
67
- # capture should be entity.name.type, but it doesn't provide a good color in the default schema.
68
71
captures :
69
72
1 : storage.type.class.powershell
70
73
2 : meta.class.powershell entity.name.class.powershell
71
- - match : \B- (?i:as)\b
74
+ - match : \B(-) (?i:as)\b
72
75
scope : keyword.operator.cast.powershell
73
- - match : \B-(?i:[ic]?(?:eq|ne|[gl][te]))(?!\p{L})
76
+ captures :
77
+ 1 : punctuation.definition.keyword.powershell
78
+ - match : \B(-)(?i:[ic]?(?:eq|ne|[gl][te]))(?!\p{L})
74
79
scope : keyword.operator.comparison.powershell
75
- - match : \B-(?i:[ic]?(?:not)?(?:like|match|contains|in))(?!\p{L})
80
+ captures :
81
+ 1 : punctuation.definition.keyword.powershell
82
+ - match : \B(-)(?i:[ic]?(?:not)?(?:like|match|contains|in))(?!\p{L})
76
83
scope : keyword.operator.logical.powershell
77
- - match : \B-(?i:join|split|replace)(?!\p{L})|!
84
+ captures :
85
+ 1 : punctuation.definition.keyword.powershell
86
+ - match : \B(-)(?i:join|split|replace)(?!\p{L})|!
78
87
scope : keyword.operator.string.powershell
79
- - match : \B-(?i:is(?:not)?)\b
88
+ captures :
89
+ 1 : punctuation.definition.keyword.powershell
90
+ - match : \B(-)(?i:is(?:not)?)\b
80
91
scope : keyword.operator.logical.powershell
81
- - match : \B-(?i:and|or|not|xor)(?!\p{L})|!
92
+ captures :
93
+ 1 : punctuation.definition.keyword.powershell
94
+ - match : \B(-)(?i:and|or|not|xor)(?!\p{L})|!
82
95
scope : keyword.operator.logical.powershell
83
- - match : \B-(?i:band|bor|bnot|bxor|sh[lr])(?!\p{L})
96
+ captures :
97
+ 1 : punctuation.definition.keyword.powershell
98
+ - match : \B(-)(?i:band|bor|bnot|bxor|sh[lr])(?!\p{L})
84
99
scope : keyword.operator.bitwise.powershell
85
- - match : \B-(?i:f)(?!\p{L})
100
+ captures :
101
+ 1 : punctuation.definition.keyword.powershell
102
+ - match : \B(-)(?i:f)(?!\p{L})
86
103
scope : keyword.operator.string-format.powershell
104
+ captures :
105
+ 1 : punctuation.definition.keyword.powershell
106
+ - match : \B([-/])[\p{L}](?:[\w-]*\w)?
107
+ scope : variable.parameter.option.powershell
108
+ captures :
109
+ 1 : punctuation.definition.parameter.powershell
87
110
- match : ' [+/*%-]?='
88
111
scope : keyword.operator.assignment.powershell
89
112
- match : (?:\+\+|--)(?![ \t]*\d)
90
113
scope : keyword.operator.assignment.powershell
114
+ - match : ' [+-](?=\.?\d)'
115
+ scope : keyword.operator.unary.powershell
91
116
- match : ' [+/*%-]'
92
117
scope : keyword.operator.arithmetic.powershell
93
118
- match : \|\||&&
@@ -102,7 +127,7 @@ contexts:
102
127
scope : keyword.operator.logical.pipe.powershell
103
128
- match : ' &|\B\.(?= )'
104
129
scope : keyword.operator.other.powershell
105
- - match : (?<!\s|^) \.\.(?=\-?\d|\(|\$)
130
+ - match : \.\.(?=\-?\d|\(|\$)
106
131
# This is very imprecise. Is there a syntax for 'must come after...'?
107
132
scope : keyword.operator.range.powershell
108
133
@@ -111,17 +136,20 @@ contexts:
111
136
- include : comment-line
112
137
113
138
redirection :
114
- - match : ([2-6])(>&)(1)|([1-6])(>)|([1-6])(>>)
139
+ # https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_redirection
140
+ - match : ([2-6*])(>&)(1)
115
141
captures :
116
142
1 : constant.numeric.decimal.file-descriptor.powershell
117
143
2 : keyword.operator.redirection.powershell
118
144
3 : constant.numeric.decimal.file-descriptor.powershell
119
- 4 : constant.numeric.decimal.file-descriptor.powershell
120
- 5 : keyword.operator.redirection.powershell
121
- 6 : constant.numeric.decimal.file-descriptor.powershell
122
- 7 : keyword.operator.redirection.powershell
123
- - match : ' >>?|<<?|>\| '
145
+ - match : ([1-6*])(>>?)
146
+ captures :
147
+ 1 : constant.numeric.decimal.file-descriptor.powershell
148
+ 2 : keyword.operator.redirection.powershell
149
+ - match : ' >>?'
124
150
scope : keyword.operator.redirection.powershell
151
+ # - match: <+
152
+ # scope: invalid.illegal.powershell
125
153
126
154
requires-directive :
127
155
- match : (?<=#)(?i:requires)\s
@@ -349,35 +377,44 @@ contexts:
349
377
- include : interpolated-string-content
350
378
351
379
numeric-constant :
352
- - match : ((?:[-+]|\b)0(?i:x[0-9a-f_]+)(?i:u|l|ul|lu )?)({{bytes_unit}}?) \b
380
+ - match : \b((0[xX])[\h_]*\h({{integer_suffix}} )?)({{bytes_unit}})? \b
353
381
captures :
354
382
1 : constant.numeric.integer.hexadecimal.powershell
355
- 2 : keyword.other.powershell
356
- - match : ((?:[-+]|\b)(?:[0-9_]+)?(\.)[0-9_]+(?:(?i:e)[0-9]+)?(?i:[fdm])?)({{bytes_unit}}?)\b
357
- captures :
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
383
+ 2 : punctuation.definition.numeric.base.powershell
384
+ 3 : storage.type.numeric.powershell
385
+ 4 : keyword.other.unit.powershell
386
+ - match : \b((0[bB])[01_]*[01]({{integer_suffix}})?)({{bytes_unit}})?\b
362
387
captures :
363
388
1 : constant.numeric.integer.binary.powershell
364
- 2 : keyword.other.powershell
365
- - match : ((?:[-+]|\b)[0-9_]+[eE](?:[0-9_])?+(?i:[fdm])?)({{bytes_unit}}?)\b
389
+ 2 : punctuation.definition.numeric.base.powershell
390
+ 3 : storage.type.numeric.powershell
391
+ 4 : keyword.other.unit.powershell
392
+ - match : |-
393
+ (?x:
394
+ \b(
395
+ {{dec_digits}}
396
+ (?:
397
+ (?:
398
+ (?:(\.(?!\.)){{dec_digits}}?){{dec_exponent}}?
399
+ |{{dec_exponent}}
400
+ )
401
+ ({{float_suffix}})?
402
+ |({{float_suffix}})
403
+ )
404
+ )
405
+ ({{bytes_unit}})?
406
+ )\b
366
407
captures:
367
- 1 : constant.numeric.integer.powershell
368
- 2 : keyword.other.powershell
369
- - match : ((?:[-+]|\b)[0-9_]+\.[eE](?:[0-9_])?+(?i:[fdm])?)({{bytes_unit}}?)\b
370
- captures :
371
- 1 : constant.numeric.integer.powershell
372
- 2 : keyword.other.powershell
373
- - match : ((?:[-+]|\b)[0-9_]+[\.]?(?i:[fdm]))({{bytes_unit}}?)\b
374
- captures :
375
- 1 : constant.numeric.integer.powershell
376
- 2 : keyword.other.powershell
377
- - match : ((?:[-+]|\b)[0-9_]+[\.]?(?i:u|l|ul|lu)?)({{bytes_unit}}?)\b
408
+ 1: constant.numeric.float.decimal.powershell
409
+ 2: punctuation.separator.decimal.powershell
410
+ 3: storage.type.numeric.powershell
411
+ 4: storage.type.numeric.powershell
412
+ 5: keyword.other.unit.powershell
413
+ - match : \b((?:0|[1-9]{{dec_digits}}?)({{integer_suffix}})?)({{bytes_unit}})?\b
378
414
captures :
379
- 1 : constant.numeric.integer.powershell
380
- 2 : keyword.other.powershell
415
+ 1 : constant.numeric.integer.decimal.powershell
416
+ 2 : storage.type.numeric.powershell
417
+ 3 : keyword.other.unit.powershell
381
418
382
419
script-block :
383
420
- match : \{
@@ -410,7 +447,22 @@ contexts:
410
447
1 : support.constant.variable.powershell
411
448
2 : punctuation.definition.variable.powershell
412
449
3 : variable.other.member.powershell
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
450
+ - match : |-
451
+ (?x:
452
+ (
453
+ (\$)
454
+ (?:
455
+ [$^?_]
456
+ |(?i:Args|ConsoleFileName|Event|EventArgs|EventSubscriber|ForEach
457
+ |Input|LastExitCode|Matches|MyInvocation|NestedPromptLevel|Profile
458
+ |PSBoundParameters|PsCmdlet|PsCulture|PSDebugContext|PSItem
459
+ |PSCommandPath|PSScriptRoot|PsUICulture|Pwd|Sender|SourceArgs
460
+ |SourceEventArgs|StackTrace|Switch|This
461
+ )\b
462
+ )
463
+ )
464
+ ((?:\.(?:\p{L}|\d|_)+)*\b)?
465
+ )
414
466
captures:
415
467
1: variable.language.powershell
416
468
2: punctuation.definition.variable.powershell
@@ -459,7 +511,18 @@ contexts:
459
511
scope : support.constant.variable.powershell
460
512
captures :
461
513
1 : punctuation.definition.variable.powershell
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
514
+ - match : |-
515
+ (?x:
516
+ (\$)
517
+ (?:
518
+ [$^?_]
519
+ |(?i:Args|ConsoleFileName|Event|EventArgs|EventSubscriber|ForEach
520
+ |Input|LastExitCode|Matches|MyInvocation|NestedPromptLevel|Profile
521
+ |PSBoundParameters|PsCmdlet|PsCulture|PSDebugContext|PSItem
522
+ |PSCommandPath|PSScriptRoot|PsUICulture|Pwd|Sender|SourceArgs
523
+ |SourceEventArgs|StackTrace|Switch|This)\b
524
+ )
525
+ )
463
526
scope: variable.language.powershell
464
527
captures:
465
528
1: punctuation.definition.variable.powershell
0 commit comments