Skip to content

Commit 7daa98a

Browse files
committed
Add labels
1 parent be42068 commit 7daa98a

File tree

2 files changed

+30
-15
lines changed

2 files changed

+30
-15
lines changed

PowerShell.sublime-syntax

Lines changed: 26 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -103,9 +103,12 @@ contexts:
103103
scope: keyword.declaration.variable.powershell
104104

105105
expressions:
106+
# Meta
107+
- include: labels
106108
- include: regions
107109
- include: requires-directives
108110

111+
# Normal code
109112
- include: commands
110113
- include: constants
111114
- include: types
@@ -854,6 +857,29 @@ contexts:
854857
2: constant.numeric.suffix.powershell
855858
push: members
856859

860+
###[ LABELS ]##################################################################
861+
862+
labels:
863+
- match: ^\s*((:){{identifier_simple}})
864+
captures:
865+
1: entity.name.label.powershell
866+
2: punctuation.definition.label.powershell
867+
868+
regions:
869+
- match: ^\s*((#)\s*(region\b)(?:\s*(\S.*))?(\n?))
870+
captures:
871+
1: comment.line.powershell
872+
2: punctuation.definition.comment.powershell
873+
3: keyword.other.region.begin.powershell
874+
4: meta.toc-list.powershell entity.name.section.powershell
875+
5: meta.fold.begin.powershell
876+
- match: ^\s*((#)\s*(endregion\b).*(\n?))
877+
captures:
878+
1: comment.line.powershell
879+
2: punctuation.definition.comment.powershell
880+
3: keyword.other.region.end.powershell
881+
4: meta.fold.end.powershell
882+
857883
###[ COMMENTS ]################################################################
858884

859885
comments:
@@ -904,21 +930,6 @@ contexts:
904930
- include: pop-eol
905931
- include: comment-embedded-docs
906932

907-
regions:
908-
- match: ^\s*((#)\s*(region\b)(?:\s*(\S.*))?(\n?))
909-
captures:
910-
1: comment.line.powershell
911-
2: punctuation.definition.comment.powershell
912-
3: keyword.other.region.begin.powershell
913-
4: meta.toc-list.powershell entity.name.section.powershell
914-
5: meta.fold.begin.powershell
915-
- match: ^\s*((#)\s*(endregion\b).*(\n?))
916-
captures:
917-
1: comment.line.powershell
918-
2: punctuation.definition.comment.powershell
919-
3: keyword.other.region.end.powershell
920-
4: meta.fold.end.powershell
921-
922933
###[ COMPONENTS ]##############################################################
923934

924935
comma-separators:

Tests/syntax_test_PowerShell.ps1

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,10 @@ using namespace System.Management.Automation
8080
# ^ meta.requires meta.hashtable
8181
# ^^^^^^^^^ meta.requires meta.hashtable string.quoted.double
8282

83+
:label1
84+
# ^^^^^^^ entity.name.label.powershell
85+
# ^ punctuation.definition.label.powershell
86+
8387
throw "Do not run this file!"
8488
# <- keyword.control
8589
# ^^^^^^^^^^^^^^^^^^^^^^^ string.quoted.double

0 commit comments

Comments
 (0)