Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions PowerShell.sublime-syntax
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,11 @@ contexts:
- include: main
- match: \b[\w.-]+\.(?i:exe|com|cmd|bat)\b
scope: variable.function.powershell
# Consume a string with a trailing dot
# to prevent members with particular names from being recognized as keywords.
- match: \b[\w-]+(?=\.)
Comment thread
matteocoder marked this conversation as resolved.
scope: variable.other.object.powershell
push: members
# Exceptions
- match: \b(?i:throw){{kebab_break}}
scope: keyword.control.exception.raise.powershell
Expand All @@ -100,6 +105,8 @@ contexts:
# Begin/End
- match: \b(?i:begin){{kebab_break}}
scope: keyword.context.block.begin.powershell
- match: \b(?i:process){{kebab_break}}
scope: keyword.context.block.process.powershell
- match: \b(?i:end){{kebab_break}}
scope: keyword.context.block.end.powershell
- match: \b(?i:clean){{kebab_break}}
Expand Down Expand Up @@ -129,7 +136,7 @@ contexts:
- match: \b(?i:(?:dynamic)?param){{kebab_break}}
scope: keyword.declaration.parameter.powershell # This scope is not standard
# Uncategorized keywords
- match: \b(?i:data|default|define|from|in|inlinescript|parallel|process){{kebab_break}}
- match: \b(?i:data|default|define|from|in|inlinescript|parallel|sequence){{kebab_break}}
scope: keyword.control.powershell
- match: \B--%\B
scope: keyword.control.powershell
Expand Down Expand Up @@ -292,10 +299,10 @@ contexts:
(?xi:
\b(
Mandatory | ValueFromPipeline(?:ByPropertyName)?
| ValueFromRemainingArguments | Position
| ValueFromRemainingArguments | Position(?:alBinding)?
| (?:Default)?ParameterSetName | SupportsShouldProcess | SupportsPaging
| PositionalBinding | HelpUri | ConfirmImpact | HelpMessage
)
| HelpUri | ConfirmImpact | HelpMessage
)\b
\s*(=)?
)
captures:
Expand Down
2 changes: 1 addition & 1 deletion Tests/syntax_test_Function.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@ function Verb-Noun {
{
}
Process {
# <- keyword.control
# <- keyword.context.block.process
if ($pscmdlet.ShouldProcess("Target", "Operation")) {
# <- keyword.control
# ^ punctuation.section.group.begin
Expand Down
6 changes: 6 additions & 0 deletions Tests/syntax_test_PowerShell.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -1360,6 +1360,12 @@ New-Object -TypeName System.Diagnostics.Process
# ^^^^^^^ - keyword.control
New-Object -TypeName System.Data
# ^^^^ - keyword.control
New-Object -TypeName Sy-stem.if
# ^^ - keyword.control
New-Object -TypeName S_ystem.Clean
# ^^^^^ - keyword.control
New-Object -TypeName Sy_stem-.Throw
# ^^^^^ - keyword.control
echo `"test`"
# ^^^^^^^^^ - string.quoted
# ^^ constant.character.escape
Expand Down