Skip to content

Commit cdacd44

Browse files
committed
Extract flow-like matches to named contexts
1 parent 1c2adf9 commit cdacd44

File tree

1 file changed

+55
-43
lines changed

1 file changed

+55
-43
lines changed

PowerShell.sublime-syntax

Lines changed: 55 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -54,49 +54,10 @@ contexts:
5454
- match: \B\.(?= )
5555
scope: support.function.source.powershell
5656

57-
# Exceptions
58-
- match: \b(?i:throw){{kebab_break}}
59-
scope: keyword.control.exception.raise.powershell
60-
- match: \b(?i:try){{kebab_break}}
61-
scope: keyword.control.exception.try.powershell
62-
- match: \b(?i:catch|trap){{kebab_break}}
63-
scope: keyword.control.exception.catch.powershell
64-
- match: \b(?i:finally){{kebab_break}}
65-
scope: keyword.control.exception.finally.powershell
66-
67-
# Loops
68-
- match: \b(?i:for|foreach(?!-object)){{kebab_break}}
69-
scope: keyword.control.loop.for.powershell
70-
- match: \b(?i:do){{kebab_break}}
71-
scope: keyword.control.loop.do-while.powershell
72-
- match: \b(?i:while){{kebab_break}}
73-
scope: keyword.control.loop.while.powershell
74-
- match: \b(?i:until){{kebab_break}}
75-
scope: keyword.control.loop.repeat-until.powershell
76-
77-
# Flow
78-
- match: \b(?i:break){{kebab_break}}
79-
scope: keyword.control.flow.break.powershell
80-
- match: \b(?i:continue){{kebab_break}}
81-
scope: keyword.control.flow.continue.powershell
82-
- match: \b(?i:exit){{kebab_break}}
83-
scope: keyword.control.flow.exit.powershell
84-
- match: \b(?i:return){{kebab_break}}
85-
scope: keyword.control.flow.return.powershell
86-
87-
# Conditionals
88-
- match: \b(?i:if){{kebab_break}}
89-
scope: keyword.control.conditional.if.powershell
90-
- match: \b(?i:elseif){{kebab_break}}
91-
scope: keyword.control.conditional.elseif.powershell
92-
- match: \b(?i:else){{kebab_break}}
93-
scope: keyword.control.conditional.else.powershell
94-
- match: \b(?i:switch){{kebab_break}}
95-
scope: keyword.control.conditional.switch.powershell
96-
- match: \?
97-
scope: keyword.control.conditional.select.powershell
98-
- match: \b(?i:where(?!-object)){{kebab_break}}
99-
scope: keyword.control.conditional.select.powershell
57+
- include: exceptions
58+
- include: loops
59+
- include: flow
60+
- include: conditionals
10061

10162
expressions:
10263
# Meta
@@ -148,6 +109,57 @@ contexts:
148109

149110
- include: operators
150111
- include: parameters
112+
###[ EXCEPTIONS ]##############################################################
113+
114+
exceptions:
115+
- match: \b(?i:throw){{kebab_break}}
116+
scope: keyword.control.exception.raise.powershell
117+
- match: \b(?i:try){{kebab_break}}
118+
scope: keyword.control.exception.try.powershell
119+
- match: \b(?i:catch|trap){{kebab_break}}
120+
scope: keyword.control.exception.catch.powershell
121+
- match: \b(?i:finally){{kebab_break}}
122+
scope: keyword.control.exception.finally.powershell
123+
124+
###[ LOOPS ]###################################################################
125+
126+
loops:
127+
- match: \b(?i:for|foreach(?!-object)){{kebab_break}}
128+
scope: keyword.control.loop.for.powershell
129+
- match: \b(?i:do){{kebab_break}}
130+
scope: keyword.control.loop.do-while.powershell
131+
- match: \b(?i:while){{kebab_break}}
132+
scope: keyword.control.loop.while.powershell
133+
- match: \b(?i:until){{kebab_break}}
134+
scope: keyword.control.loop.repeat-until.powershell
135+
136+
###[ FLOW ]####################################################################
137+
138+
flow:
139+
- match: \b(?i:break){{kebab_break}}
140+
scope: keyword.control.flow.break.powershell
141+
- match: \b(?i:continue){{kebab_break}}
142+
scope: keyword.control.flow.continue.powershell
143+
- match: \b(?i:exit){{kebab_break}}
144+
scope: keyword.control.flow.exit.powershell
145+
- match: \b(?i:return){{kebab_break}}
146+
scope: keyword.control.flow.return.powershell
147+
148+
###[ CONDITIONALS ]############################################################
149+
150+
conditionals:
151+
- match: \b(?i:if){{kebab_break}}
152+
scope: keyword.control.conditional.if.powershell
153+
- match: \b(?i:elseif){{kebab_break}}
154+
scope: keyword.control.conditional.elseif.powershell
155+
- match: \b(?i:else){{kebab_break}}
156+
scope: keyword.control.conditional.else.powershell
157+
- match: \b(?i:switch){{kebab_break}}
158+
scope: keyword.control.conditional.switch.powershell
159+
- match: \?
160+
scope: keyword.control.conditional.select.powershell
161+
- match: \b(?i:where(?!-object)){{kebab_break}}
162+
scope: keyword.control.conditional.select.powershell
151163

152164
###[ GROUPS ]##################################################################
153165

0 commit comments

Comments
 (0)