Skip to content

Commit b45a435

Browse files
Chickenkeepermtoohey31
authored andcommitted
Add PowerShell highlighting (helix-editor#9827)
1 parent 7b676a1 commit b45a435

File tree

4 files changed

+191
-0
lines changed

4 files changed

+191
-0
lines changed

book/src/generated/lang-support.md

+1
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@
132132
| po ||| | |
133133
| pod || | | |
134134
| ponylang |||| |
135+
| powershell || | | |
135136
| prisma || | | `prisma-language-server` |
136137
| prolog | | | | `swipl` |
137138
| protobuf |||| `bufls`, `pb` |

languages.toml

+14
Original file line numberDiff line numberDiff line change
@@ -3259,3 +3259,17 @@ indent = { tab-width = 4, unit = " " }
32593259
[[grammar]]
32603260
name = "fidl"
32613261
source = { git = "https://github.com/google/tree-sitter-fidl", rev = "bdbb635a7f5035e424f6173f2f11b9cd79703f8d" }
3262+
3263+
[[language]]
3264+
name = "powershell"
3265+
scope = "source.powershell"
3266+
injection-regex = "(pwsh|powershell)"
3267+
file-types = [ "ps1", "psm1", "psd1", "pscc", "psrc" ]
3268+
shebangs = [ "pwsh", "powershell" ]
3269+
comment-token = '#'
3270+
block-comment-tokens = { start = "<#", end = "#>" }
3271+
indent = { tab-width = 4, unit = " " }
3272+
3273+
[[grammar]]
3274+
name = "powershell"
3275+
source = { git = "https://github.com/airbus-cert/tree-sitter-powershell", rev = "c9316be0faca5d5b9fd3b57350de650755f42dc0" }
+174
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,174 @@
1+
[
2+
"if"
3+
"elseif"
4+
"else"
5+
"switch"
6+
] @keyword.control.conditional
7+
8+
[
9+
"foreach"
10+
"for"
11+
"while"
12+
"do"
13+
"until"
14+
] @keyword.control.repeat
15+
16+
[
17+
"break"
18+
"continue"
19+
"return"
20+
] @keyword.control.return
21+
22+
"in" @keyword.operator
23+
24+
"function" @keyword.function
25+
26+
[
27+
"class"
28+
"enum"
29+
] @keyword.storage.type
30+
31+
[
32+
"param"
33+
"dynamicparam"
34+
"begin"
35+
"process"
36+
"end"
37+
"filter"
38+
"workflow"
39+
"throw"
40+
"exit"
41+
"trap"
42+
"try"
43+
"catch"
44+
"finally"
45+
"data"
46+
"inlinescript"
47+
"parallel"
48+
"sequence"
49+
] @keyword
50+
51+
[
52+
"-as"
53+
"-ccontains"
54+
"-ceq"
55+
"-cge"
56+
"-cgt"
57+
"-cle"
58+
"-clike"
59+
"-clt"
60+
"-cmatch"
61+
"-cne"
62+
"-cnotcontains"
63+
"-cnotlike"
64+
"-cnotmatch"
65+
"-contains"
66+
"-creplace"
67+
"-csplit"
68+
"-eq"
69+
"-ge"
70+
"-gt"
71+
"-icontains"
72+
"-ieq"
73+
"-ige"
74+
"-igt"
75+
"-ile"
76+
"-ilike"
77+
"-ilt"
78+
"-imatch"
79+
"-in"
80+
"-ine"
81+
"-inotcontains"
82+
"-inotlike"
83+
"-inotmatch"
84+
"-ireplace"
85+
"-is"
86+
"-isnot"
87+
"-isplit"
88+
"-join"
89+
"-le"
90+
"-like"
91+
"-lt"
92+
"-match"
93+
"-ne"
94+
"-not"
95+
"-notcontains"
96+
"-notin"
97+
"-notlike"
98+
"-notmatch"
99+
"-replace"
100+
"-shl"
101+
"-shr"
102+
"-split"
103+
"-and"
104+
"-or"
105+
"-xor"
106+
"-band"
107+
"-bor"
108+
"-bxor"
109+
"+"
110+
"-"
111+
"*"
112+
"/"
113+
"%"
114+
"++"
115+
"--"
116+
"!"
117+
"\\"
118+
".."
119+
"|"
120+
] @operator
121+
122+
(assignement_operator) @operator
123+
124+
[
125+
"("
126+
")"
127+
"{"
128+
"}"
129+
"["
130+
"]"
131+
] @punctuation.bracket
132+
133+
[
134+
";"
135+
","
136+
"::"
137+
] @punctuation.delimiter
138+
139+
(string_literal) @string
140+
141+
(integer_literal) @constant.numeric
142+
(real_literal) @constant.numeric
143+
144+
(command
145+
command_name: (command_name) @function)
146+
147+
(function_name) @function
148+
149+
(invokation_expression
150+
(member_name) @function)
151+
152+
(member_access
153+
(member_name) @variable.other.member)
154+
155+
(command_invokation_operator) @operator
156+
157+
(type_spec) @type
158+
159+
(variable) @variable
160+
161+
(comment) @comment
162+
163+
(array_expression) @punctuation.bracket
164+
165+
(assignment_expression
166+
value: (pipeline) @variable)
167+
168+
(format_operator) @operator
169+
170+
(command_parameter) @variable.parameter
171+
172+
(command_elements) @variable.builtin
173+
174+
(generic_token) @variable
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
((comment) @injection.content
2+
(#set! injection.language "comment"))

0 commit comments

Comments
 (0)