Skip to content

Commit 7dc10a5

Browse files
committed
Scope command arguments
1 parent 8e35b8e commit 7dc10a5

File tree

2 files changed

+137
-85
lines changed

2 files changed

+137
-85
lines changed

PowerShell.sublime-syntax

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -362,6 +362,7 @@ contexts:
362362
push: in-command
363363

364364
in-command:
365+
- meta_content_scope: meta.function-call.arguments.powershell
365366
- include: command-ending-sequences
366367
- include: redirection
367368
- include: cli-parameters

Tests/syntax_test_PowerShell.ps1

Lines changed: 136 additions & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ using namespace System.Management.Automation
9696
# ^ keyword.operator.call.powershell
9797
# ^^^^^^^^ meta.function-call.powershell variable.function.powershell
9898
# @@@@@@@@ reference
99+
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function-call.arguments.powershell
99100
# ^^^^^ variable.parameter.option.powershell
100101
# ^ punctuation.definition.parameter.powershell
101102
# ^^^^^^^ meta.string.powershell string.quoted.single.powershell
@@ -112,6 +113,7 @@ using namespace System.Management.Automation
112113
# ^ keyword.operator.call.powershell
113114
# ^^^^^^^^^^^ meta.function-call.powershell variable.function.powershell
114115
# @@@@@@@@@@@ reference
116+
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function-call.arguments.powershell
115117
# ^^ variable.parameter.option.powershell
116118
# ^ punctuation.definition.parameter.powershell
117119
# ^^^^^^^^^^^^^^ meta.string.powershell string.quoted.single.powershell
@@ -131,13 +133,15 @@ using namespace System.Management.Automation
131133
# ^ keyword.operator.assignment.powershell
132134
# ^^^^^^^^^^^ meta.function-call.powershell support.function.powershell
133135
# @@@@@@@@@@@ reference
136+
# ^^^^^^^^^^^^^ meta.function-call.arguments.powershell
134137
# ^^^^^ variable.parameter.option.powershell
135138
# ^ punctuation.definition.parameter.powershell
136139
# ^^^^ string.unquoted.powershell
137140
# ^ keyword.operator.background.powershell
138141
Receive-Job $job -Wait
139142
# ^^^^^^^^^^^ meta.function-call.powershell support.function.powershell
140143
# @@@@@@@@@@@ reference
144+
# ^^^^^^^^^^^ meta.function-call.arguments.powershell
141145
# ^^^^ variable.other.readwrite.powershell
142146
# ^ punctuation.definition.variable.powershell
143147
# ^^^^^ variable.parameter.option.powershell
@@ -817,109 +821,156 @@ $a3[1..2]
817821

818822
###[ Commands ]################################################################
819823

820-
# Commands (functions)
821-
Invoke-Something -foobar
822-
#^ support.function
823-
# ^ punctuation.definition.parameter
824-
# ^^^^^^^ variable.parameter.option
825-
#@@@@@@@@@@@@@@@@ reference
826-
Invoke-Something -foobar value
827-
#^ support.function
828-
# ^ punctuation.definition.parameter
829-
# ^^^^^^^ variable.parameter.option
830-
#@@@@@@@@@@@@@@@@ reference
831-
Invoke-Something -foobar:$true
832-
#^ support.function
833-
#@@@@@@@@@@@@@@@@ reference
834-
# ^ punctuation.definition.parameter
835-
# ^^^^^^^ variable.parameter.option
836-
# ^ punctuation.definition.variable
837-
# ^^^^ constant.language
838-
Invoke-Something -foobar: $true
839-
#^ support.function
840-
#@@@@@@@@@@@@@@@@ reference
841-
# ^ punctuation.definition.parameter
842-
# ^^^^^^^ variable.parameter.option
843-
Invoke-Something -p1 v1 -p2 10 -p3 'value' -switch -verbose
844-
#^ support.function
845-
#@@@@@@@@@@@@@@@@ reference
846-
# ^ punctuation.definition.parameter
847-
# ^^^ variable.parameter.option
848-
# ^ punctuation.definition.parameter
849-
# ^^^ variable.parameter.option
850-
# ^^ meta.number.integer.decimal constant.numeric.value
851-
# ^^^^^^ - keyword
852-
# ^ punctuation.definition.parameter
853-
# ^^^ variable.parameter.option
854-
Invoke-Something (1..20 | Invoke-Something) -p2 'value'
855-
#^ support.function
856-
#@@@@@@@@@@@@@@@@ reference
857-
# @@@@@@@@@@@@@@@@ reference
858-
# ^^ keyword.operator.range
859-
Invoke-Something -p1 v2 -p2 30 | Invoke-Something -switch
860-
#^ support.function
861-
# @@@@@@@@@@@@@@@@ reference
862-
#@@@@@@@@@@@@@@@@ reference
863-
# ^ punctuation.definition.parameter
864-
# ^^^ variable.parameter.option
865-
# ^ punctuation.definition.parameter
866-
# ^^^ variable.parameter.option
867-
# ^^ meta.number.integer.decimal constant.numeric.value
868-
# ^ keyword.operator.logical.pipe
869-
# ^ support.function
870-
# ^ punctuation.definition.parameter
871-
# ^^^^^^^ variable.parameter.option - keyword
872-
Invoke-Something -p1 {
873-
#^ support.function
874-
#@@@@@@@@@@@@@@@@ reference
875-
# ^ punctuation.definition.parameter
876-
# ^^^ variable.parameter.option
824+
Invoke-Something -foobar
825+
# ^^^^^^^^^^^^^^^^ meta.function-call.powershell support.function.powershell
826+
# @@@@@@@@@@@@@@@@ reference
827+
# ^^^^^^^^ meta.function-call.arguments.powershell
828+
# ^^^^^^^ variable.parameter.option.powershell
829+
# ^ punctuation.definition.parameter.powershell
830+
Invoke-Something -foobar value
831+
# ^^^^^^^^^^^^^^^^ meta.function-call.powershell support.function.powershell
832+
# @@@@@@@@@@@@@@@@ reference
833+
# ^^^^^^^^^^^^^^ meta.function-call.arguments.powershell
834+
# ^^^^^^^ variable.parameter.option.powershell
835+
# ^ punctuation.definition.parameter.powershell
836+
# ^^^^^ string.unquoted.powershell
877837
Invoke-Something -foobar:$true
878-
# ^ support.function
838+
# ^^^^^^^^^^^^^^^^ meta.function-call.powershell support.function.powershell
879839
# @@@@@@@@@@@@@@@@ reference
880-
# ^ punctuation.definition.parameter
881-
# ^^^^^^^ variable.parameter.option
882-
# ^ punctuation.definition.variable
883-
# ^^^^ constant.language
884-
} | Invoke-Something
885-
# <- punctuation.section.braces.end
886-
# ^ keyword.operator.logical.pipe
887-
# ^ support.function
840+
# ^^^^^^^^^^^^^^ meta.function-call.arguments.powershell
841+
# ^^^^^^^ variable.parameter.option.powershell
842+
# ^ punctuation.definition.parameter.powershell
843+
# ^ keyword.operator.ternary.powershell
844+
# ^^^^^ constant.language.boolean.true.powershell
845+
# ^ punctuation.definition.variable.powershell
846+
Invoke-Something -foobar: $true
847+
# ^^^^^^^^^^^^^^^^ meta.function-call.powershell support.function.powershell
888848
# @@@@@@@@@@@@@@@@ reference
889-
Invoke-Something -p1 value `
890-
#^^^^^^^^^^^^^^^^ meta.function-call.powershell support.function.powershell
891-
#@@@@@@@@@@@@@@@@ reference
892-
# ^^^ variable.parameter.option.powershell
893-
# ^ punctuation.definition.parameter.powershell
894-
# ^^^^^ string.unquoted.powershell
895-
# ^ punctuation.separator.continuation.line.powershell
849+
# ^^^^^^^^^^^^^^^ meta.function-call.arguments.powershell
850+
# ^^^^^^^ variable.parameter.option.powershell
851+
# ^ punctuation.definition.parameter.powershell
852+
# ^ keyword.operator.ternary.powershell
853+
# ^^^^^ constant.language.boolean.true.powershell
854+
# ^ punctuation.definition.variable.powershell
855+
Invoke-Something -p1 v1 -p2 10 -p3 'value' -switch -verbose
856+
# ^^^^^^^^^^^^^^^^ meta.function-call.powershell support.function.powershell
857+
# @@@@@@@@@@@@@@@@ reference
858+
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function-call.arguments.powershell
859+
# ^^^ variable.parameter.option.powershell
860+
# ^ punctuation.definition.parameter.powershell
861+
# ^^ string.unquoted.powershell
862+
# ^^^ variable.parameter.option.powershell
863+
# ^ punctuation.definition.parameter.powershell
864+
# ^^ meta.number.integer.decimal.powershell constant.numeric.value.powershell
865+
# ^^^ variable.parameter.option.powershell
866+
# ^ punctuation.definition.parameter.powershell
867+
# ^^^^^^^ meta.string.powershell string.quoted.single.powershell
868+
# ^ punctuation.definition.string.begin.powershell
869+
# ^ punctuation.definition.string.end.powershell
870+
# ^^^^^^^ variable.parameter.option.powershell
871+
# ^ punctuation.definition.parameter.powershell
872+
# ^^^^^^^^ variable.parameter.option.powershell
873+
# ^ punctuation.definition.parameter.powershell
874+
Invoke-Something (1..20 | Invoke-Something) -p2 'value'
875+
# ^^^^^^^^^^^^^^^^ meta.function-call.powershell support.function.powershell
876+
# @@@@@@@@@@@@@@@@ reference
877+
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function-call.arguments.powershell
878+
# ^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.group.powershell
879+
# ^ punctuation.section.group.begin.powershell
880+
# ^ meta.number.integer.decimal.powershell constant.numeric.value.powershell
881+
# ^^ keyword.operator.range.powershell
882+
# ^^ meta.number.integer.decimal.powershell constant.numeric.value.powershell
883+
# ^ keyword.operator.logical.pipe.powershell
884+
# ^^^^^^^^^^^^^^^^ meta.function-call.powershell support.function.powershell
885+
# @@@@@@@@@@@@@@@@ reference
886+
# ^ punctuation.section.group.end.powershell
887+
# ^^^ variable.parameter.option.powershell
888+
# ^ punctuation.definition.parameter.powershell
889+
# ^^^^^^^ meta.string.powershell string.quoted.single.powershell
890+
# ^ punctuation.definition.string.begin.powershell
891+
# ^ punctuation.definition.string.end.powershell
892+
Invoke-Something -p1 v2 -p2 30 | Invoke-Something -switch
893+
# ^^^^^^^^^^^^^^^^ meta.function-call.powershell support.function.powershell
894+
# @@@@@@@@@@@@@@@@ reference
895+
# ^^^^^^^^^^^^^^^ meta.function-call.arguments.powershell
896+
# ^^^ variable.parameter.option.powershell
897+
# ^ punctuation.definition.parameter.powershell
898+
# ^^ string.unquoted.powershell
899+
# ^^^ variable.parameter.option.powershell
900+
# ^ punctuation.definition.parameter.powershell
901+
# ^^ meta.number.integer.decimal.powershell constant.numeric.value.powershell
902+
# ^ keyword.operator.logical.pipe.powershell
903+
# ^^^^^^^^^^^^^^^^ meta.function-call.powershell support.function.powershell
904+
# @@@@@@@@@@@@@@@@ reference
905+
# ^^^^^^^^ meta.function-call.arguments.powershell
906+
# ^^^^^^^ variable.parameter.option.powershell
907+
# ^ punctuation.definition.parameter.powershell
908+
Invoke-Something -p1 {
909+
# ^^^^^^^^^^^^^^^^ meta.function-call.powershell support.function.powershell
910+
# @@@@@@@@@@@@@@@@ reference
911+
# ^^^^^^ meta.function-call.arguments.powershell
912+
# ^^^ variable.parameter.option.powershell
913+
# ^ punctuation.definition.parameter.powershell
914+
# ^ meta.block.powershell punctuation.section.braces.begin.powershell
915+
Invoke-Something -foobar:$true
916+
#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function-call.arguments.powershell meta.block.powershell
917+
# ^^^^^^^^^^^^^^^^ meta.function-call.powershell support.function.powershell
918+
# @@@@@@@@@@@@@@@@ reference
919+
# ^^^^^^^^^^^^^^ meta.function-call.arguments.powershell
920+
# ^^^^^^^ variable.parameter.option.powershell
921+
# ^ punctuation.definition.parameter.powershell
922+
# ^ keyword.operator.ternary.powershell
923+
# ^^^^^ constant.language.boolean.true.powershell
924+
# ^ punctuation.definition.variable.powershell
925+
} | Invoke-Something
926+
#^^^^^^^^^ meta.function-call.arguments.powershell
927+
#^^^^^^^^ meta.block.powershell
928+
# ^ punctuation.section.braces.end.powershell
929+
# ^ keyword.operator.logical.pipe.powershell
930+
# ^^^^^^^^^^^^^^^^ meta.function-call.powershell support.function.powershell
931+
# @@@@@@@@@@@@@@@@ reference
932+
933+
Invoke-Something -p1 value `
934+
# ^^^^^^^^^^^^^^^^ meta.function-call.powershell support.function.powershell
935+
# @@@@@@@@@@@@@@@@ reference
936+
# ^^^^^^^^^^^^ meta.function-call.arguments.powershell
937+
# ^^^ variable.parameter.option.powershell
938+
# ^ punctuation.definition.parameter.powershell
939+
# ^^^^^ string.unquoted.powershell
940+
# ^ punctuation.separator.continuation.line.powershell
896941
-p2 14.4 `
897-
# ^ punctuation.definition.parameter
898-
# ^^^ variable.parameter.option
899-
# ^^^^ meta.number.float.decimal constant.numeric.value
900-
# ^ punctuation.separator.continuation
942+
#^^^^^^^^^^^^^ meta.function-call.arguments.powershell
943+
# ^^^ variable.parameter.option.powershell
944+
# ^ punctuation.definition.parameter.powershell
945+
# ^^^^ meta.number.float.decimal.powershell constant.numeric.value.powershell
946+
# ^ punctuation.separator.decimal.powershell
947+
# ^ punctuation.separator.continuation.line.powershell
901948
-p3 $value | Invoke-Something -verbose
902-
# ^ punctuation.definition.parameter
903-
# ^^^ variable.parameter.option
949+
#^^^^^^^^^^^^^^ meta.function-call.arguments.powershell
950+
# ^^^ variable.parameter.option.powershell
951+
# ^ punctuation.definition.parameter.powershell
952+
# ^^^^^^ variable.other.readwrite.powershell
953+
# ^ punctuation.definition.variable.powershell
954+
# ^ keyword.operator.logical.pipe.powershell
955+
# ^^^^^^^^^^^^^^^^ meta.function-call.powershell support.function.powershell
904956
# @@@@@@@@@@@@@@@@ reference
905-
# ^ punctuation.definition.parameter
906-
# ^^^^^^^^ variable.parameter.option
907-
# ^ punctuation.definition.variable
908-
# ^ keyword.operator.logical.pipe
909-
# ^^^^^^^^^^^^^^^^ support.function
957+
# ^^^^^^^^^ meta.function-call.arguments.powershell
958+
# ^^^^^^^^ variable.parameter.option.powershell
959+
# ^ punctuation.definition.parameter.powershell
910960

911961
Get-ChildItem |
912962
# ^^^^^^^^^^^^^ meta.function-call.powershell support.function.powershell
913963
# @@@@@@@@@@@@@ reference
964+
# ^^ meta.function-call.arguments.powershell
914965
# ^ keyword.operator.logical.pipe.powershell
915966
Select Name,Length
916967
# ^^^^^^ meta.function-call.powershell variable.function.powershell
917968
# @@@@@@ reference
969+
# ^^^^^^^^^^^^ meta.function-call.arguments.powershell
918970
# ^^^^ string.unquoted.powershell
919971
# ^ punctuation.separator.sequence.powershell
920972
# ^^^^^^ string.unquoted.powershell
921973

922-
923974
# Commands (Built-in variables)
924975
ls *.ps1 -recurse
925976
# ^^ meta.function-call.powershell variable.function.powershell

0 commit comments

Comments
 (0)