Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add PowerShell highlighting #9827

Merged
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
1 change: 1 addition & 0 deletions book/src/generated/lang-support.md
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@
| po | ✓ | ✓ | | |
| pod | ✓ | | | |
| ponylang | ✓ | ✓ | ✓ | |
| powershell | ✓ | | | |
| prisma | ✓ | | | `prisma-language-server` |
| prolog | | | | `swipl` |
| protobuf | ✓ | ✓ | ✓ | `bufls`, `pb` |
Expand Down
14 changes: 14 additions & 0 deletions languages.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3259,3 +3259,17 @@ indent = { tab-width = 4, unit = " " }
[[grammar]]
name = "fidl"
source = { git = "https://github.com/google/tree-sitter-fidl", rev = "bdbb635a7f5035e424f6173f2f11b9cd79703f8d" }

[[language]]
name = "powershell"
scope = "source.powershell"
injection-regex = "(pwsh|powershell)"
file-types = [ "ps1", "psm1", "psd1", "pscc", "psrc" ]
shebangs = [ "pwsh", "powershell" ]
comment-token = '#'
block-comment-tokens = { start = "<#", end = "#>" }
indent = { tab-width = 4, unit = " " }

[[grammar]]
name = "powershell"
source = { git = "https://github.com/airbus-cert/tree-sitter-powershell", rev = "c9316be0faca5d5b9fd3b57350de650755f42dc0" }
174 changes: 174 additions & 0 deletions runtime/queries/powershell/highlights.scm
Original file line number Diff line number Diff line change
@@ -0,0 +1,174 @@
[
"if"
"elseif"
"else"
"switch"
] @keyword.control.conditional

[
"foreach"
"for"
"while"
"do"
"until"
] @keyword.control.repeat

[
"break"
"continue"
"return"
] @keyword.control.return

"in" @keyword.operator

"function" @keyword.function

[
"class"
"enum"
] @keyword.storage.type

[
"param"
"dynamicparam"
"begin"
"process"
"end"
"filter"
"workflow"
"throw"
"exit"
"trap"
"try"
"catch"
"finally"
"data"
"inlinescript"
"parallel"
"sequence"
] @keyword

[
"-as"
"-ccontains"
"-ceq"
"-cge"
"-cgt"
"-cle"
"-clike"
"-clt"
"-cmatch"
"-cne"
"-cnotcontains"
"-cnotlike"
"-cnotmatch"
"-contains"
"-creplace"
"-csplit"
"-eq"
"-ge"
"-gt"
"-icontains"
"-ieq"
"-ige"
"-igt"
"-ile"
"-ilike"
"-ilt"
"-imatch"
"-in"
"-ine"
"-inotcontains"
"-inotlike"
"-inotmatch"
"-ireplace"
"-is"
"-isnot"
"-isplit"
"-join"
"-le"
"-like"
"-lt"
"-match"
"-ne"
"-not"
"-notcontains"
"-notin"
"-notlike"
"-notmatch"
"-replace"
"-shl"
"-shr"
"-split"
"-and"
"-or"
"-xor"
"-band"
"-bor"
"-bxor"
"+"
"-"
"*"
"/"
"%"
"++"
"--"
"!"
"\\"
".."
"|"
] @operator

(assignement_operator) @operator

[
"("
")"
"{"
"}"
"["
"]"
] @punctuation.bracket

[
";"
","
"::"
] @punctuation.delimiter

(string_literal) @string

(integer_literal) @constant.numeric
(real_literal) @constant.numeric

(command
command_name: (command_name) @function)

(function_name) @function

(invokation_expression
(member_name) @function)

(member_access
(member_name) @variable.other.member)

(command_invokation_operator) @operator

(type_spec) @type

(variable) @variable

(comment) @comment

(array_expression) @punctuation.bracket

(assignment_expression
value: (pipeline) @variable)

(format_operator) @operator

(command_parameter) @variable.parameter

(command_elements) @variable.builtin

(generic_token) @variable
2 changes: 2 additions & 0 deletions runtime/queries/powershell/injections.scm
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
((comment) @injection.content
(#set! injection.language "comment"))
Loading