├── Fold.tmPreferences ├── ISE Nostalgia.sublime-color-scheme ├── Indentation.tmPreferences ├── LICENSE.txt ├── PowerShell.sublime-syntax ├── README.md ├── Snippets ├── (beg) scriptblock begin clause.sublime-snippet ├── (catch) catch {...}.sublime-snippet ├── (comm) comment block.sublime-snippet ├── (elif) elseif {...}.sublime-snippet ├── (elifi) elseif in-line.sublime-snippet ├── (else) else {...}.sublime-snippet ├── (elsei) else in-line.sublime-snippet ├── (end) scriptblock end clause.sublime-snippet ├── (fil) new filter.sublime-snippet ├── (fin) finally {...}.sublime-snippet ├── (fun) define function.sublime-snippet ├── (here) heredoc string (single quoted).sublime-snippet ├── (hhere) heredoc string (double quoted).sublime-snippet ├── (if) if {...}.sublime-snippet ├── (ifelse) if {...} else {...}.sublime-snippet ├── (ifi) if in-line.sublime-snippet ├── (mydocs) path to My Documents.sublime-snippet ├── (proc) scriptblock process clause.sublime-snippet ├── (sd) enable script debug stepping.sublime-snippet ├── (sub) $(...) complex subexpression.sublime-snippet ├── (thisdir) path to current script.sublime-snippet ├── (tmp) create temp file.sublime-snippet ├── (try) try {...}.sublime-snippet ├── Powershell.sublime-completions └── env.sublime-snippet ├── Support ├── Comments.tmPreferences ├── PowerShell.sublime-settings └── Powershell.sublime-build ├── Tests ├── syntax_test_Class.ps1 ├── syntax_test_Function.ps1 ├── syntax_test_PowerShell.ps1 └── syntax_test_reindent.ps1 ├── messages.json └── messages └── prerelease-invitation.md /Fold.tmPreferences: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | scope 5 | source.powershell 6 | settings 7 | 8 | foldScopes 9 | 10 | 11 | begin 12 | meta.fold.begin 13 | end 14 | meta.fold.end 15 | 16 | 17 | begin 18 | punctuation.definition.comment.block.begin 19 | end 20 | punctuation.definition.comment.block.end 21 | excludeTrailingNewlines 22 | 23 | 24 | 25 | begin 26 | string.quoted.double.heredoc punctuation.definition.string.begin 27 | end 28 | string.quoted.double.heredoc punctuation.definition.string.end 29 | excludeTrailingNewlines 30 | 31 | 32 | 33 | begin 34 | string.quoted.single.heredoc punctuation.definition.string.begin 35 | end 36 | string.quoted.single.heredoc punctuation.definition.string.end 37 | excludeTrailingNewlines 38 | 39 | 40 | 41 | begin 42 | punctuation.section.group.begin 43 | end 44 | punctuation.section.group.end 45 | excludeTrailingNewlines 46 | 47 | 48 | 49 | begin 50 | punctuation.section.braces.begin 51 | end 52 | punctuation.section.braces.end 53 | excludeTrailingNewlines 54 | 55 | 56 | 57 | 58 | 59 | 60 | -------------------------------------------------------------------------------- /ISE Nostalgia.sublime-color-scheme: -------------------------------------------------------------------------------- 1 | { 2 | "name": "ISE Nostalgia", 3 | "author": "Guillermo L\u00f3pez-Anglada", 4 | "variables": 5 | { 6 | "blue": "#87beff", 7 | "blue2": "#add6ff", 8 | "blue3": "#5ab1cd", 9 | "blue4": "#585cf6", 10 | "blue5": "#0000ff", 11 | "blue6": "#6d79de", 12 | "blue7":"#21439C", 13 | "green": "#006400", 14 | "green2": "#06960e", 15 | "grey": "#a9a9a9", 16 | "grey2": "#7f7f7f", 17 | "grey3": "#292929", 18 | "grey4": "#70727E", 19 | "purple": "#8a2be2", 20 | "purple2": "#801e92", 21 | "purple3": "#aa69b6", 22 | "red": "#6b0000", 23 | "red2": "#ff4500", 24 | "red3": "#b85b44", 25 | "white": "#ffffff", 26 | "white2": "#fef8da", 27 | "white3": "#e3f1ff", 28 | "yellow": "#ffff00", 29 | }, 30 | "globals": 31 | { 32 | "foreground": "var(purple)", 33 | "background": "var(white)", 34 | "caret": "var(grey2)", 35 | // "invisibles": "var(grey2)", 36 | "line_highlight": "var(white2)", 37 | "selection": "var(blue2)", 38 | "selection_border": "var(blue)", 39 | "inactive_selection": "var(white3)", 40 | "gutter_foreground": "var(blue3)", 41 | }, 42 | "rules": 43 | [ 44 | { 45 | "name": "Comment", 46 | "scope": "comment", 47 | "foreground": "var(green)", 48 | "font_style": "normal", 49 | }, 50 | { 51 | "name": "Keyword", 52 | "scope": "keyword, storage", 53 | "foreground": "var(grey3)", 54 | }, 55 | { 56 | "name": "Number", 57 | "scope": "constant.numeric", 58 | "foreground": "var(purple2)", 59 | }, 60 | { 61 | "name": "Built-in constant", 62 | "scope": "constant.language", 63 | "foreground": "var(blue4)", 64 | }, 65 | { 66 | "name": "Variable", 67 | "scope": "variable.language, variable.other", 68 | "foreground": "var(red2)", 69 | }, 70 | { 71 | "name": "String", 72 | "scope": "string", 73 | "foreground": "var(red)", 74 | }, 75 | { 76 | "name": "String interpolation", 77 | "scope": "constant.character.escape, string source", 78 | "foreground": "var(purple3)", 79 | }, 80 | // { 81 | // "name": "Function name", 82 | // "scope": "entity.name.function, support.function.any-method", 83 | // "foreground": "var(blue5)", 84 | // }, 85 | // { 86 | // "name": "Type name", 87 | // "scope": "entity.name.type", 88 | // "font_style": "underline", 89 | // }, 90 | // { 91 | // "name": "Inherited class name", 92 | // "scope": "entity.other.inherited-class", 93 | // "font_style": "italic", 94 | // }, 95 | // { 96 | // "name": "Function parameter", 97 | // "scope": "variable.parameter", 98 | // "font_style": "italic", 99 | // }, 100 | // { 101 | // "name": "Function argument and result types", 102 | // "scope": "storage.type.method", 103 | // "font_style": "", 104 | // "foreground": "var(grey4)", 105 | // }, 106 | // { 107 | // "name": "Section", 108 | // "scope": "meta.section entity.name.section, declaration.section entity.name.section", 109 | // "font_style": "italic", 110 | // }, 111 | { 112 | "name": "Library function", 113 | "scope": "support.function", 114 | "foreground": "var(blue5)", 115 | }, 116 | // { 117 | // "name": "Library object", 118 | // "scope": "support.class, support.type", 119 | // "font_style": "bold", 120 | // "foreground": "var(blue6)", 121 | // }, 122 | // { 123 | // "name": "Library constant", 124 | // "scope": "support.constant", 125 | // "font_style": "bold", 126 | // "foreground": "var(green2)", 127 | // }, 128 | // { 129 | // "name": "Library variable", 130 | // "scope": "support.variable", 131 | // "font_style": "bold", 132 | // "foreground": "var(blue7)", 133 | // }, 134 | { 135 | "name": "PowerShell: Assignment Operator", 136 | "scope": "keyword.operator.assignment.powershell", 137 | "foreground": "var(grey)", 138 | }, 139 | { 140 | "name": "Invalid", 141 | "scope": "invalid", 142 | "foreground": "var(yellow)", 143 | "background": "var(red3)", 144 | }, 145 | { 146 | "name": "Invalid trailing whitespace", 147 | "scope": "invalid.deprecated.trailing-whitespace", 148 | "background": "var(red3)", 149 | } 150 | ] 151 | } 152 | -------------------------------------------------------------------------------- /Indentation.tmPreferences: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | name 6 | Indentation Rules 7 | scope 8 | source.powershell 9 | settings 10 | 11 | unIndentedLinePattern 12 | "@ 13 | decreaseIndentPattern 14 | ^(.*\*/)?\s*\}[;\s]*(?:$|else\b|elseif\b) 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) 2011-2015 Guillermo López-Anglada 2 | 2020-2021 Michael Lyons 3 | 4 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 5 | 6 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 7 | 8 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 9 | -------------------------------------------------------------------------------- /PowerShell.sublime-syntax: -------------------------------------------------------------------------------- 1 | %YAML 1.2 2 | --- 3 | # http://www.sublimetext.com/docs/3/syntax.html 4 | name: PowerShell 5 | scope: source.powershell 6 | version: 2 7 | 8 | file_extensions: 9 | - ps1 10 | - psm1 11 | - psd1 12 | 13 | first_line_match: |- 14 | (?x: 15 | ^\#!.*\b(?:pwsh|powershell)\b 16 | | ^\# \s* -\*- [^*]* mode: \s* powershell [^*]* -\*- 17 | ) 18 | 19 | variables: 20 | dec_exponent: (?:[eE][-+]?\d*) 21 | dec_suffix: '[dD]' 22 | float_suffix: '[dDlL]' 23 | int_suffix: (?i:u[lsy]?|[lnsy]) 24 | unit_suffix: (?i:[kmgtp]b\b) 25 | kebab_break: (?![\w-]) 26 | 27 | contexts: 28 | 29 | pop-before-newline: 30 | - match: (?=\n|$) 31 | pop: true 32 | 33 | pop-at-newline: 34 | - match: \n|$ 35 | pop: true 36 | 37 | main: 38 | - include: regions 39 | - include: comments 40 | - include: expressions 41 | 42 | expressions: 43 | - include: redirection 44 | - include: commands 45 | - include: variable 46 | - include: group 47 | - include: function 48 | - include: attribute 49 | - include: using-directive 50 | - include: type 51 | - include: hashtable 52 | - include: strings 53 | - include: script-block 54 | - include: escape-characters 55 | - include: numeric-constant 56 | - include: class-method 57 | - match: (@)(\() 58 | captures: 59 | 1: keyword.other.array.begin.powershell 60 | 2: punctuation.section.group.begin.powershell 61 | push: 62 | - meta_scope: meta.group.array-expression.powershell 63 | - match: \) 64 | scope: punctuation.section.group.end.powershell 65 | pop: true 66 | - include: main 67 | - match: (\$)(\() 68 | # TODO: move to repo; make recursive. 69 | captures: 70 | 1: keyword.other.variable.definition.powershell 71 | 2: punctuation.section.group.begin.powershell 72 | push: 73 | - meta_scope: meta.group.complex.subexpression.powershell 74 | - match: \) 75 | scope: punctuation.section.group.end.powershell 76 | pop: true 77 | - include: main 78 | - match: \b[\w.-]+\.(?i:exe|com|cmd|bat)\b 79 | scope: variable.function.powershell 80 | # Consume a string with a trailing dot 81 | # to prevent members with particular names from being recognized as keywords. 82 | - match: \b[\w-]+(?=\.) 83 | scope: variable.other.object.powershell 84 | push: members 85 | # Exceptions 86 | - match: \b(?i:throw){{kebab_break}} 87 | scope: keyword.control.exception.raise.powershell 88 | - match: \b(?i:try){{kebab_break}} 89 | scope: keyword.control.exception.try.powershell 90 | - match: \b(?i:catch|trap){{kebab_break}} 91 | scope: keyword.control.exception.catch.powershell 92 | - match: \b(?i:finally){{kebab_break}} 93 | scope: keyword.control.exception.finally.powershell 94 | # Conditionals 95 | - match: \b(?i:if){{kebab_break}} 96 | scope: keyword.control.conditional.if.powershell 97 | - match: \b(?i:elseif){{kebab_break}} 98 | scope: keyword.control.conditional.elseif.powershell 99 | - match: \b(?i:else){{kebab_break}} 100 | scope: keyword.control.conditional.else.powershell 101 | - match: \b(?i:switch){{kebab_break}} 102 | scope: keyword.control.conditional.switch.powershell 103 | - match: \? 104 | scope: keyword.control.conditional.select.powershell 105 | - match: \b(?i:where(?!-object)){{kebab_break}} 106 | scope: keyword.control.conditional.select.powershell 107 | # Begin/End 108 | - match: \b(?i:begin){{kebab_break}} 109 | scope: keyword.context.block.begin.powershell 110 | - match: \b(?i:process){{kebab_break}} 111 | scope: keyword.context.block.process.powershell 112 | - match: \b(?i:end){{kebab_break}} 113 | scope: keyword.context.block.end.powershell 114 | - match: \b(?i:clean){{kebab_break}} 115 | scope: keyword.context.block.clean.powershell 116 | # Loops 117 | - match: \b(?i:for|foreach(?!-object)){{kebab_break}} 118 | scope: keyword.control.loop.for.powershell 119 | - match: \b(?i:do){{kebab_break}} 120 | scope: keyword.control.loop.do-while.powershell 121 | - match: \b(?i:while){{kebab_break}} 122 | scope: keyword.control.loop.while.powershell 123 | - match: \b(?i:until){{kebab_break}} 124 | scope: keyword.control.loop.repeat-until.powershell 125 | # Flow 126 | - match: \b(?i:break){{kebab_break}} 127 | scope: keyword.control.flow.break.powershell 128 | - match: \b(?i:continue){{kebab_break}} 129 | scope: keyword.control.flow.continue.powershell 130 | - match: \b(?i:exit){{kebab_break}} 131 | scope: keyword.control.flow.exit.powershell 132 | - match: \b(?i:return){{kebab_break}} 133 | scope: keyword.control.flow.return.powershell 134 | # Declaration 135 | - match: \b(?i:var){{kebab_break}} 136 | # scope: storage.type.variable.powershell 137 | scope: keyword.declaration.variable.powershell 138 | - match: \b(?i:(?:dynamic)?param){{kebab_break}} 139 | scope: keyword.declaration.parameter.powershell # This scope is not standard 140 | # Uncategorized keywords 141 | - match: \b(?i:data|default|define|from|in|inlinescript|parallel|sequence){{kebab_break}} 142 | scope: keyword.control.powershell 143 | - match: \B--%\B 144 | scope: keyword.control.powershell 145 | push: 146 | - meta_content_scope: string.unquoted.powershell 147 | - include: pop-before-newline 148 | - match: \b(?i:hidden|static)\b 149 | # This should only be relevant inside a class but will require a rework of how classes are matched. This is a temp fix. 150 | scope: storage.modifier.powershell 151 | - match: \b((?i:class))\s+([\w-]+)\b 152 | captures: 153 | 1: storage.type.class.powershell 154 | 2: meta.class.powershell entity.name.class.powershell 155 | # Operators... 156 | - match: \B(-)(?i:as){{kebab_break}} 157 | scope: keyword.operator.cast.powershell 158 | captures: 159 | 1: punctuation.definition.keyword.powershell 160 | - match: \B(-)(?i:[ic]?(?:eq|ne|[gl][te])){{kebab_break}} 161 | scope: keyword.operator.comparison.powershell 162 | captures: 163 | 1: punctuation.definition.keyword.powershell 164 | - match: \B(-)(?i:[ic]?(?:not)?(?:like|match|contains|in)){{kebab_break}} 165 | scope: keyword.operator.logical.powershell 166 | captures: 167 | 1: punctuation.definition.keyword.powershell 168 | - match: \B(-)(?i:join|split|replace){{kebab_break}} 169 | scope: keyword.operator.string.powershell 170 | captures: 171 | 1: punctuation.definition.keyword.powershell 172 | - match: \B(-)(?i:is(?:not)?){{kebab_break}} 173 | scope: keyword.operator.logical.powershell 174 | captures: 175 | 1: punctuation.definition.keyword.powershell 176 | - match: \B(-)(?i:and|or|not|xor){{kebab_break}}|! # <-- note `!` 177 | scope: keyword.operator.logical.powershell 178 | captures: 179 | 1: punctuation.definition.keyword.powershell 180 | - match: \B(-)(?i:band|bor|bnot|bxor|sh[lr]){{kebab_break}} 181 | scope: keyword.operator.bitwise.powershell 182 | captures: 183 | 1: punctuation.definition.keyword.powershell 184 | - match: \B(-)(?i:f){{kebab_break}} 185 | scope: keyword.operator.string-format.powershell 186 | captures: 187 | 1: punctuation.definition.keyword.powershell 188 | # Flags/Options/Parameters 189 | - match: \B(--?|[/+])\p{L}(?:[\w-]*\w)? 190 | scope: variable.parameter.option.powershell 191 | captures: 192 | 1: punctuation.definition.parameter.powershell 193 | # Operators continue... 194 | - match: '[+/*%-]?=' 195 | scope: keyword.operator.assignment.powershell 196 | - match: (?:\+\+|--)(?![ \t]*\d) 197 | scope: keyword.operator.assignment.powershell 198 | - match: '[+-](?=\.?\d)' # This is sort of heuristic 199 | scope: keyword.operator.unary.powershell 200 | - match: '[+/*-]' 201 | scope: keyword.operator.arithmetic.powershell 202 | - match: '%(?!\s*\{)' 203 | scope: keyword.operator.arithmetic.powershell 204 | - match: \|\||&& 205 | scope: keyword.operator.logical.powershell 206 | - match: \| 207 | scope: keyword.operator.logical.pipe.powershell 208 | - match: ; 209 | scope: punctuation.terminator.statement.powershell 210 | - match: \`(?=\n|$) 211 | scope: punctuation.separator.continuation.line.powershell 212 | - match: ',' 213 | scope: punctuation.separator.sequence.powershell 214 | - match: '&|\B\.(?= )' 215 | scope: keyword.operator.other.powershell 216 | - match: \.\.(?=\-?\d|\(|\$) 217 | # This is very imprecise. Is there a syntax for 'must come after...'? 218 | scope: keyword.operator.range.powershell 219 | 220 | comments: 221 | - include: comment-block 222 | - include: comment-line 223 | 224 | redirection: 225 | # https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_redirection 226 | - match: ([2-6*])(>&)(1) 227 | captures: 228 | 1: constant.numeric.decimal.file-descriptor.powershell 229 | 2: keyword.operator.redirection.powershell 230 | 3: constant.numeric.decimal.file-descriptor.powershell 231 | - match: ([1-6*])(>>?) 232 | captures: 233 | 1: constant.numeric.decimal.file-descriptor.powershell 234 | 2: keyword.operator.redirection.powershell 235 | - match: '>>?' 236 | scope: keyword.operator.redirection.powershell 237 | # - match: <+ 238 | # scope: invalid.illegal.powershell 239 | 240 | requires-directive: 241 | # TODO: add back `(?<=#)`-equivalent match 242 | - match: (#)((?i:requires))\s 243 | captures: 244 | 1: punctuation.definition.keyword.powershell 245 | 2: keyword.control.import.require.powershell 246 | push: 247 | - meta_scope: meta.requires.powershell 248 | - include: pop-at-newline 249 | - include: hashtable 250 | - match: (-)(?i:Modules|PSSnapin|RunAsAdministrator|ShellId|Version) 251 | scope: variable.parameter.option.powershell 252 | captures: 253 | 1: punctuation.definition.variable.powershell 254 | - match: ',' 255 | scope: punctuation.separator.powershell 256 | 257 | using-directive: 258 | - match: \b(?i:(using))\s+(?i:(namespace|module))\s+(?i:((?:\w+(?:\.)?)+)) 259 | captures: 260 | 1: keyword.control.using.powershell 261 | 2: keyword.other.powershell 262 | 3: variable.parameter.powershell 263 | 264 | attribute: 265 | - match: |- 266 | (?xi: 267 | (\[)\s* 268 | ( 269 | CmdletBinding | Alias | OutputType | Parameter 270 | | Validate 271 | (?: 272 | Count | NotNull(?:OrEmpty)? | Range | Pattern | Length | Set 273 | | Script) 274 | | Allow(?: Null | Empty(?: Collection | String )) 275 | )\b 276 | ) 277 | captures: 278 | 1: punctuation.section.brackets.begin.powershell 279 | 2: support.function.attribute.powershell 280 | push: 281 | - meta_scope: meta.attribute.powershell 282 | - match: \] 283 | scope: punctuation.section.brackets.end.powershell 284 | pop: true 285 | - match: \( 286 | scope: punctuation.section.group.begin.powershell 287 | push: 288 | - match: \) 289 | scope: punctuation.section.group.end.powershell 290 | pop: true 291 | - include: variable 292 | - include: variable-no-property 293 | - include: hashtable 294 | - include: script-block 295 | - include: escape-characters 296 | - include: double-quoted-string 297 | - include: type 298 | - include: numeric-constant 299 | - include: main 300 | - match: |- 301 | (?xi: 302 | \b( 303 | Mandatory | ValueFromPipeline(?:ByPropertyName)? 304 | | ValueFromRemainingArguments | Position(?:alBinding)? 305 | | (?:Default)?ParameterSetName | SupportsShouldProcess | SupportsPaging 306 | | HelpUri | ConfirmImpact | HelpMessage 307 | )\b 308 | \s*(=)? 309 | ) 310 | captures: 311 | 1: variable.parameter.attribute.powershell 312 | 2: keyword.operator.assignment.powershell 313 | - match: \' 314 | scope: punctuation.definition.string.begin.powershell 315 | push: 316 | - meta_scope: string.quoted.single.powershell 317 | - match: \'\' 318 | scope: constant.character.escape.powershell 319 | - match: \' 320 | scope: punctuation.definition.string.end.powershell 321 | pop: true 322 | 323 | commands: 324 | # "Verb-Noun pattern:" 325 | - match: |- 326 | (?x: 327 | (?:[\w\\:-]*\\)? # Path stuff 328 | \b(?i: 329 | Add | Approve | Assert | Backup | Block | Build | Checkpoint # "Official" Verbs 330 | | Clear | Close | Compare | Complete | Compress | Confirm | Connect 331 | | Convert | ConvertFrom | ConvertTo | Copy | Debug | Deny | Deploy 332 | | Disable | Disconnect | Dismount | Edit | Enable | Enter | Exit 333 | | Expand | Export | Find | Format | Get | Grant | Group | Hide 334 | | Import | Initialize | Install | Invoke | Join | Limit | Lock 335 | | Measure | Merge | Mount | Move | New | Open | Optimize | Out | Ping 336 | | Pop | Protect | Publish | Push | Read | Receive | Redo | Register 337 | | Remove | Rename | Repair | Request | Reset | Resize | Resolve 338 | | Restart | Restore | Resume | Revoke | Save | Search | Select | Send 339 | | Set | Show | Skip | Split | Start | Step | Stop | Submit | Suspend 340 | | Switch | Sync | Test | Trace | Unblock | Undo | Uninstall | Unlock 341 | | Unprotect | Unpublish | Unregister | Update | Use | Wait | Watch 342 | | Write 343 | ) 344 | \-\w+? # Any "noun" 345 | (?:\.(?i:exe|cmd|bat|ps1))?\b # More path stuff 346 | ) 347 | scope: meta.function-call.powershell support.function.powershell 348 | # Builtin cmdlets with reserved verbs 349 | - match: \b(?i:(?:foreach|where|sort|tee)-object)\b 350 | scope: support.function.powershell 351 | 352 | comment-block: 353 | - match: <# 354 | scope: punctuation.definition.comment.block.begin.powershell 355 | push: 356 | - meta_scope: comment.block.powershell 357 | - match: '#>' 358 | scope: punctuation.definition.comment.block.end.powershell 359 | pop: true 360 | - include: comment-embedded-docs 361 | 362 | comment-embedded-docs: 363 | # TODO 364 | # https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_comment_based_help 365 | - match: |- 366 | (?xi: 367 | ^\s*(\.) 368 | ( 369 | Component | Description | Example | ExternalHelp | ForwardHelpCategory | ForwardHelpTargetName 370 | | Functionality | Inputs | Link | Notes | Outputs | Parameter | RemoteHelpRunSpace 371 | | Role | Synopsis 372 | ) 373 | ) 374 | scope: comment.documentation.embedded.powershell 375 | captures: 376 | 1: punctuation.definition.keyword.documentation.powershell 377 | 2: keyword.other.documentation.powershell 378 | - match: ^\s*(\.)(?i:(Parameter)\s+([a-z0-9-_]+)) 379 | scope: comment.documentation.embedded.powershell 380 | captures: 381 | 1: punctuation.definition.keyword.documentation.powershell 382 | 2: keyword.other.documentation.param.powershell 383 | 3: variable.parameter.powershell 384 | - match: ^\s*(\.)(?i:(ForwardHelpTargetName|ForwardHelpCategory|ExternalHelp|Link)\s+([a-z0-9-_]+)) 385 | scope: comment.documentation.embedded.powershell 386 | captures: 387 | 1: punctuation.definition.keyword.documentation.powershell 388 | 2: keyword.other.documentation.powershell 389 | 3: markup.underline.link.powershell 390 | 391 | comment-line: 392 | - include: requires-directive 393 | - match: '#' 394 | scope: punctuation.definition.comment.powershell 395 | push: 396 | - meta_scope: comment.line.powershell 397 | - include: pop-at-newline 398 | - include: comment-embedded-docs 399 | 400 | static-members: 401 | # - meta_content_scope: debug.in.static-members 402 | - match: '::' 403 | scope: punctuation.accessor.double-colon.powershell 404 | set: members 405 | 406 | members: 407 | # - meta_content_scope: debug.in.members 408 | - match: (?=\.\.) 409 | pop: true 410 | - match: \.(?=\w) 411 | scope: punctuation.accessor.dot.powershell 412 | - match: (\w+)(\() 413 | captures: 414 | 1: meta.function-call.powershell variable.function.powershell 415 | 2: meta.function-call.arguments.powershell punctuation.section.arguments.begin.powershell 416 | push: 417 | - meta_content_scope: meta.function-call.arguments.powershell 418 | - match: \) 419 | scope: meta.function-call.arguments.powershell punctuation.section.arguments.end.powershell 420 | pop: true 421 | - include: expressions 422 | - match: \w+ 423 | scope: variable.other.member.powershell 424 | - match: \[ 425 | scope: punctuation.section.brackets.begin.powershell 426 | push: 427 | - meta_scope: meta.brackets.indexer.powershell 428 | - match: \] 429 | scope: punctuation.section.brackets.end.powershell 430 | pop: true 431 | - include: expressions 432 | - match: '' 433 | pop: true 434 | 435 | strings: 436 | - include: double-quoted-string 437 | - include: single-quoted-string 438 | - match: \@"(?=$) 439 | scope: punctuation.definition.string.begin.powershell 440 | push: 441 | - meta_scope: meta.string.powershell string.quoted.double.heredoc.powershell 442 | - match: ^"@ 443 | scope: punctuation.definition.string.end.powershell 444 | pop: true 445 | - include: escape-characters 446 | - include: interpolation 447 | - match: \@'(?=$) 448 | scope: punctuation.definition.string.begin.powershell 449 | push: 450 | - meta_scope: meta.string.powershell string.quoted.single.heredoc.powershell 451 | - match: ^'@ 452 | scope: punctuation.definition.string.end.powershell 453 | pop: true 454 | - match: "''" 455 | scope: constant.character.escape.powershell 456 | 457 | single-quoted-string: 458 | - match: \' 459 | scope: punctuation.definition.string.begin.powershell 460 | push: 461 | - meta_scope: meta.string.powershell string.quoted.single.powershell 462 | - match: "''" 463 | scope: constant.character.escape.powershell 464 | - match: \' 465 | scope: punctuation.definition.string.end.powershell 466 | pop: true 467 | 468 | double-quoted-string: 469 | - match: '"' 470 | scope: punctuation.definition.string.begin.powershell 471 | push: 472 | - meta_scope: meta.string.powershell string.quoted.double.powershell 473 | - match: '""' 474 | scope: constant.character.escape.powershell 475 | - include: escape-characters 476 | - match: '"' 477 | scope: punctuation.definition.string.end.powershell 478 | pop: true 479 | - match: '(?i)\b[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,64}\b' 480 | - include: interpolation 481 | - match: '`\s*$' 482 | scope: keyword.other.powershell 483 | 484 | escape-characters: 485 | - match: '`[0abenfrvt"''$`]' 486 | scope: constant.character.escape.powershell 487 | - match: '`u\{\h+\}' 488 | scope: constant.character.escape.powershell 489 | 490 | function: 491 | - match: ^(?:\s*)(?i)(function|filter|configuration|workflow)\s+(?:(global|local|script|private):)?((?:\p{L}|\d|_|-|\.)+) 492 | scope: meta.function.powershell 493 | captures: 494 | 1: storage.type.powershell 495 | 2: storage.modifier.scope.powershell 496 | 3: entity.name.function.powershell 497 | push: 498 | - match: (?=\{|\() 499 | pop: true 500 | - include: comment-line 501 | 502 | hashtable: 503 | - match: (@)(\{) 504 | captures: 505 | 1: keyword.other.hashtable.begin.powershell 506 | 2: punctuation.section.braces.begin.powershell 507 | push: 508 | - meta_scope: meta.hashtable.powershell 509 | - match: \} 510 | scope: punctuation.section.braces.end.powershell 511 | pop: true 512 | - match: \b(['"]?)(\w+)(['"]?)\s*(=)\s* 513 | scope: meta.hashtable.assignment.powershell 514 | captures: 515 | 1: punctuation.definition.string.begin.powershell 516 | 2: variable.other.readwrite.powershell 517 | 3: punctuation.definition.string.end.powershell 518 | 4: keyword.operator.assignment.powershell 519 | - include: script-block 520 | - include: main 521 | 522 | group: 523 | - match: \( 524 | scope: punctuation.section.group.begin.powershell 525 | push: 526 | - meta_scope: meta.group.powershell 527 | - match: \) 528 | scope: punctuation.section.group.end.powershell 529 | pop: true 530 | - include: main 531 | 532 | interpolation: 533 | - match: \$\( 534 | scope: punctuation.section.interpolation.begin.powershell 535 | push: 536 | - clear_scopes: 1 537 | - meta_scope: meta.interpolation.powershell 538 | - meta_content_scope: source.powershell.embedded 539 | - match: \) 540 | scope: punctuation.section.interpolation.end.powershell 541 | pop: true 542 | - include: main 543 | - match: (?=\$) 544 | push: 545 | - clear_scopes: 1 546 | - meta_scope: meta.interpolation.powershell 547 | - include: variable-no-property 548 | - include: variable 549 | - match: '' 550 | pop: true 551 | 552 | numeric-constant: 553 | - match: \b(0[bB])([01]*)({{int_suffix}}?{{unit_suffix}}?) 554 | scope: meta.number.integer.binary.powershell 555 | captures: 556 | 1: constant.numeric.base.powershell 557 | 2: constant.numeric.value.powershell 558 | 3: constant.numeric.suffix.powershell 559 | push: members 560 | - match: \b(0[xX])(\h*)({{int_suffix}}?{{unit_suffix}}?) 561 | scope: meta.number.integer.hexadecimal.powershell 562 | captures: 563 | 1: constant.numeric.base.powershell 564 | 2: constant.numeric.value.powershell 565 | 3: constant.numeric.suffix.powershell 566 | push: members 567 | - match: |- 568 | (?x) 569 | ( 570 | # .10 .10e5 571 | (\.)\d+{{dec_exponent}}? 572 | # 1.2 1.2e-3 1.e2 1e2 573 | | \d+ (?: (\.) \d+ {{dec_exponent}}? | (\.)? {{dec_exponent}} ) 574 | ) 575 | ( {{float_suffix}}? {{unit_suffix}}? ) 576 | | 577 | # 10.l 10.lGB 10.GB 578 | ( \d+ (\.) ) 579 | ( {{float_suffix}} {{unit_suffix}}? | {{unit_suffix}} ) 580 | scope: meta.number.float.decimal.powershell 581 | captures: 582 | 1: constant.numeric.value.powershell 583 | 2: punctuation.separator.decimal.powershell 584 | 3: punctuation.separator.decimal.powershell 585 | 4: punctuation.separator.decimal.powershell 586 | 5: constant.numeric.suffix.powershell 587 | 6: constant.numeric.value.powershell 588 | 7: punctuation.separator.decimal.powershell 589 | 8: constant.numeric.suffix.powershell 590 | push: members 591 | - match: \b(\d+)({{dec_suffix}}{{unit_suffix}}?) 592 | scope: meta.number.float.decimal.powershell 593 | captures: 594 | 1: constant.numeric.value.powershell 595 | 2: constant.numeric.suffix.powershell 596 | push: members 597 | - match: \b(\d+)({{int_suffix}}?{{unit_suffix}}?) 598 | scope: meta.number.integer.decimal.powershell 599 | captures: 600 | 1: constant.numeric.value.powershell 601 | 2: constant.numeric.suffix.powershell 602 | push: members 603 | 604 | script-block: 605 | - match: (%)?(\{) 606 | captures: 607 | 1: keyword.control.loop.for.powershell 608 | 2: punctuation.section.braces.begin.powershell 609 | push: 610 | - meta_scope: meta.block.powershell 611 | - match: \} 612 | scope: punctuation.section.braces.end.powershell 613 | pop: true 614 | - include: main 615 | 616 | type: 617 | # TODO: push a maybe-static-members context 618 | - match: \[ 619 | scope: punctuation.section.brackets.begin.powershell 620 | push: 621 | - match: \](?=::) 622 | scope: punctuation.section.brackets.end.powershell 623 | set: static-members 624 | - match: \] 625 | scope: punctuation.section.brackets.end.powershell 626 | pop: true 627 | - match: (?!\d+|\.)[\p{L}\p{N}.]+ 628 | scope: storage.type.powershell 629 | - include: main 630 | 631 | variable: 632 | - match: (\$)(?i:True|False|Null)\b 633 | scope: constant.language.powershell 634 | captures: 635 | 1: punctuation.definition.variable.powershell 636 | - match: |- 637 | (?xi: 638 | (\$) 639 | (?: 640 | ExecutionContext | Host | Home | IsCoreCLR | IsLinux | IsWindows 641 | | IsMacOS | PID | Profile | PsCommandPath | PsHome | PsScriptRoot 642 | | PsUiCulture | PsVersionTable | ShellID 643 | ) 644 | ) 645 | scope: support.constant.variable.powershell 646 | captures: 647 | 1: punctuation.definition.variable.powershell 648 | push: members 649 | - match: |- 650 | (?xi: 651 | (\$) 652 | (?: 653 | [$^?_] 654 | | (?: 655 | Args | ConsoleFileName | Error | Event | EventArgs 656 | | EventSubscriber | ForEach | Input | LastExitCode | Matches 657 | | MyInvocation | NestedPromptLevel | PsBoundParameters | PsCmdlet 658 | | PsCulture | PsDebugContext | PsItem | Pwd | Sender | SourceArgs 659 | | SourceEventArgs | StackTrace | Switch | This 660 | )\b 661 | ) 662 | ) 663 | scope: variable.language.powershell 664 | captures: 665 | 1: punctuation.definition.variable.powershell 666 | push: members 667 | - match: |- 668 | (?xi: 669 | (\$) 670 | (?: 671 | (?: 672 | Confirm | Debug | ErrorAction | Information | Progress | Verbose # *Preference 673 | | Warning | WhatIf 674 | ) 675 | Preference 676 | | Maximum(?:Alias|Drive|Error|Function|History|Variable)Count # Maximum*Count 677 | | Log(?:Command|Engine|Provider)(?:Health|Lifecycle)Event # Log*Event 678 | | PsDebugContext | PsDefaultParameterValues | PsEmailServer 679 | | PsModuleAutoloadingPreference | PsSenderInfo 680 | | PsSessionApplicationName | PsSessionConfigurationName 681 | | PsSessionOption | ErrorView | FormatEnumerationLimit | OFS 682 | | OutputEncoding 683 | ) 684 | ) 685 | scope: variable.language.powershell 686 | captures: 687 | 1: punctuation.definition.variable.powershell 688 | push: members 689 | - match: ((\$|@)(?i:(global|local|private|script|using|workflow):\w+)) 690 | captures: 691 | 1: variable.other.readwrite.powershell 692 | 2: punctuation.definition.variable.powershell 693 | 3: storage.modifier.scope.powershell 694 | push: members 695 | - match: ((\$)(\{)((?i:global|local|private|script|using|workflow)):([^}]*[^}`])(\})) 696 | captures: 697 | 1: variable.other.readwrite.powershell 698 | 2: punctuation.definition.variable.powershell 699 | 3: punctuation.section.braces.begin.powershell 700 | 4: storage.modifier.scope.powershell 701 | 6: punctuation.section.braces.end.powershell 702 | push: members 703 | - match: ((?i:(\$|@)(\w+:)?\w+)) 704 | captures: 705 | 1: variable.other.readwrite.powershell 706 | 2: punctuation.definition.variable.powershell 707 | 3: support.variable.drive.powershell 708 | 4: variable.other.member.powershell 709 | push: members 710 | - match: ((?i:(\$)(\{)(\w+:)?([^}]*[^}`])(\}))) 711 | captures: 712 | 1: variable.other.readwrite.powershell 713 | 2: punctuation.definition.variable.powershell 714 | 3: punctuation.section.braces.begin.powershell 715 | 4: support.variable.drive.powershell 716 | 6: punctuation.section.braces.end.powershell 717 | push: members 718 | 719 | variable-no-property: 720 | - match: (\$)(?i:True|False|Null)\b 721 | scope: constant.language.powershell 722 | captures: 723 | 1: punctuation.definition.variable.powershell 724 | - match: |- 725 | (?xi: 726 | (\$) 727 | (?: 728 | ExecutionContext | Host | Home | IsCoreCLR | IsLinux | IsWindows 729 | | IsMacOS | PID | Profile | PsCommandPath | PsHome | PsScriptRoot 730 | | PsUiCulture | PsVersionTable | ShellID 731 | ) 732 | ) 733 | scope: support.constant.variable.powershell 734 | captures: 735 | 1: punctuation.definition.variable.powershell 736 | - match: |- 737 | (?xi: 738 | (\$) 739 | (?: 740 | [$^?_] 741 | | (?: 742 | Args | ConsoleFileName | Error | Event | EventArgs 743 | | EventSubscriber | ForEach | Input | LastExitCode | Matches 744 | | MyInvocation | NestedPromptLevel | PsBoundParameters | PsCmdlet 745 | | PsCulture | PsDebugContext | PsItem | Pwd | Sender | SourceArgs 746 | | SourceEventArgs | StackTrace | Switch | This 747 | )\b 748 | ) 749 | ) 750 | scope: variable.language.powershell 751 | captures: 752 | 1: punctuation.definition.variable.powershell 753 | - match: |- 754 | (?xi: 755 | (\$) 756 | (?: 757 | (?: 758 | Confirm | Debug | ErrorAction | Information | Progress | Verbose # *Preference 759 | | Warning | WhatIf 760 | ) 761 | Preference 762 | | Maximum(?:Alias|Drive|Error|Function|History|Variable)Count # Maximum*Count 763 | | Log(?:Command|Engine|Provider)(?:Health|Lifecycle)Event # Log*Event 764 | | PsDebugContext | PsDefaultParameterValues | PsEmailServer 765 | | PsModuleAutoloadingPreference | PsSenderInfo 766 | | PsSessionApplicationName | PsSessionConfigurationName 767 | | PsSessionOption | ErrorView | FormatEnumerationLimit | OFS 768 | | OutputEncoding 769 | ) 770 | ) 771 | scope: variable.language.powershell 772 | captures: 773 | 1: punctuation.definition.variable.powershell 774 | - match: (?i:(\$|@)(global|local|private|script|using|workflow):(\w+)) 775 | captures: 776 | 1: punctuation.definition.variable.powershell 777 | 2: storage.modifier.scope.powershell 778 | 3: variable.other.readwrite.powershell 779 | - match: (?i:(\$)(\{)(global|local|private|script|using|workflow):([^}]*[^}`])(\})) 780 | captures: 781 | 1: punctuation.definition.variable.powershell 782 | 2: punctuation.section.braces.begin 783 | 3: storage.modifier.scope.powershell 784 | 4: variable.other.readwrite.powershell 785 | 5: punctuation.section.braces.end 786 | - match: (?i:(\$)(\w+:)?\w+) 787 | scope: variable.other.readwrite.powershell 788 | captures: 789 | 1: punctuation.definition.variable.powershell 790 | 2: support.variable.drive.powershell 791 | - match: (?i:(\$)(\{)(\w+:)?([^}]*[^}`])(\})) 792 | captures: 793 | 1: punctuation.definition.variable.powershell 794 | 2: punctuation.section.braces.begin 795 | 3: support.variable.drive.powershell 796 | 4: variable.other.readwrite.powershell 797 | 5: punctuation.section.braces.end 798 | 799 | class-method: 800 | - match: ^(?:\s*)(?i)(hidden|static)?\s*(\[)((?!\d+|\.)[\p{L}\p{N}.]+)(\])\s*((?:\p{L}|\d|_|-|\.)+)\s*(?=\() 801 | scope: meta.function.powershell 802 | captures: 803 | 1: storage.modifier.powershell 804 | 2: punctuation.section.brackets.begin.powershell 805 | 3: storage.type.powershell 806 | 4: punctuation.section.brackets.end.powershell 807 | 5: entity.name.function.powershell 808 | push: 809 | - match: (?=\() 810 | pop: true 811 | - include: comment-line 812 | 813 | regions: 814 | - match: ^\s*((#)\s*(region\b)(?:\s*(\S.*))?(\n?)) 815 | captures: 816 | 1: comment.line.powershell 817 | 2: punctuation.definition.comment.powershell 818 | 3: keyword.other.region.begin.powershell 819 | 4: meta.toc-list.powershell entity.name.section.powershell 820 | 5: meta.fold.begin.powershell 821 | - match: ^\s*((#)\s*(endregion\b).*(\n?)) 822 | captures: 823 | 1: comment.line.powershell 824 | 2: punctuation.definition.comment.powershell 825 | 3: keyword.other.region.end.powershell 826 | 4: meta.fold.end.powershell 827 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # PowerShell Package for Sublime Text 3 2 | 3 | [![Join the chat at https://gitter.im/SublimeText/PowerShell](https://badges.gitter.im/SublimeText/PowerShell.svg)](https://gitter.im/SublimeText/PowerShell?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) 4 | 5 | Adds support for the MS PowerShell programming language. 6 | 7 | ### Installing 8 | 9 | 1. Install [package control][package_control] for Sublime Text. 10 | 1. Install the **PowerShell** package: 11 | 12 | 1. Press Ctrl+Shift+P (Cmd+Shift+P on Mac) 13 | 1. Select 'Install Package' 14 | 1. Select 'PowerShell' 15 | 16 | 17 | ### Developing 18 | 19 | You want to contribute? Awesome! Take a look at [CONTRIBUTING.md](CONTRIBUTING.md). 20 | 21 | ### EditorSyntax 22 | 23 | Syntax highlighting is adapted from the [EditorSyntax][] project. 24 | 25 | [package_control]: https://sublime.wbond.net/installation 26 | [EditorSyntax]: https://github.com/PowerShell/EditorSyntax 27 | -------------------------------------------------------------------------------- /Snippets/(beg) scriptblock begin clause.sublime-snippet: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 6 | beg 7 | 8 | source.powershell 9 | 10 | -------------------------------------------------------------------------------- /Snippets/(catch) catch {...}.sublime-snippet: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | catch 7 | source.powershell 8 | 9 | -------------------------------------------------------------------------------- /Snippets/(comm) comment block.sublime-snippet: -------------------------------------------------------------------------------- 1 | 2 | 3 | ]]> 6 | 7 | comm 8 | 9 | source.powershell 10 | 11 | Comment block 12 | 13 | -------------------------------------------------------------------------------- /Snippets/(elif) elseif {...}.sublime-snippet: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | 7 | elif 8 | 9 | source.powershell 10 | 11 | -------------------------------------------------------------------------------- /Snippets/(elifi) elseif in-line.sublime-snippet: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | elifi 6 | 7 | source.powershell 8 | 9 | -------------------------------------------------------------------------------- /Snippets/(else) else {...}.sublime-snippet: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | 7 | else 8 | 9 | source.powershell 10 | 11 | -------------------------------------------------------------------------------- /Snippets/(elsei) else in-line.sublime-snippet: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | elsei 6 | 7 | source.powershell 8 | 9 | -------------------------------------------------------------------------------- /Snippets/(end) scriptblock end clause.sublime-snippet: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 6 | end 7 | 8 | source.powershell 9 | 10 | -------------------------------------------------------------------------------- /Snippets/(fil) new filter.sublime-snippet: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | 7 | fil 8 | 9 | source.powershell 10 | 11 | -------------------------------------------------------------------------------- /Snippets/(fin) finally {...}.sublime-snippet: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | fin 7 | source.powershell 8 | 9 | -------------------------------------------------------------------------------- /Snippets/(fun) define function.sublime-snippet: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | 7 | fun 8 | 9 | source.powershell 10 | 11 | -------------------------------------------------------------------------------- /Snippets/(here) heredoc string (single quoted).sublime-snippet: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | 7 | here 8 | 9 | source.powershell 10 | 11 | -------------------------------------------------------------------------------- /Snippets/(hhere) heredoc string (double quoted).sublime-snippet: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | 7 | hhere 8 | 9 | source.powershell 10 | 11 | -------------------------------------------------------------------------------- /Snippets/(if) if {...}.sublime-snippet: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | 7 | if 8 | 9 | source.powershell 10 | 11 | -------------------------------------------------------------------------------- /Snippets/(ifelse) if {...} else {...}.sublime-snippet: -------------------------------------------------------------------------------- 1 | 2 | 3 | 9 | 10 | ifelse 11 | 12 | source.powershell 13 | 14 | -------------------------------------------------------------------------------- /Snippets/(ifi) if in-line.sublime-snippet: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | ifi 6 | 7 | source.powershell 8 | 9 | -------------------------------------------------------------------------------- /Snippets/(mydocs) path to My Documents.sublime-snippet: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | mydocs 6 | 7 | source.powershell 8 | 9 | -------------------------------------------------------------------------------- /Snippets/(proc) scriptblock process clause.sublime-snippet: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 6 | proc 7 | 8 | source.powershell 9 | 10 | -------------------------------------------------------------------------------- /Snippets/(sd) enable script debug stepping.sublime-snippet: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | sd 5 | source.powershell 6 | 7 | -------------------------------------------------------------------------------- /Snippets/(sub) $(...) complex subexpression.sublime-snippet: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | sub 6 | 7 | source.powershell 8 | 9 | -------------------------------------------------------------------------------- /Snippets/(thisdir) path to current script.sublime-snippet: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | thisdir 5 | source.powershell 6 | 7 | -------------------------------------------------------------------------------- /Snippets/(tmp) create temp file.sublime-snippet: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 6 | tmp 7 | 8 | source.powershell 9 | 10 | -------------------------------------------------------------------------------- /Snippets/(try) try {...}.sublime-snippet: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | try 7 | source.powershell 8 | 9 | -------------------------------------------------------------------------------- /Snippets/Powershell.sublime-completions: -------------------------------------------------------------------------------- 1 | { 2 | "scope": "source.powershell", 3 | 4 | "completions": [ 5 | { "trigger": "dict\thashtable", "contents": "@{$1$0}" }, 6 | { "trigger": "arr\tarray", "contents": "@($0)" }, 7 | { "trigger": "req\trequires", "contents": "#requires -$0" }, 8 | { "trigger": "reqp\trequires", "contents": "#requires -pssnapin $0" }, 9 | { "trigger": "reqv\trequires", "contents": "#requires -version ${0:2}" }, 10 | { "trigger": "void", "contents": "[void] ($1)$0" }, 11 | { "trigger": "sb", "contents": "\\${$1}$0" }, 12 | { "trigger": "wd\twrite-debug", "contents": "write-debug -message \"$1\"$0" }, 13 | { "trigger": "wh\twrite-host", "contents": "write-host \"$1\"" }, 14 | { "trigger": "ww\twrite-warning", "contents": "write-warning $0" }, 15 | { "trigger": "param", "contents": "param(\\$${1:paramName})" } 16 | ] 17 | } 18 | -------------------------------------------------------------------------------- /Snippets/env.sublime-snippet: -------------------------------------------------------------------------------- 1 | 2 | 3 | !env 4 | source.powershell 5 | #!/usr/bin/env 6 | 7 | -------------------------------------------------------------------------------- /Support/Comments.tmPreferences: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | name 6 | Comments 7 | scope 8 | source.powershell 9 | settings 10 | 11 | shellVariables 12 | 13 | 14 | name 15 | TM_COMMENT_START 16 | value 17 | # 18 | 19 | 20 | name 21 | TM_COMMENT_START_2 22 | value 23 | <# 24 | 25 | 26 | name 27 | TM_COMMENT_END_2 28 | value 29 | #> 30 | 31 | 32 | name 33 | TM_COMMENT_DISABLE_INDENT_2 34 | value 35 | yes 36 | 37 | 38 | 39 | uuid 40 | 06532840-4879-11df-9879-0800200c9a66 41 | 42 | 43 | -------------------------------------------------------------------------------- /Support/PowerShell.sublime-settings: -------------------------------------------------------------------------------- 1 | { 2 | "word_wrap": false, 3 | "translate_tabs_to_spaces": true, 4 | // Skip `-` in word separators 5 | "word_separators": "./\\()\"':,.;<>~!@#$%^&*|+=[]{}`~?", 6 | } 7 | -------------------------------------------------------------------------------- /Support/Powershell.sublime-build: -------------------------------------------------------------------------------- 1 | { 2 | "cmd": ["pwsh", "-noprofile", "-ExecutionPolicy", "Bypass", "-file", "$file"], 3 | "selector": "source.powershell", 4 | 5 | "windows": { 6 | "cmd": ["powershell.exe", "-noprofile", "-ExecutionPolicy", "Bypass", "-file", "$file"], 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /Tests/syntax_test_Class.ps1: -------------------------------------------------------------------------------- 1 | # SYNTAX TEST "Packages/PowerShell/PowerShell.sublime-syntax" 2 | using namespace system.management.automation 3 | # <- keyword.control.using 4 | # ^^^^^^^^^ keyword.other 5 | # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ variable.parameter 6 | 7 | # Define a class 8 | class TypeName 9 | # <- storage.type 10 | # ^^^^^^^^ entity.name.class 11 | # @@@@@@@@ definition 12 | { 13 | # Property with validate set 14 | # <- punctuation.definition.comment 15 | # ^^^^^^^^^^^^^^^^^^^^^^^^^^ comment.line 16 | [ValidateSet("val1", "Val2")] 17 | # ^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.attribute 18 | # <- punctuation.section.brackets.begin 19 | # ^^^^^^^^^^ support.function.attribute 20 | # ^ punctuation.section.group.begin 21 | # ^^^^^^ string.quoted.double 22 | # ^ punctuation.separator 23 | # ^^^^^^ string.quoted.double 24 | # ^ punctuation.section.group.end 25 | # ^ punctuation.section.brackets.end 26 | [string] $P1 27 | # <- punctuation.section.brackets.begin 28 | # ^^^^^ storage.type 29 | # ^ punctuation.section.brackets.end 30 | # ^ punctuation.definition.variable 31 | # ^^ variable.other.readwrite 32 | 33 | # Static property 34 | # <- punctuation.definition.comment 35 | # ^^^^^^^^^^^^^^^ comment.line 36 | static [hashtable] $P2 37 | #^^^^^ storage.modifier 38 | # ^ punctuation.section.brackets.begin 39 | # ^^^^^^^^^ storage.type 40 | # ^ punctuation.section.brackets.end 41 | # ^ punctuation.definition.variable 42 | # ^^ variable.other.readwrite 43 | 44 | # Hidden property does not show as result of Get-Member 45 | # <- punctuation.definition.comment 46 | # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ comment.line 47 | hidden [int] $P3 48 | #^^^^^ storage.modifier 49 | # ^ punctuation.section.brackets.begin 50 | # ^ storage.type 51 | # ^ punctuation.section.brackets.end 52 | # ^ punctuation.definition.variable 53 | # ^^ variable.other.readwrite 54 | 55 | # Constructor 56 | # <- punctuation.definition.comment 57 | # ^^^^^^^^^^^ comment.line 58 | TypeName ([string] $s) { 59 | # ^ punctuation.section.group.begin 60 | # ^ punctuation.section.brackets.begin 61 | # ^^^^^^ storage.type 62 | # ^ punctuation.section.brackets.end 63 | # ^ punctuation.definition.variable 64 | # ^ variable.other.readwrite 65 | # ^ punctuation.section.group.end 66 | $this.P1 = $s 67 | # <- punctuation.definition.variable 68 | # ^ variable.language 69 | # ^^ variable.other.member 70 | # ^ keyword.operator.assignment 71 | # ^ punctuation.definition.variable 72 | # ^ variable.other.readwrite 73 | } 74 | 75 | # Static method 76 | # <- punctuation.definition.comment 77 | # ^^^^^^^^^^^^^ comment.line 78 | static [void] MemberMethod1([hashtable] $h) { 79 | # <- storage.modifier 80 | # ^ punctuation.section.brackets.begin 81 | # ^^^^ storage.type 82 | # ^ punctuation.section.brackets.end 83 | # ^^^^^^^^^^^^^ entity.name.function 84 | # @@@@@@@@@@@@@ definition 85 | # ^ punctuation.section.group.begin 86 | # ^ punctuation.section.brackets.begin 87 | # ^^^^^^^^^ storage.type 88 | # ^ punctuation.section.brackets.end 89 | # ^ punctuation.definition.variable 90 | # ^ variable.other.readwrite 91 | # ^ punctuation.section.group.end 92 | [TypeName]::P2 = $h 93 | # <- punctuation.section.brackets.begin 94 | # ^ storage.type 95 | # ^ punctuation.section.brackets.end 96 | # ^^ punctuation.accessor.double-colon 97 | # ^^ variable.other.member 98 | # ^ keyword.operator.assignment 99 | # ^ punctuation.definition.variable 100 | # ^ variable.other.readwrite 101 | } 102 | 103 | # Instance method 104 | # <- punctuation.definition.comment 105 | # ^^^^^^^^^^^^^^^ comment.line 106 | [int] MemberMethod2([int] $i) { 107 | # <- punctuation.section.brackets.begin 108 | # ^ storage.type 109 | # ^ punctuation.section.brackets.end 110 | # ^^^^^^^^^^^^^ entity.name.function 111 | # @@@@@@@@@@@@@ definition 112 | # ^ punctuation.section.group.begin 113 | # ^ punctuation.section.brackets.begin 114 | # ^^^ storage.type 115 | # ^ punctuation.section.brackets.end 116 | # ^ punctuation.definition.variable 117 | # ^ variable.other.readwrite 118 | # ^ punctuation.section.group.end 119 | $this.P3 = $i 120 | # <- punctuation.definition.variable 121 | # ^^^ variable.language 122 | # ^^ variable.other.member 123 | # ^ keyword.operator.assignment 124 | # ^ punctuation.definition.variable 125 | # ^ variable.other.readwrite 126 | return $this.P3 127 | # <- keyword.control 128 | # ^ punctuation.definition.variable 129 | # ^^^^ variable.language 130 | # ^^ variable.other.member 131 | } 132 | } 133 | 134 | [TypeName]::MemberMethod1() 135 | # @@@@@@@@@@@@@ reference 136 | 137 | $object.MemberMethod2() 138 | # @@@@@@@@@@@@@ reference 139 | -------------------------------------------------------------------------------- /Tests/syntax_test_Function.ps1: -------------------------------------------------------------------------------- 1 | # SYNTAX TEST "Packages/PowerShell/PowerShell.sublime-syntax" 2 | 3 | using module Microsoft.Management 4 | # <- keyword.control.using 5 | # ^ keyword.other 6 | # ^ variable.parameter 7 | 8 | function Test-Path {} 9 | # @@@@@@@@@ definition 10 | <# 11 | # <- punctuation.definition.comment.block.begin 12 | .Synopsis 13 | # <- punctuation.definition.keyword 14 | # ^ keyword.other.documentation 15 | Short description 16 | .DESCRIPTION 17 | # <- punctuation.definition.keyword 18 | # ^ keyword.other.documentation 19 | Long description 20 | .EXAMPLE 21 | # <- punctuation.definition.keyword 22 | # ^ keyword.other.documentation 23 | Example of how to use this cmdlet 24 | .EXAMPLE 25 | # <- punctuation.definition.keyword 26 | # ^ keyword.other.documentation 27 | Another example of how to use this cmdlet 28 | .INPUTS 29 | # <- punctuation.definition.keyword 30 | # ^ keyword.other.documentation 31 | Inputs to this cmdlet (if any) 32 | .OUTPUTS 33 | # <- punctuation.definition.keyword 34 | # ^ keyword.other.documentation 35 | Output from this cmdlet (if any) 36 | .NOTES 37 | # <- punctuation.definition.keyword 38 | # ^ keyword.other.documentation 39 | General notes 40 | .COMPONENT 41 | # <- punctuation.definition.keyword 42 | # ^ keyword.other.documentation 43 | The component this cmdlet belongs to 44 | .ROLE 45 | # <- punctuation.definition.keyword 46 | # ^ keyword.other.documentation 47 | The role this cmdlet belongs to 48 | .FUNCTIONALITY 49 | # <- punctuation.definition.keyword 50 | # ^ keyword.other.documentation 51 | The functionality that best describes this cmdlet 52 | 53 | This should not be considered documentaton -> .role 54 | # ^ - keyword.operator.documentation 55 | #> 56 | # <- punctuation.definition.comment.block.end 57 | function Verb-Noun { 58 | #^^^^^^^^^^^^^^^^^ meta.function 59 | #^^^^^^^ storage.type 60 | # ^^^^^^^^^ entity.name.function 61 | # @@@@@@@@@ definition 62 | [CmdletBinding(DefaultParameterSetName = 'Parameter Set 1', 63 | # <- meta.attribute punctuation.section.brackets.begin 64 | # ^ meta.attribute support.function.attribute 65 | # ^ meta.attribute punctuation.section.group.begin 66 | # ^ meta.attribute variable.parameter.attribute 67 | # ^ meta.attribute keyword.operator.assignment 68 | # ^ meta.attribute string.quoted.single 69 | SupportsShouldProcess = $true, 70 | # ^^^^^^^^^^^^^^^^^^^^^ meta.attribute variable.parameter.attribute 71 | # ^ meta.attribute keyword.operator.assignment 72 | # ^ meta.attribute punctuation.definition.variable 73 | # ^^^^ meta.attribute constant.language 74 | PositionalBinding = $false, 75 | # ^^^^^^^^^^^^^^^^^ meta.attribute variable.parameter.attribute 76 | # ^ meta.attribute keyword.operator.assignment 77 | # ^ meta.attribute punctuation.definition.variable 78 | # ^^^^^ meta.attribute constant.language 79 | HelpUri = 'http://www.microsoft.com/', 80 | # ^^^^^^^ meta.attribute variable.parameter.attribute 81 | # ^ meta.attribute keyword.operator.assignment 82 | # ^ meta.attribute string.quoted.single 83 | ConfirmImpact = 'Medium')] 84 | # ^^^^^^^^^^^^^ meta.attribute variable.parameter.attribute 85 | # ^ meta.attribute keyword.operator.assignment 86 | # ^ meta.attribute string.quoted.single 87 | # ^ meta.attribute punctuation.section.group.end 88 | # ^ meta.attribute punctuation.section.brackets.end 89 | [Alias()] 90 | # <- meta.attribute punctuation.section.brackets.begin 91 | # ^ meta.attribute support.function.attribute 92 | # ^ meta.attribute punctuation.section.group.begin 93 | # ^ meta.attribute punctuation.section.group.end 94 | # ^ meta.attribute punctuation.section.brackets.end 95 | [OutputType([String])] 96 | # <- meta.attribute punctuation.section.brackets.begin 97 | # ^ meta.attribute support.function.attribute 98 | # ^ meta.attribute punctuation.section.group.begin 99 | # ^ meta.attribute punctuation.section.brackets.begin 100 | # ^^^^^^ meta.attribute storage.type 101 | # ^ meta.attribute punctuation.section.brackets.end 102 | # ^ meta.attribute punctuation.section.group.end 103 | # ^ meta.attribute punctuation.section.brackets.end 104 | Param 105 | #^^^^^ keyword.declaration.parameter 106 | ( 107 | # <- punctuation.section.group.begin 108 | # Param1 help description 109 | # <- comment.line punctuation.definition.comment 110 | # ^^^^^^^^^^^^^^^^^^^^^^^ comment.line 111 | [Parameter(Mandatory=$true, 112 | #^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.attribute 113 | # <- punctuation.section.brackets.begin 114 | # ^ support.function.attribute 115 | # ^ punctuation.section.group.begin 116 | # ^^^^^^^^^ variable.parameter.attribute 117 | # ^ keyword.operator.assignment 118 | # ^ punctuation.definition.variable 119 | # ^^^^ constant.language 120 | # ^ punctuation.separator 121 | ValueFromPipeline=$true, 122 | #^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.attribute.powershell 123 | # ^^^^^^^^^^^^^^^^^ variable.parameter.attribute 124 | # ^ keyword.operator.assignment 125 | # ^ punctuation.definition.variable 126 | # ^^^^ constant.language 127 | # ^ punctuation.separator 128 | ValueFromPipelineByPropertyName = $true, 129 | #^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.attribute 130 | # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ variable.parameter.attribute 131 | # ^ keyword.operator.assignment 132 | # ^ punctuation.definition.variable 133 | # ^^^^^ constant.language 134 | # ^ punctuation.separator 135 | ValueFromRemainingArguments=$false, 136 | #^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.attribute 137 | # ^^^^^^^^^^^^^^^^^^^^^^^^^^^ variable.parameter.attribute 138 | # ^ keyword.operator.assignment 139 | # ^ punctuation.definition.variable 140 | # ^^^^^ constant.language 141 | # ^ punctuation.separator 142 | Position=0, 143 | #^^^^^^^^^^^^^^^^^^^^^^ meta.attribute 144 | # ^^^^^^^^ variable.parameter.attribute 145 | # ^ keyword.operator.assignment 146 | # ^ constant.numeric.value 147 | # ^ punctuation.separator 148 | ParameterSetName = 'Parameter Set 1')] 149 | #^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.attribute 150 | # ^^^^^^^^^^^^^^^^ variable.parameter.attribute 151 | # ^ keyword.operator.assignment 152 | # ^^^^^^^^^^^^^^^^^ string.quoted.single 153 | # ^ punctuation.section.group.end 154 | # ^ punctuation.section.brackets.end 155 | # ^ - meta.attribute 156 | [ValidateNotNullOrEmpty()] 157 | #^^^^^^^^^^^^^^^^^^^^^^^^^ meta.attribute 158 | # <- punctuation.section.brackets.begin 159 | # ^^^^^^^^^^^^^^^^^^^^^ support.function.attribute 160 | # ^ punctuation.section.group.begin 161 | # ^ punctuation.section.group.end 162 | # ^ punctuation.section.brackets.end 163 | [ValidateNotNull()] 164 | #^^^^^^^^^^^^^^^^^^ meta.attribute 165 | # <- punctuation.section.brackets.begin 166 | # ^^^^^^^^^^^^^^ support.function.attribute 167 | # ^ punctuation.section.group.begin 168 | # ^ punctuation.section.group.end 169 | # ^ punctuation.section.brackets.end 170 | [ValidateNotNullOrEmpty()] 171 | #^^^^^^^^^^^^^^^^^^^^^^^^^ meta.attribute 172 | # <- punctuation.section.brackets.begin 173 | # ^^^^^^^^^^^^^^^^^^^^^ support.function.attribute 174 | # ^ punctuation.section.group.begin 175 | # ^ punctuation.section.group.end 176 | # ^ punctuation.section.brackets.end 177 | [ValidateCount(0,5)] 178 | #^^^^^^^^^^^^^^^^^^^ meta.attribute 179 | # <- punctuation.section.brackets.begin 180 | # ^^^^^^^^^^^^ support.function.attribute 181 | # ^ punctuation.section.group.begin 182 | # ^ constant.numeric.value 183 | # ^ punctuation.separator 184 | # ^ constant.numeric.value 185 | # ^ punctuation.section.group.end 186 | # ^ punctuation.section.brackets.end 187 | [ValidateSet("sun", "moon", "earth")] 188 | #^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.attribute 189 | # <- punctuation.section.brackets.begin 190 | # ^ support.function.attribute 191 | # ^ punctuation.section.group.begin 192 | # ^^^^ string.quoted.double 193 | # ^ punctuation.separator 194 | # ^^^^^^ string.quoted.double 195 | # ^ punctuation.separator 196 | # ^^^^^^^ string.quoted.double 197 | # ^ punctuation.section.group.end 198 | # ^ punctuation.section.brackets.end 199 | [Alias("p1")] 200 | #^^^^^^^^^^^^ meta.attribute 201 | # <- punctuation.section.brackets.begin 202 | # ^ support.function.attribute 203 | # ^ punctuation.section.group.begin 204 | # ^^^^ string.quoted.double 205 | # ^ punctuation.section.group.end 206 | # ^ punctuation.section.brackets.end 207 | $Param1, 208 | # <- punctuation.definition.variable 209 | # ^ variable.other.readwrite 210 | # ^ punctuation.separator 211 | 212 | # Param2 help description 213 | # <- comment.line punctuation.definition.comment 214 | # ^^^^^^^^^^^^^^^^^^^^^^^ comment.line 215 | [Parameter(ParameterSetName='Parameter Set 1')] 216 | #^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.attribute 217 | # ^^^^^^^^ support.function.attribute 218 | # ^^^^^^^^^^^^^^^^ variable.parameter.attribute 219 | # ^ keyword.operator.assignment 220 | # ^^^^^^^^^^^^^^^^ string.quoted.single 221 | # ^ punctuation.section.group.end 222 | # ^ punctuation.section.brackets.end 223 | # ^ - meta.attribute 224 | [AllowNull()] 225 | #^^^^^^^^^^^^ meta.attribute 226 | # <- meta.attribute punctuation.section.brackets.begin 227 | # ^ meta.attribute support.function.attribute 228 | # ^ meta.attribute punctuation.section.group.begin 229 | # ^ meta.attribute punctuation.section.group.end 230 | # ^ meta.attribute punctuation.section.brackets.end 231 | [AllowEmptyCollection()] 232 | #^^^^^^^^^^^^^^^^^^^^^^^ meta.attribute 233 | # <- meta.attribute punctuation.section.brackets.begin 234 | # ^ meta.attribute support.function.attribute 235 | # ^ meta.attribute punctuation.section.group.begin 236 | # ^ meta.attribute punctuation.section.group.end 237 | # ^ meta.attribute punctuation.section.brackets.end 238 | [AllowEmptyString()] 239 | #^^^^^^^^^^^^^^^^^^^ meta.attribute 240 | # <- meta.attribute punctuation.section.brackets.begin 241 | # ^ meta.attribute support.function.attribute 242 | # ^ meta.attribute punctuation.section.group.begin 243 | # ^ meta.attribute punctuation.section.group.end 244 | # ^ meta.attribute punctuation.section.brackets.end 245 | [ValidateScript({$true})] 246 | #^^^^^^^^^^^^^^^^^^^^^^^^ meta.attribute 247 | # <- meta.attribute punctuation.section.brackets.begin 248 | # ^^^^^^^^^^^^^ support.function.attribute 249 | # ^ punctuation.section.group.begin 250 | # ^ meta.attribute 251 | # ^ punctuation.definition.variable 252 | # ^^^^ constant.language 253 | # ^ meta.attribute 254 | # ^ punctuation.section.group.end 255 | # ^ punctuation.section.brackets.end 256 | [ValidateRange(0,5)] 257 | #^^^^^^^^^^^^^^^^^^^ meta.attribute 258 | # <- meta.attribute punctuation.section.brackets.begin 259 | # ^^^^^^^^^^^^ support.function.attribute 260 | # ^ punctuation.section.group.begin 261 | # ^ constant.numeric.value 262 | # ^ punctuation.separator 263 | # ^ constant.numeric.value 264 | # ^ punctuation.section.group.end 265 | # ^ punctuation.section.brackets.end 266 | [int32] 267 | # <- punctuation.section.brackets.begin 268 | #^^^^^ storage.type 269 | # ^ punctuation.section.brackets.end 270 | $Param2, 271 | # <- punctuation.definition.variable 272 | # ^ variable.other.readwrite 273 | # ^ punctuation.separator 274 | 275 | # Param3 help description 276 | # <- comment.line punctuation.definition.comment 277 | # ^^^^^^^^^^^^^^^^^^^^^^^ comment.line 278 | [Parameter(ParameterSetName='Another Parameter Set')] 279 | #^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.attribute 280 | # <- meta.attribute punctuation.section.brackets.begin 281 | # ^ meta.attribute support.function.attribute 282 | # ^ meta.attribute punctuation.section.group.begin 283 | # ^^^^^^^^^^^^^^^^ meta.attribute variable.parameter.attribute 284 | # ^ meta.attribute keyword.operator.assignment 285 | # ^^^^^^^^^^^^^^^^^^^^^^^ meta.attribute string.quoted.single 286 | # ^ meta.attribute punctuation.section.group.end 287 | # ^ meta.attribute punctuation.section.brackets.end 288 | [ValidatePattern("[a-z]*")] 289 | # <- meta.attribute punctuation.section.brackets.begin 290 | # ^ meta.attribute support.function.attribute 291 | # ^ meta.attribute punctuation.section.group.begin 292 | # ^^^^^^^^ meta.attribute string.quoted.double 293 | # ^ meta.attribute punctuation.section.group.end 294 | # ^ meta.attribute punctuation.section.brackets.end 295 | [ValidateLength(0,15)] 296 | # <- meta.attribute punctuation.section.brackets.begin 297 | # ^ meta.attribute support.function.attribute 298 | # ^ meta.attribute punctuation.section.group.begin 299 | # ^ meta.attribute meta.number.integer.decimal constant.numeric.value 300 | # ^ punctuation.separator 301 | # ^^ meta.attribute meta.number.integer.decimal constant.numeric.value 302 | # ^ meta.attribute punctuation.section.group.end 303 | # ^ meta.attribute punctuation.section.brackets.end 304 | [String] 305 | # <- punctuation.section.brackets.begin 306 | #^^^^^^ storage.type 307 | # ^ punctuation.section.brackets.end 308 | $Param3, 309 | # <- punctuation.definition.variable 310 | #^^^^^^ variable.other.readwrite 311 | # ^ punctuation.separator 312 | 313 | # Param4 help description 314 | # <- comment.line punctuation.definition.comment 315 | # ^^^^^^^^^^^^^^^^^^^^^^^ comment.line 316 | [Parameter(ParameterSetName='Parameter Set 1')] 317 | # <- meta.attribute punctuation.section.brackets.begin 318 | # ^ meta.attribute support.function.attribute 319 | # ^ meta.attribute punctuation.section.group.begin 320 | # ^^^^^^^^^^^^^^^^ meta.attribute variable.parameter.attribute 321 | # ^ meta.attribute keyword.operator.assignment 322 | # ^^^^^^^^^^^^^^^^^ meta.attribute string.quoted.single 323 | # ^ meta.attribute punctuation.section.group.end 324 | # ^ meta.attribute punctuation.section.brackets.end 325 | [ValidateScript({Test-Path $_})] #Make sure cmdlets don't break highlighting 326 | # @@@@@@@@@ reference 327 | # <- meta.attribute punctuation.section.brackets.begin 328 | # ^ meta.attribute support.function.attribute 329 | # ^ meta.attribute punctuation.section.group.begin 330 | # ^ meta.attribute meta.block 331 | # ^^^^^^^^^ meta.block support.function 332 | # ^ meta.block punctuation.definition.variable 333 | # ^ meta.block variable.language 334 | # ^ meta.attribute meta.block 335 | # ^ meta.attribute punctuation.section.group.end 336 | # ^ meta.attribute punctuation.section.brackets.end 337 | [string] 338 | # <- punctuation.section.brackets.begin 339 | # ^ storage.type 340 | # ^ punctuation.section.brackets.end 341 | $Param4, 342 | # <- punctuation.definition.variable 343 | # ^ variable.other.readwrite 344 | # ^ punctuation.separator 345 | 346 | # Param5 help description 347 | # <- comment.line punctuation.definition.comment 348 | # ^^^^^^^^^^^^^^^^^^^^^^^ comment.line 349 | [Parameter(ParameterSetName='Parameter Set 1')] 350 | # <- meta.attribute punctuation.section.brackets.begin 351 | # ^ meta.attribute support.function.attribute 352 | # ^ meta.attribute punctuation.section.group.begin 353 | # ^^^^^^^^^^^^^^^^ meta.attribute variable.parameter.attribute 354 | # ^ meta.attribute keyword.operator.assignment 355 | # ^^^^^^^^^^^^^^^^^ meta.attribute string.quoted.single 356 | # ^ meta.attribute punctuation.section.group.end 357 | # ^ meta.attribute punctuation.section.brackets.end 358 | [ValidatePattern('(?=^.{1,254}$)(^(?:(?!\d+\.)[a-zA-Z0-9_\-]{1,63}\.?)+(?:[a-zA-Z]{2,})$)')] # this regex shouldn't break highlighting 359 | # <- meta.attribute punctuation.section.brackets.begin 360 | # ^ meta.attribute support.function.attribute 361 | # ^ meta.attribute punctuation.section.group.begin 362 | # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.attribute string.quoted.single 363 | # ^ meta.attribute punctuation.section.group.end 364 | # ^ meta.attribute punctuation.section.brackets.end 365 | # ^ comment.line punctuation.definition.comment 366 | # ^ comment.line 367 | [string] 368 | # <- punctuation.section.brackets.begin 369 | # ^ storage.type 370 | # ^ punctuation.section.brackets.end 371 | $Param5 372 | # <- punctuation.definition.variable 373 | # ^ variable.other.readwrite 374 | ) 375 | # <- punctuation.section.group.end 376 | 377 | Begin 378 | #^^^^^ keyword.context.block.begin 379 | { 380 | } 381 | Process { 382 | # <- keyword.context.block.process 383 | if ($pscmdlet.ShouldProcess("Target", "Operation")) { 384 | # <- keyword.control 385 | # ^ punctuation.section.group.begin 386 | # ^ punctuation.definition.variable 387 | # ^^^^^^^^ variable.language 388 | # ^^^^^^^^^^^^^ variable.function 389 | # @@@@@@@@@@@@@ reference 390 | # ^ punctuation.section.arguments.begin 391 | # ^^^^^^^^ string.quoted.double 392 | # ^ punctuation.separator 393 | # ^^^^^^^^^^^ string.quoted.double 394 | # ^ punctuation.section.arguments.end 395 | # ^ punctuation.section.group.end 396 | } 397 | } 398 | End { 399 | #^^^ keyword.context.block.end 400 | 401 | } 402 | } 403 | -------------------------------------------------------------------------------- /Tests/syntax_test_PowerShell.ps1: -------------------------------------------------------------------------------- 1 | # SYNTAX TEST "Packages/PowerShell/PowerShell.sublime-syntax" 2 | using namespace System.Management.Automation 3 | # <- keyword.control.using 4 | # ^ keyword.other 5 | # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ variable.parameter 6 | #Requires -PSSnapin DiskSnapin -Version 1.2 7 | # <- punctuation.definition.keyword 8 | #^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.requires 9 | #^^^^^^^^ keyword.control.import.require 10 | # ^^^^^^^^^ variable.parameter 11 | # ^^^^^^^^ variable.parameter 12 | #Requires -PSSnapin DiskSnapin 13 | # <- punctuation.definition.keyword 14 | #^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.requires 15 | #^^^^^^^^ keyword.control.import.require 16 | # ^^^^^^^^^ variable.parameter 17 | #Requires -Version 3 18 | # <- punctuation.definition.keyword 19 | #^^^^^^^^^^^^^^^^^^^ meta.requires 20 | #^^^^^^^^ keyword.control.import.require 21 | # ^^^^^^^^ variable.parameter 22 | #Requires -Version 3.0 23 | # <- punctuation.definition.keyword 24 | #^^^^^^^^^^^^^^^^^^^^^ meta.requires 25 | #^^^^^^^^ keyword.control.import.require 26 | # ^^^^^^^^ variable.parameter 27 | #Requires -Version 3 -RunAsAdministrator 28 | # <- punctuation.definition.keyword 29 | #^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.requires 30 | #^^^^^^^^ keyword.control.import.require 31 | # ^^^^^^^^ variable.parameter 32 | # ^^^^^^^^^^^^^^^^^^^ variable.parameter 33 | #Requires -RunAsAdministrator 34 | # <- punctuation.definition.keyword 35 | #^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.requires 36 | #^^^^^^^^ keyword.control.import.require 37 | # ^^^^^^^^^ variable.parameter 38 | #Requires -Modules PSWorkflow 39 | # <- punctuation.definition.keyword 40 | #^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.requires 41 | #^^^^^^^^ keyword.control.import.require 42 | # ^^^^^^^^ variable.parameter 43 | #Requires -Modules PSWorkflow -ThisIsInvalid 44 | # <- punctuation.definition.keyword 45 | #^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.requires 46 | #^^^^^^^^ keyword.control.import.require 47 | # ^^^^^^^^ variable.parameter 48 | # ^^^^^^^^ - variable.parameter 49 | #Requires -Modules PSWorkflow, ActiveDirectory 50 | # <- punctuation.definition.keyword 51 | #^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.requires 52 | #^^^^^^^^ keyword.control.import.require 53 | # ^^^^^^^^ variable.parameter 54 | # ^ punctuation.separator 55 | #Requires -Modules PSWorkflow,ActiveDirectory 56 | # <- punctuation.definition.keyword 57 | #^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.requires 58 | #^^^^^^^^ keyword.control.import.require 59 | # ^^^^^^^^ variable.parameter 60 | # ^ punctuation.separator 61 | #Requires -ShellId MyLocalShell 62 | # <- punctuation.definition.keyword 63 | #^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.requires 64 | #^^^^^^^^ keyword.control.import.require 65 | # ^^^^^^^^ variable.parameter 66 | #Requires -Modules PSWorkflow, @{ModuleName="PSScheduledJob"; ModuleVersion="1.0.0.0"} 67 | # <- punctuation.definition.keyword 68 | #^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.requires 69 | #^^^^^^^^ keyword.control.import.require 70 | # ^^^^^^^^ variable.parameter 71 | # ^ punctuation.separator 72 | # ^^^^^^^^^^ meta.requires meta.hashtable variable.other.readwrite 73 | # ^ meta.requires meta.hashtable 74 | # ^^^^^^^^^^^^^^^^ meta.requires meta.hashtable string.quoted.double 75 | # ^ meta.requires meta.hashtable punctuation.terminator.statement 76 | # ^^^^^^^^^^^^^ meta.requires meta.hashtable variable.other.readwrite 77 | # ^ meta.requires meta.hashtable 78 | # ^^^^^^^^^ meta.requires meta.hashtable string.quoted.double 79 | 80 | throw "Do not run this file!" 81 | # <- keyword.control 82 | # ^^^^^^^^^^^^^^^^^^^^^^^ string.quoted.double 83 | 84 | # Stop parsing 85 | & tool.exe /arg1 'value' /arg2 $value --% /arg3 $value /arg4 "value" # Comment 86 | # <- keyword.operator.other 87 | # ^^^^^^^^ variable.function 88 | # ^ punctuation.definition.parameter 89 | # ^^^^^ variable.parameter.option 90 | # ^ punctuation.definition.parameter 91 | # ^^^^^ variable.parameter.option 92 | # ^^^ keyword.control 93 | # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ string.unquoted - constant - variable - comment 94 | 95 | & gnutool.exe -s 'short option' --long-option --very_long_option value +plus-option 96 | #<- keyword.operator.other 97 | # ^^^^^^^^^^^ variable.function 98 | # ^ variable.parameter.option punctuation.definition.parameter 99 | # ^ variable.parameter.option 100 | # ^^ variable.parameter.option punctuation.definition.parameter 101 | # ^^ variable.parameter.option punctuation.definition.parameter 102 | # ^^^^^^^^^^^^^^^^ variable.parameter.option 103 | # ^ variable.parameter.option punctuation.definition.parameter 104 | # ^^^^^^^^^^^ variable.parameter.option 105 | 106 | # Automatic variables 107 | $_, $$, $^, $? 108 | # <- punctuation.definition.variable 109 | #^ variable.language 110 | # ^ punctuation.definition.variable 111 | # ^^ variable.language 112 | # ^ punctuation.definition.variable 113 | # ^^ variable.language 114 | # ^ punctuation.definition.variable 115 | # ^^ variable.language 116 | $args 117 | # <- punctuation.definition.variable 118 | #^^^^ variable.language 119 | $error 120 | # <- punctuation.definition.variable 121 | # ^^^^ variable.language 122 | $home 123 | # <- punctuation.definition.variable 124 | # ^^^ support.constant.variable 125 | $foreach 126 | # <- punctuation.definition.variable 127 | #^^^^^^^ variable.language 128 | 129 | # Normal variables 130 | $variable 131 | # <- punctuation.definition.variable 132 | # ^ variable.other.readwrite 133 | $script:variable 134 | # <- variable.other.readwrite punctuation.definition.variable 135 | # ^ storage.modifier.scope 136 | # ^ variable.other.readwrite 137 | $ENV:ComputerName 138 | # <- variable.other.readwrite punctuation.definition.variable 139 | # ^ support.variable.drive 140 | # ^ variable.other.readwrite 141 | ${variable} 142 | # <- variable.other.readwrite punctuation.definition.variable 143 | # <- punctuation.section.braces.begin 144 | # ^^^^^^^^ variable.other.readwrite 145 | # ^ punctuation.section.braces.end 146 | ${script:variable} 147 | # <- variable.other.readwrite punctuation.definition.variable 148 | # <- punctuation.section.braces.begin 149 | # ^ storage.modifier.scope 150 | # ^ variable.other.readwrite 151 | # ^ punctuation.section.braces.end 152 | 153 | # Variable properties should be highlighted 154 | $variable.Name 155 | # <- variable.other.readwrite punctuation.definition.variable 156 | #^^^^^^^^ variable.other.readwrite 157 | # ^ punctuation.accessor.dot 158 | # ^^^^^ - variable.other.readwrite 159 | # ^^^^ variable.other.member 160 | 161 | # Variable properties should be highlighted 162 | $variable.Name.Method( ) 163 | # <- variable.other.readwrite punctuation.definition.variable 164 | #^^^^^^^^ variable.other.readwrite 165 | # ^ punctuation.accessor.dot 166 | # ^^^^ variable.other.member 167 | # ^ punctuation.accessor.dot 168 | # ^^^^^^ meta.function-call variable.function 169 | # @@@@@@ reference 170 | # ^^^ meta.function-call.arguments 171 | # ^^^^^^^^^^^^^^^ - variable.other.readwrite 172 | # ^ - meta.function-call 173 | 174 | # In double-quoted strings, only the variable should be highlighted, not the property 175 | "This is my $variable.Name!" 176 | # <- punctuation.definition.string.begin 177 | #^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.string 178 | #^^^^^^^^^^^ string.quoted.double 179 | # ^^^^^^^^^ meta.interpolation variable.other.readwrite - string 180 | # ^ punctuation.definition.variable 181 | # ^^^^^^ string.quoted.double - meta.interpolation - variable - punctuation 182 | # ^ punctuation.definition.string.end 183 | 184 | # When used in a subexpression, both should be highlighted 185 | "This is my $($variable.Name)!" 186 | # <- punctuation.definition.string.begin 187 | #^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.string 188 | #^^^^^^^^^^^ string.quoted.double 189 | # ^^^^^^^^^^^^^^^^^ meta.interpolation - string 190 | # ^^ string.quoted.double - meta.interpolation 191 | # ^^ punctuation.section.interpolation.begin 192 | # ^^^^^^^^^ variable.other.readwrite 193 | # ^ punctuation.definition.variable 194 | # ^ punctuation.accessor.dot 195 | # ^^^^ variable.other.member 196 | # ^ punctuation.section.interpolation.end 197 | # ^ punctuation.definition.string.end 198 | 199 | # $ENV:ComputerName should be highlighted 200 | "This is the name of my computer: $ENV:ComputerName" 201 | # <- punctuation.definition.string.begin 202 | #^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.string 203 | #^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ string.quoted.double 204 | # ^^^^^^^^^^^^^^^^^ meta.interpolation - string 205 | # ^ punctuation.definition.variable 206 | # ^^^^ support.variable.drive 207 | # ^^^^^^^^^^^^ variable.other.readwrite 208 | # ^ punctuation.definition.string.end 209 | 210 | # Here as well 211 | "This is the name of my computer: ${ENV:ComputerName}" 212 | # <- punctuation.definition.string.begin 213 | #^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.string 214 | #^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ string.quoted.double 215 | # ^^^^^^^^^^^^^^^^^^^ meta.interpolation - string 216 | # ^ punctuation.definition.variable 217 | # ^ punctuation.section.braces.begin 218 | # ^^^^ support.variable.drive 219 | # ^^^^^^^^^^^^ variable.other.readwrite 220 | # ^ punctuation.definition.string.end 221 | 222 | # The @splat references only work in argument mode, should not highlight in strings 223 | "This is a @double quoted string." 224 | # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.string string.quoted.double 225 | # ^ - punctuation.definition.variable 226 | # ^^^^^^^ - variable 227 | 228 | # double check scopes for automatic variables in strings 229 | "$_ $$ $Pwd" 230 | #^^ variable.language 231 | # ^^ variable.language 232 | # ^^^^ variable.language 233 | 234 | # Single quotes string 235 | 'This is a string' 236 | # <- punctuation.definition.string.begin 237 | #^^^^^^^^^^^^^^^^^ meta.string string.quoted.single 238 | # ^ punctuation.definition.string.end 239 | 240 | # Hashtable 241 | $properties = @{ 242 | # <- punctuation.definition.variable 243 | # ^ variable.other.readwrite 244 | # ^ keyword.operator.assignment 245 | # ^ keyword.other.hashtable.begin 246 | # ^ punctuation.section.braces.begin 247 | Name = 'Name' 248 | # <- meta.hashtable meta.hashtable.assignment variable.other.readwrite 249 | # ^ meta.hashtable meta.hashtable.assignment keyword.operator.assignment 250 | # ^ meta.hashtable string.quoted.single 251 | Something = $else 252 | # <- meta.hashtable meta.hashtable.assignment variable.other.readwrite 253 | # Atom-grammar-test is not tokenizing this correctly... Need to test in Atom - TODO 254 | Number = 16 255 | # <- meta.hashtable meta.hashtable.assignment variable.other.readwrite 256 | # ^ meta.hashtable meta.hashtable.assignment keyword.operator.assignment 257 | # ^^ meta.hashtable meta.number.integer.decimal constant.numeric.value 258 | from = 'hello world' 259 | # <- meta.hashtable meta.hashtable.assignment variable.other.readwrite 260 | # ^ meta.hashtable meta.hashtable.assignment keyword.operator.assignment 261 | # ^^^^^^^^^^^^^ meta.hashtable string.quoted.single 262 | hash = @{ 263 | # <- meta.hashtable meta.hashtable.assignment variable.other.readwrite 264 | # ^ meta.hashtable meta.hashtable.assignment keyword.operator.assignment 265 | # ^ keyword.other.hashtable.begin 266 | # ^ punctuation.section.braces.begin 267 | hello = 'world' 268 | # <- meta.hashtable meta.hashtable.assignment variable.other.readwrite 269 | # ^ meta.hashtable meta.hashtable.assignment keyword.operator.assignment 270 | # ^^^^^^^ meta.hashtable string.quoted.single 271 | } 272 | # <- punctuation.section.braces.end 273 | } 274 | # <- punctuation.section.braces.end 275 | 276 | function Invoke-Something {} 277 | # @@@@@@@@@@@@@@@@ definition 278 | 279 | # Spatting 280 | Invoke-Something @properties 281 | # ^^^^^^^^^^^^^^^^ support.function 282 | # @@@@@@@@@@@@@@@@ reference 283 | # ^ punctuation.definition.variable 284 | # ^ variable.other.readwrite 285 | 286 | # ScriptBlock 287 | {Invoke-Something @properties} 288 | # ^ punctuation.section.braces.begin 289 | # ^^^^^^^^^^^^^^^^ support.function 290 | # @@@@@@@@@@@@@@@@ reference 291 | # ^ punctuation.definition.variable 292 | # ^ variable.other.readwrite 293 | # ^ punctuation.section.braces.end 294 | { 295 | # <- punctuation.section.braces.begin 296 | Invoke-Something @properties 297 | # ^^^^^^^^^^^^^^^^ support.function 298 | # @@@@@@@@@@@@@@@@ reference 299 | # ^ punctuation.definition.variable 300 | # ^ variable.other.readwrite 301 | } 302 | # <- punctuation.section.braces.end 303 | $sb = { 304 | # <- punctuation.definition.variable 305 | # ^ variable.other.readwrite 306 | # ^ keyword.operator.assignment 307 | # ^ punctuation.section.braces.begin 308 | Invoke-Something @properties 309 | # ^^^^^^^^^^^^^^^^ support.function 310 | # @@@@@@@@@@@@@@@@ reference 311 | # ^ punctuation.definition.variable 312 | # ^ variable.other.readwrite 313 | } 314 | # <- punctuation.section.braces.end 315 | 316 | # Arrays 317 | $a1 = @(1,2,3,4) 318 | # <- variable.other.readwrite punctuation.definition.variable 319 | #^^ variable.other.readwrite 320 | # ^ keyword.operator.assignment 321 | # ^ keyword.other.array.begin 322 | # ^ punctuation.section.group.begin 323 | # ^ punctuation.section.group.end 324 | # ^^^^^^^ meta.group.array-expression 325 | # ^ meta.number.integer.decimal constant.numeric.value 326 | # ^ punctuation.separator.sequence 327 | # ^ meta.number.integer.decimal constant.numeric.value 328 | # ^ punctuation.separator.sequence 329 | # ^ meta.number.integer.decimal constant.numeric.value 330 | # ^ punctuation.separator.sequence 331 | # ^ meta.number.integer.decimal constant.numeric.value 332 | $a2 = ('one','two','three','four') 333 | # <- variable.other.readwrite punctuation.definition.variable 334 | #^^ variable.other.readwrite 335 | # ^ keyword.operator.assignment 336 | # ^ punctuation.section.group.begin 337 | # ^^^^^ string.quoted.single 338 | # ^ punctuation.separator.sequence 339 | # ^^^^^ string.quoted.single 340 | # ^ punctuation.separator.sequence 341 | # ^^^^^^^ string.quoted.single 342 | # ^ punctuation.separator.sequence 343 | # ^^^^^^ string.quoted.single 344 | # ^ punctuation.section.group.end 345 | $a3 = $one, $two, $three, $four 346 | # <- variable.other.readwrite punctuation.definition.variable 347 | #^^ variable.other.readwrite 348 | # ^ punctuation.definition.variable 349 | # ^^^^ variable.other.readwrite 350 | # ^ punctuation.definition.variable 351 | # ^^^^ variable.other.readwrite 352 | # ^ punctuation.definition.variable 353 | # ^^^^^^ variable.other.readwrite 354 | # ^ punctuation.definition.variable 355 | # ^^^^^ variable.other.readwrite 356 | # ^ keyword.operator.assignment 357 | # ^ punctuation.separator 358 | # ^ punctuation.separator 359 | # ^ punctuation.separator 360 | $a1[0] 361 | # <- variable.other.readwrite punctuation.definition.variable 362 | # ^ variable.other.readwrite 363 | # ^ punctuation.section.brackets.begin 364 | # ^ meta.number.integer.decimal constant.numeric.value 365 | # ^ punctuation.section.brackets.end 366 | # ^^^ meta.brackets.indexer 367 | $a2[-1] 368 | # <- variable.other.readwrite punctuation.definition.variable 369 | # ^ variable.other.readwrite 370 | # ^ punctuation.section.brackets.begin 371 | # ^ meta.number.integer.decimal constant.numeric.value 372 | # ^ punctuation.section.brackets.end 373 | # ^^^^ meta.brackets.indexer 374 | $a3[1..2] 375 | # <- variable.other.readwrite punctuation.definition.variable 376 | # ^ variable.other.readwrite 377 | # ^ punctuation.section.brackets.begin 378 | # ^ meta.number.integer.decimal constant.numeric.value 379 | # ^^ keyword.operator.range 380 | # ^ meta.number.integer.decimal constant.numeric.value 381 | # ^ punctuation.section.brackets.end 382 | # ^^^^^^ meta.brackets.indexer 383 | @(@($a)) 384 | # ^ keyword.other.array.begin 385 | # ^ punctuation.section.group.begin 386 | # ^ keyword.other.array.begin 387 | # ^ punctuation.section.group.begin 388 | # ^ variable.other.readwrite punctuation.definition.variable 389 | # ^^ variable.other.readwrite 390 | # ^^ punctuation.section.group.end 391 | @(($i = 10); (++$j)) 392 | # ^ keyword.other.array.begin 393 | # ^^ punctuation.section.group.begin 394 | # ^ variable.other.readwrite punctuation.definition.variable 395 | # ^^ variable.other.readwrite 396 | # ^ keyword.operator.assignment 397 | # ^^ meta.number.integer.decimal constant.numeric.value 398 | # ^ punctuation.section.group.end 399 | # ^ punctuation.terminator.statement 400 | # ^ punctuation.section.group.begin 401 | # ^^ keyword.operator.assignment 402 | # ^ variable.other.readwrite punctuation.definition.variable 403 | # ^ variable.other.readwrite 404 | # ^^ punctuation.section.group.end 405 | @($i = 10) 406 | # ^ keyword.other.array.begin 407 | # ^ punctuation.section.group.begin 408 | # ^ variable.other.readwrite punctuation.definition.variable 409 | # ^^ variable.other.readwrite 410 | # ^ keyword.operator.assignment 411 | # ^^ meta.number.integer.decimal constant.numeric.value 412 | # ^ punctuation.section.group.end 413 | $i[($y - 1) + $x] 414 | # ^ variable.other.readwrite punctuation.definition.variable 415 | # ^^ variable.other.readwrite 416 | # ^ punctuation.section.brackets.begin 417 | # ^ punctuation.section.group.begin 418 | # ^ variable.other.readwrite punctuation.definition.variable 419 | # ^^ variable.other.readwrite 420 | # ^ keyword.operator.arithmetic 421 | # ^ meta.number.integer.decimal constant.numeric.value 422 | # ^ punctuation.section.group.end 423 | # ^ keyword.operator.arithmetic 424 | # ^ variable.other.readwrite punctuation.definition.variable 425 | # ^^ variable.other.readwrite 426 | # ^ punctuation.section.brackets.end 427 | # ^^^^^^^^^^^^^^^ meta.brackets.indexer 428 | 429 | # Single quoted strings 430 | 'This is a single quoted string.' 431 | # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.string string.quoted.single 432 | '$This is a single ''quoted'' string.' 433 | # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.string string.quoted.single 434 | # ^^ constant.character.escape 435 | # ^^ constant.character.escape 436 | 'This is a 437 | single quoted string.' 438 | # ^^^^^^^^^^^^^^^^^^^^^^ meta.string string.quoted.single 439 | 'This #also' 440 | # ^^^^^^^^^^^^ meta.string string.quoted.single 441 | '$(Invoke-Something)' 442 | # ^^^^^^^^^^^^^^^^^^^^^ meta.string string.quoted.single - meta.interpolation - variable - support 443 | 'This "string" is nice.' 444 | # ^^^^^^^^^^^^^^^^^^^^^^^^ meta.string string.quoted.single 445 | 446 | # Double quoted strings 447 | "This is a double quoted string." 448 | # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.string string.quoted.double 449 | "$This is a double ""quoted"" string." 450 | # ^ meta.string string.quoted.double 451 | # ^^^^^ meta.string meta.interpolation variable.language - string 452 | # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.string string.quoted.double - meta.interpolation 453 | # ^^ constant.character.escape 454 | # ^^ constant.character.escape 455 | "This is a 456 | double quoted string." 457 | # ^^^^^^^^^^^^^^^^^^^^^^ meta.string string.quoted.double 458 | "This #also" 459 | # ^^^^^^^^^^^^ meta.string string.quoted.double 460 | "$(Invoke-Something)" 461 | # ^ meta.string string.quoted.double 462 | # ^^^^^^^^^^^^^^^^^^^ meta.string meta.interpolation - string 463 | # ^^ punctuation.section.interpolation.begin 464 | # ^^^^^^^^^^^^^^^^ support.function 465 | # ^ punctuation.section.interpolation.end 466 | # @@@@@@@@@@@@@@@@ reference 467 | "This 'string' is nice." 468 | # ^^^^^^^^^^^^^^^^^^^^^^^^ meta.string string.quoted.double 469 | 470 | # Double quoted here-string 471 | @" 472 | # <- string.quoted.double.heredoc 473 | # <- string.quoted.double.heredoc 474 | $This is a 'double quoted' 475 | # <- punctuation.definition.variable 476 | #^^^^ variable.language 477 | Isn't it "nice"?? 478 | There is no @platting here! 479 | # ^^^^^^^^^ - variable - punctuation 480 | "@ 481 | # <- string.quoted.double.heredoc 482 | # <- string.quoted.double.heredoc 483 | @' 484 | #<- meta.string string.quoted.single.heredoc punctuation.definition.string.begin 485 | A 'single quoted' "heredoc" 486 | '@ 487 | #<- meta.string string.quoted.single.heredoc punctuation.definition.string.end 488 | 489 | # Numeric constants 490 | 491 | -3 +3 3 3l 3lm 3lmb 492 | # ^ keyword.operator.unary 493 | # ^ meta.number.integer.decimal constant.numeric.value 494 | # ^ keyword.operator.unary 495 | # ^ meta.number.integer.decimal constant.numeric.value 496 | # ^ meta.number.integer.decimal constant.numeric.value 497 | # ^ meta.number.integer.decimal constant.numeric.value 498 | # ^ meta.number.integer.decimal constant.numeric.suffix 499 | # ^^ meta.number.integer.decimal 500 | # ^ - constant.numeric 501 | # ^^^^ meta.number.integer.decimal 502 | # ^ constant.numeric.value 503 | # ^^^ constant.numeric.suffix 504 | 505 | 3y 3uy 3s 3us 3u 3ul # PowerShell 6.2+ 506 | # ^^ meta.number.integer.decimal 507 | # ^ constant.numeric.value 508 | # ^ constant.numeric.suffix 509 | # ^^^ meta.number.integer.decimal 510 | # ^ constant.numeric.value 511 | # ^^ constant.numeric.suffix 512 | # ^^ meta.number.integer.decimal 513 | # ^ constant.numeric.value 514 | # ^ constant.numeric.suffix 515 | # ^^^ meta.number.integer.decimal 516 | # ^ constant.numeric.value 517 | # ^^ constant.numeric.suffix 518 | # ^^ meta.number.integer.decimal 519 | # ^ constant.numeric.value 520 | # ^ constant.numeric.suffix 521 | # ^^^ meta.number.integer.decimal 522 | # ^ constant.numeric.value 523 | # ^^ constant.numeric.suffix 524 | 525 | 3n # PowerShell 7.0+ 526 | # ^^ meta.number.integer.decimal 527 | # ^ constant.numeric.value 528 | # ^ constant.numeric.suffix 529 | 530 | .5 531 | # ^^ meta.number.float.decimal constant.numeric.value - constant constant 532 | # ^ punctuation.separator.decimal 533 | 534 | +.5 535 | # ^ keyword.operator.unary 536 | # ^^ meta.number.float.decimal constant.numeric.value - constant constant 537 | # ^ punctuation.separator.decimal 538 | 539 | 1. 540 | # ^ meta.number.integer.decimal constant.numeric.value 541 | # ^ - meta.number - constant.numeric 542 | 543 | 1.f 1.f() 544 | # ^ meta.number.integer.decimal constant.numeric.value 545 | # ^ punctuation.accessor.dot 546 | # ^ variable.other.member 547 | # ^ meta.number.integer.decimal constant.numeric.value 548 | # ^ punctuation.accessor.dot 549 | # @ reference 550 | # ^ meta.function-call variable.function 551 | # ^ meta.function-call.arguments punctuation.section.arguments.begin 552 | # ^ meta.function-call.arguments punctuation.section.arguments.end 553 | 554 | 1.d 555 | # ^^^ meta.number.float.decimal - constant constant 556 | # ^^ constant.numeric.value 557 | # ^ punctuation.separator.decimal 558 | # ^ constant.numeric.suffix 559 | 560 | 1.lGB 561 | # ^^^^^ meta.number.float.decimal 562 | # ^^ constant.numeric.value 563 | # ^ punctuation.separator.decimal 564 | # ^^^ constant.numeric.suffix 565 | 566 | 1.dGB 567 | # ^^^^^ meta.number.float.decimal 568 | # ^^ constant.numeric.value 569 | # ^ punctuation.separator.decimal 570 | # ^^^ constant.numeric.suffix 571 | 572 | 1.e+12d 573 | # ^^^^^^^ meta.number.float.decimal 574 | # ^^^^^^ constant.numeric.value 575 | # ^ punctuation.separator.decimal 576 | # ^ constant.numeric.suffix 577 | 578 | 1e+12d 579 | # ^^^^^^ meta.number.float.decimal 580 | # ^^^^^ constant.numeric.value 581 | # ^ constant.numeric.suffix 582 | 583 | 1.5 584 | # ^^^ meta.number.float.decimal constant.numeric.value 585 | # ^ punctuation.separator.decimal 586 | 587 | -1.5 588 | # ^ keyword.operator.unary 589 | # ^^^ meta.number.float.decimal constant.numeric.value 590 | # ^ punctuation.separator.decimal 591 | 592 | -3 + -2 593 | # ^ keyword.operator.unary 594 | # ^ meta.number.integer.decimal constant.numeric.value 595 | # ^ keyword.operator.arithmetic 596 | # ^ keyword.operator.unary 597 | # ^ meta.number.integer.decimal constant.numeric.value 598 | 599 | -3+-2 600 | # ^ keyword.operator.unary 601 | # ^ meta.number.integer.decimal constant.numeric.value 602 | # ^ keyword.operator.arithmetic 603 | # ^ keyword.operator.unary 604 | # ^ meta.number.integer.decimal constant.numeric.value 605 | 606 | 3++2 607 | # ^ meta.number.integer.decimal constant.numeric.value 608 | # ^ keyword.operator.arithmetic 609 | # ^ keyword.operator.unary 610 | # ^ meta.number.integer.decimal constant.numeric.value 611 | 612 | +2 613 | # ^ keyword.operator.unary 614 | # ^ meta.number.integer.decimal constant.numeric.value 615 | 616 | -3+- 617 | # ^ keyword.operator.unary 618 | # ^ meta.number.integer.decimal constant.numeric.value 619 | # ^^ keyword.operator 620 | 621 | 10/-10 622 | # ^^ meta.number.integer.decimal constant.numeric.value 623 | # ^ keyword.operator.arithmetic 624 | # ^^ meta.number.integer.decimal constant.numeric.value 625 | 626 | 10/-10D 627 | # ^^ meta.number.integer.decimal constant.numeric.value 628 | # ^ keyword.operator.arithmetic 629 | # ^^^ meta.number.float.decimal 630 | # ^^ constant.numeric.value 631 | # ^ constant.numeric.suffix 632 | 633 | -10.002L 634 | # ^ keyword.operator.unary 635 | # ^^^^^^^ meta.number.float.decimal 636 | # ^^^^^^ constant.numeric.value 637 | # ^ punctuation.separator.decimal 638 | # ^ constant.numeric.suffix 639 | 640 | $x..5.40D 641 | # ^ punctuation.definition.variable 642 | # ^^ variable.other.readwrite 643 | # ^^ keyword.operator.range 644 | # ^^^^^ meta.number.float.decimal 645 | # ^^^^ constant.numeric.value 646 | # ^ punctuation.separator.decimal 647 | # ^ constant.numeric.suffix 648 | 649 | -500..-495 650 | # ^ keyword.operator.unary 651 | # ^^^ meta.number.integer.decimal constant.numeric.value 652 | # ^^ keyword.operator.range 653 | # ^ keyword.operator.unary 654 | # ^^^ meta.number.integer.decimal constant.numeric.value 655 | 656 | $true..3 657 | # ^ punctuation.definition.variable 658 | # ^^^^ constant.language 659 | # ^^ keyword.operator.range 660 | # ^ meta.number.integer.decimal constant.numeric.value 661 | 662 | -2..$null 663 | # ^ keyword.operator.unary 664 | # ^ meta.number.integer.decimal constant.numeric.value 665 | # ^^ keyword.operator.range 666 | # ^^^^^ constant.language 667 | # ^ punctuation.definition.variable 668 | 669 | -3..3 670 | # ^ keyword.operator.unary 671 | # ^ meta.number.integer.decimal constant.numeric.value 672 | # ^ meta.number.integer.decimal constant.numeric.value 673 | # ^^ keyword.operator.range 674 | 675 | 1..3 676 | # ^ meta.number.integer.decimal constant.numeric.value 677 | # ^ meta.number.integer.decimal constant.numeric.value 678 | # ^^ keyword.operator.range 679 | 680 | 6,10,-3 681 | # ^ meta.number.integer.decimal constant.numeric.value 682 | # ^ punctuation.separator.sequence -constant 683 | # ^^ meta.number.integer.decimal constant.numeric.value 684 | # ^ punctuation.separator.sequence -constant 685 | # ^ meta.number.integer.decimal constant.numeric.value 686 | 687 | 0x476 0X476 0x476l 0x47m 0x47mb 688 | # ^^^^^ meta.number.integer.hexadecimal 689 | # ^^ constant.numeric.base 690 | # ^^^ constant.numeric.value 691 | # ^^^^^ meta.number.integer.hexadecimal 692 | # ^^ constant.numeric.base 693 | # ^^^ constant.numeric.value 694 | # ^^^^^^ meta.number.integer.hexadecimal 695 | # ^^ constant.numeric.base 696 | # ^^^ constant.numeric.value 697 | # ^ constant.numeric.suffix 698 | # ^^^^ meta.number.integer.hexadecimal 699 | # ^^ constant.numeric.base 700 | # ^^ constant.numeric.value 701 | # ^ - constant.numeric 702 | # ^^^^ meta.number.integer.hexadecimal 703 | # ^^ constant.numeric.base 704 | # ^^ constant.numeric.value 705 | # ^^ constant.numeric.suffix 706 | 707 | +0x20 +0X20 +0x20l +0x20m +0x20mb 708 | # ^ keyword.operator.unary 709 | # ^^^^ meta.number.integer.hexadecimal 710 | # ^^ constant.numeric.base 711 | # ^^ constant.numeric.value 712 | # ^ keyword.operator.unary 713 | # ^^^^ meta.number.integer.hexadecimal 714 | # ^^ constant.numeric.base 715 | # ^^ constant.numeric.value 716 | # ^^^^^ meta.number.integer.hexadecimal 717 | # ^^ constant.numeric.base 718 | # ^^ constant.numeric.value 719 | # ^ constant.numeric.suffix 720 | # ^^^^ meta.number.integer.hexadecimal 721 | # ^^ constant.numeric.base 722 | # ^^ constant.numeric.value 723 | # ^ - constant.numeric 724 | # ^^^^^^ meta.number.integer.hexadecimal 725 | # ^^ constant.numeric.base 726 | # ^^ constant.numeric.value 727 | # ^^ constant.numeric.suffix 728 | 729 | -0x20 -0X20 -0x20l -0x20m -0x20mb 730 | # ^ keyword.operator.unary 731 | # ^^^^ meta.number.integer.hexadecimal 732 | # ^^ constant.numeric.base 733 | # ^^ constant.numeric.value 734 | # ^ keyword.operator.unary 735 | # ^^^^ meta.number.integer.hexadecimal 736 | # ^^ constant.numeric.base 737 | # ^^ constant.numeric.value 738 | # ^ keyword.operator.unary 739 | # ^^^^^ meta.number.integer.hexadecimal 740 | # ^^ constant.numeric.base 741 | # ^^ constant.numeric.value 742 | # ^ constant.numeric.suffix 743 | # ^^^^ meta.number.integer.hexadecimal 744 | # ^^ constant.numeric.base 745 | # ^^ constant.numeric.value 746 | # ^ - constant.numeric 747 | # ^^^^^^ meta.number.integer.hexadecimal 748 | # ^^ constant.numeric.base 749 | # ^^ constant.numeric.value 750 | # ^^ constant.numeric.suffix 751 | 752 | # Types 753 | [string] 754 | # <- punctuation.section.brackets.begin 755 | # ^ storage.type 756 | # ^ punctuation.section.brackets.end 757 | [string[]] 758 | # <- punctuation.section.brackets.begin 759 | # ^ storage.type 760 | # ^ punctuation.section.brackets.begin 761 | # ^^ punctuation.section.brackets.end 762 | [int32] 763 | # <- punctuation.section.brackets.begin 764 | # ^^^^ storage.type 765 | # ^ punctuation.section.brackets.end 766 | [System.Collections.Generic.Dictionary[[System.String, mscorlib],[System.Management.Automation.ParameterMetadata,System.Management.Automation]]] 767 | # <- punctuation.section.brackets.begin 768 | # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ storage.type 769 | # ^^ punctuation.section.brackets.begin 770 | # ^^^^^^^^^^^^^ storage.type 771 | # ^^^^^^^^ storage.type 772 | # ^ punctuation.section.brackets.end 773 | # ^ punctuation.section.brackets.begin 774 | # ^^^^^^^^^^^^^^^^ storage.type 775 | # ^^^ punctuation.section.brackets.end 776 | [System.Array+SZArrayEnumerator] 777 | # <- punctuation.section.brackets.begin 778 | # ^^^^^^^^^^^ storage.type 779 | # ^^^^^^^^^^^^^^^^^ storage.type 780 | # ^ keyword.operator 781 | # ^ punctuation.section.brackets.end 782 | [int]::MinValue 783 | # <- punctuation.section.brackets.begin 784 | # ^ storage.type 785 | # ^ punctuation.section.brackets.end 786 | # ^^ punctuation.accessor.double-colon 787 | # ^^^^^^^^ variable.other.member 788 | [System.DateTime]::Parse('2016/09/21') 789 | # <- punctuation.section.brackets.begin 790 | # ^^^^^^^^^^^^^^ storage.type 791 | # ^ punctuation.section.brackets.end 792 | # ^^ punctuation.accessor.double-colon 793 | # ^^^^^ meta.function-call variable.function 794 | # @@@@@ reference 795 | # ^^^^^^^^^^^^^^ meta.function-call.arguments 796 | # ^ punctuation.section.arguments.begin 797 | # ^ punctuation.section.arguments.end 798 | 799 | # Commands (functions) 800 | Invoke-Something -foobar 801 | #^ support.function 802 | # ^ punctuation.definition.parameter 803 | # ^^^^^^^ variable.parameter.option 804 | #@@@@@@@@@@@@@@@@ reference 805 | Invoke-Something -foobar value 806 | #^ support.function 807 | # ^ punctuation.definition.parameter 808 | # ^^^^^^^ variable.parameter.option 809 | #@@@@@@@@@@@@@@@@ reference 810 | Invoke-Something -foobar:$true 811 | #^ support.function 812 | #@@@@@@@@@@@@@@@@ reference 813 | # ^ punctuation.definition.parameter 814 | # ^^^^^^^ variable.parameter.option 815 | # ^ punctuation.definition.variable 816 | # ^^^^ constant.language 817 | Invoke-Something -foobar: $true 818 | #^ support.function 819 | #@@@@@@@@@@@@@@@@ reference 820 | # ^ punctuation.definition.parameter 821 | # ^^^^^^^ variable.parameter.option 822 | Invoke-Something -p1 v1 -p2 10 -p3 'value' -switch -verbose 823 | #^ support.function 824 | #@@@@@@@@@@@@@@@@ reference 825 | # ^ punctuation.definition.parameter 826 | # ^^^ variable.parameter.option 827 | # ^ punctuation.definition.parameter 828 | # ^^^ variable.parameter.option 829 | # ^^ meta.number.integer.decimal constant.numeric.value 830 | # ^^^^^^ - keyword 831 | # ^ punctuation.definition.parameter 832 | # ^^^ variable.parameter.option 833 | Invoke-Something (1..20 | Invoke-Something) -p2 'value' 834 | #^ support.function 835 | #@@@@@@@@@@@@@@@@ reference 836 | # @@@@@@@@@@@@@@@@ reference 837 | # ^^ keyword.operator.range 838 | Invoke-Something -p1 v2 -p2 30 | Invoke-Something -switch 839 | #^ support.function 840 | # @@@@@@@@@@@@@@@@ reference 841 | #@@@@@@@@@@@@@@@@ reference 842 | # ^ punctuation.definition.parameter 843 | # ^^^ variable.parameter.option 844 | # ^ punctuation.definition.parameter 845 | # ^^^ variable.parameter.option 846 | # ^^ meta.number.integer.decimal constant.numeric.value 847 | # ^ keyword.operator.logical.pipe 848 | # ^ support.function 849 | # ^ punctuation.definition.parameter 850 | # ^^^^^^^ variable.parameter.option - keyword 851 | Invoke-Something -p1 { 852 | #^ support.function 853 | #@@@@@@@@@@@@@@@@ reference 854 | # ^ punctuation.definition.parameter 855 | # ^^^ variable.parameter.option 856 | Invoke-Something -foobar:$true 857 | # ^ support.function 858 | # @@@@@@@@@@@@@@@@ reference 859 | # ^ punctuation.definition.parameter 860 | # ^^^^^^^ variable.parameter.option 861 | # ^ punctuation.definition.variable 862 | # ^^^^ constant.language 863 | } | Invoke-Something 864 | # <- punctuation.section.braces.end 865 | # ^ keyword.operator.logical.pipe 866 | # ^ support.function 867 | # @@@@@@@@@@@@@@@@ reference 868 | Invoke-Something -p1 value ` 869 | #^ support.function 870 | #@@@@@@@@@@@@@@@@ reference 871 | # ^ punctuation.definition.parameter 872 | # ^^^ variable.parameter.option 873 | # ^ punctuation.separator.continuation 874 | -p2 14.4 ` 875 | # ^ punctuation.definition.parameter 876 | # ^^^ variable.parameter.option 877 | # ^^^^ meta.number.float.decimal constant.numeric.value 878 | # ^ punctuation.separator.continuation 879 | -p3 $value | Invoke-Something -verbose 880 | # ^ punctuation.definition.parameter 881 | # ^^^ variable.parameter.option 882 | # @@@@@@@@@@@@@@@@ reference 883 | # ^ punctuation.definition.parameter 884 | # ^^^^^^^^ variable.parameter.option 885 | # ^ punctuation.definition.variable 886 | # ^ keyword.operator.logical.pipe 887 | # ^^^^^^^^^^^^^^^^ support.function 888 | 889 | # Commands (Built-in variables) 890 | ls *.ps1 -recurse 891 | # ^ keyword.operator 892 | # ^ punctuation.definition.parameter 893 | # ^^^^^^^^ variable.parameter.option 894 | 895 | # Commands (executable files) 896 | . .\scripts\myscript.ps1 -parameter 'value' 897 | # <- keyword.operator.other 898 | # ^ punctuation.definition.parameter 899 | # ^^^^^^^^^^ variable.parameter.option 900 | # ^^^^^^^ string.quoted.single 901 | & tool.exe 902 | # <- keyword.operator.other 903 | # ^^^^^^^^ variable.function 904 | something.cmd 905 | #^^^^^^^^^^^^ variable.function 906 | øyvind.com 907 | #^^^^^^^^^^ variable.function 908 | 909 | # switch 910 | switch ("fourteen") {} 911 | # <- keyword.control 912 | # ^ punctuation.section.group.begin 913 | # ^ string.quoted.double 914 | # ^ punctuation.section.group.end 915 | # ^ meta.block punctuation.section.braces.begin 916 | # ^ meta.block punctuation.section.braces.end 917 | switch -CaseSensitive ("fourteen") {} 918 | # <- keyword.control 919 | # ^ punctuation.definition.parameter 920 | # ^^^^^^^^^^^^^^ variable.parameter.option 921 | # ^ punctuation.section.group.begin 922 | # ^ string.quoted.double 923 | # ^ punctuation.section.group.end 924 | # ^ meta.block punctuation.section.braces.begin 925 | # ^ meta.block punctuation.section.braces.end 926 | switch -Regex ("fourteen") {} 927 | # <- keyword.control 928 | # ^ punctuation.definition.parameter 929 | # ^^^^^^ variable.parameter.option 930 | # ^ punctuation.section.group.begin 931 | # ^ string.quoted.double 932 | # ^ punctuation.section.group.end 933 | # ^ meta.block punctuation.section.braces.begin 934 | # ^ meta.block punctuation.section.braces.end 935 | switch -Wildcard ($a) {} 936 | # <- keyword.control 937 | # ^ punctuation.definition.parameter 938 | # ^^^^^^^^^ variable.parameter.option 939 | # ^ punctuation.section.group.begin 940 | # ^ punctuation.definition.variable 941 | # ^ punctuation.section.group.end 942 | # ^ meta.block punctuation.section.braces.begin 943 | # ^ meta.block punctuation.section.braces.end 944 | switch -regex -file .\somefile.txt {} 945 | # <- keyword.control 946 | # ^ punctuation.definition.parameter 947 | # ^^^^^^ variable.parameter.option 948 | # ^ punctuation.definition.parameter 949 | # ^^^^ variable.parameter.option 950 | # ^ meta.block punctuation.section.braces.begin 951 | # ^ meta.block punctuation.section.braces.end 952 | switch (3) {} 953 | # <- keyword.control 954 | # ^ punctuation.section.group.begin 955 | # ^ meta.number.integer.decimal constant.numeric.value 956 | # ^ punctuation.section.group.end 957 | # ^ meta.block punctuation.section.braces.begin 958 | # ^ meta.block punctuation.section.braces.end 959 | switch (4, 2) {} 960 | # <- keyword.control 961 | # ^ punctuation.section.group.begin 962 | # ^ meta.number.integer.decimal constant.numeric.value 963 | # ^ meta.number.integer.decimal constant.numeric.value 964 | # ^ punctuation.separator 965 | # ^ punctuation.section.group.end 966 | # ^ meta.block punctuation.section.braces.begin 967 | # ^ meta.block punctuation.section.braces.end 968 | 969 | switch -Regex -File $filePath { 970 | # <- keyword.control 971 | # ^ punctuation.definition.parameter 972 | # ^^^^^^ variable.parameter.option 973 | # ^ punctuation.definition.parameter 974 | # ^^^^ variable.parameter.option 975 | # ^ punctuation.definition.variable 976 | # ^ meta.block punctuation.section.braces.begin 977 | '.' {} 978 | # ^^^ string.quoted.single 979 | # ^ meta.block punctuation.section.braces.begin 980 | # ^ meta.block punctuation.section.braces.end 981 | default {} 982 | # ^^^^^^^ keyword.control 983 | # ^ meta.block punctuation.section.braces.begin 984 | # ^ meta.block punctuation.section.braces.end 985 | } 986 | # <- meta.block punctuation.section.braces.end 987 | 988 | switch -Wildcard -CaseSensitive ($something) { 989 | # <- keyword.control 990 | # ^ punctuation.definition.parameter 991 | # ^^^^^^^^^ variable.parameter.option 992 | # ^ punctuation.definition.parameter 993 | # ^^^^^^^^^^^^^^ variable.parameter.option 994 | # ^ punctuation.section.group.begin 995 | # ^ punctuation.definition.variable 996 | # ^ variable.other.readwrite 997 | # ^ punctuation.section.group.end 998 | # ^ meta.block punctuation.section.braces.begin 999 | '.' {} 1000 | # ^^^ string.quoted.single 1001 | # ^ meta.block punctuation.section.braces.begin 1002 | # ^ meta.block punctuation.section.braces.end 1003 | default {} 1004 | # ^^^^^^^ keyword.control 1005 | # ^ meta.block punctuation.section.braces.begin 1006 | # ^ meta.block punctuation.section.braces.end 1007 | } 1008 | # <- meta.block punctuation.section.braces.end 1009 | 1010 | switch ('this') { 1011 | # <- keyword.control 1012 | # ^ punctuation.section.group.begin 1013 | # ^^^^^^ string.quoted.single 1014 | # ^ punctuation.section.group.end 1015 | # ^ meta.block punctuation.section.braces.begin 1016 | 'this' {} 1017 | # ^^^^^^ string.quoted.single 1018 | # ^ meta.block punctuation.section.braces.begin 1019 | # ^ meta.block punctuation.section.braces.end 1020 | default {} 1021 | # ^^^^^^^ keyword.control 1022 | # ^ meta.block punctuation.section.braces.begin 1023 | # ^ meta.block punctuation.section.braces.end 1024 | } 1025 | # <- meta.block punctuation.section.braces.end 1026 | 1027 | # Functions and filters 1028 | functioN MyFunction{} 1029 | # <- storage.type 1030 | # ^^^^^^^^^^ entity.name.function 1031 | # @@@@@@@@@@ definition 1032 | # ^ punctuation.section.braces.begin 1033 | # ^ punctuation.section.braces.end 1034 | function My-Function {} 1035 | # <- storage.type 1036 | # ^^^^^^^^^^^ entity.name.function 1037 | # @@@@@@@@@@@ definition 1038 | # ^ punctuation.section.braces.begin 1039 | # ^ punctuation.section.braces.end 1040 | Function My.Function{} 1041 | # <- storage.type 1042 | # ^^^^^^^^^^^ entity.name.function 1043 | # @@@@@@@@@@@ definition 1044 | # ^ punctuation.section.braces.begin 1045 | # ^ punctuation.section.braces.end 1046 | function My-Function.Other{} 1047 | # <- storage.type 1048 | # ^^^^^^^^^^^^^^^^^ entity.name.function 1049 | # @@@@@@@@@@@@@@@@@ definition 1050 | # ^ punctuation.section.braces.begin 1051 | # ^ punctuation.section.braces.end 1052 | function Some.other.function{} 1053 | # <- storage.type 1054 | # ^^^^^^^^^^^^^^^^^^^ entity.name.function 1055 | # @@@@@@@@@@@@@@@@@@@ definition 1056 | # ^ punctuation.section.braces.begin 1057 | # ^ punctuation.section.braces.end 1058 | FUNCTION MyFunction2 {} 1059 | # <- storage.type 1060 | # ^^^^^^^^^^^ entity.name.function 1061 | # @@@@@@@@@@@ definition 1062 | # ^ punctuation.section.braces.begin 1063 | # ^ punctuation.section.braces.end 1064 | function New-File { } 1065 | # <- storage.type 1066 | # ^^^^^^^^ entity.name.function 1067 | # @@@@@@@@ definition 1068 | # ^ punctuation.section.braces.begin 1069 | # ^ punctuation.section.braces.end 1070 | function New-File ($Name) { } 1071 | # <- storage.type 1072 | # ^^^^^^^^ entity.name.function 1073 | # @@@@@@@@ definition 1074 | # ^ punctuation.section.braces.begin 1075 | # ^ punctuation.section.braces.end 1076 | New-File 1077 | #^^^^^^^^ meta.function-call support.function 1078 | #@@@@@@@@ reference 1079 | function NewFile($Name) { } 1080 | # <- storage.type 1081 | # ^^^^^^^ entity.name.function 1082 | # @@@@@@@ definition 1083 | # ^ punctuation.section.group.begin 1084 | # ^ punctuation.definition.variable 1085 | # ^ variable.other.readwrite 1086 | # ^ punctuation.section.group.end 1087 | # ^ punctuation.section.braces.begin 1088 | # ^ punctuation.section.braces.end 1089 | filter myfilter($param) {} 1090 | # <- storage.type 1091 | # ^^^^^^^^ entity.name.function 1092 | # @@@@@@@@ definition 1093 | # ^ punctuation.section.group.begin 1094 | # ^ punctuation.definition.variable 1095 | # ^ variable.other.readwrite 1096 | # ^ punctuation.section.group.end 1097 | # ^ punctuation.section.braces.begin 1098 | # ^ punctuation.section.braces.end 1099 | Filter my-Filter ($param){} 1100 | # <- storage.type 1101 | # ^^^^^^^^^ entity.name.function 1102 | # @@@@@@@@@ definition 1103 | # ^ punctuation.section.group.begin 1104 | # ^ punctuation.definition.variable 1105 | # ^ variable.other.readwrite 1106 | # ^ punctuation.section.group.end 1107 | # ^ punctuation.section.braces.begin 1108 | # ^ punctuation.section.braces.end 1109 | 1110 | # Note that the # in the path should highlight as a comment! 1111 | function Test-Drive([string]$roman) { 1112 | # <- storage.type 1113 | # ^^^^^^^^^^ entity.name.function 1114 | # @@@@@@@@@@ definition 1115 | # ^ punctuation.section.group.begin 1116 | # ^ punctuation.section.brackets.begin 1117 | # ^^^^^^ storage.type 1118 | # ^ punctuation.section.brackets.end 1119 | # ^ punctuation.definition.variable 1120 | # ^ variable.other.readwrite 1121 | # ^ punctuation.section.group.end 1122 | # ^ punctuation.section.braces.begin 1123 | $roman | c:\users\Me\Documents\Programming\F#\test.exe $roman 1124 | # ^ punctuation.definition.variable 1125 | # ^ variable.other.readwrite 1126 | # ^ keyword.operator.logical.pipe 1127 | # ^ punctuation.definition.comment 1128 | # ^^^^ comment.line 1129 | } 1130 | # <- punctuation.section.braces.end 1131 | 1132 | function Verb-Noun 1133 | #^^^^^^^^^^^^^^^^^ meta.function 1134 | #^^^^^^^ storage.type 1135 | # ^^^^^^^^^ meta.function entity.name.function 1136 | # @@@@@@@@@ definition 1137 | { 1138 | # <- punctuation.section.braces.begin 1139 | 1140 | Param 1141 | #^^^^^ keyword.declaration.parameter 1142 | ( 1143 | # <- punctuation.section.group.begin 1144 | # Param1 help description 1145 | # <- comment.line punctuation.definition.comment 1146 | # ^^^^^^^^^^^^^^^^^^^^^^^ comment.line 1147 | [Parameter(Mandatory=$true, 1148 | #^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.attribute 1149 | # <- punctuation.section.brackets.begin 1150 | # ^ support.function.attribute 1151 | # ^ punctuation.section.group.begin 1152 | # ^^^^^^^^^ variable.parameter.attribute 1153 | # ^ keyword.operator.assignment 1154 | # ^ punctuation.definition.variable 1155 | # ^^^^ constant.language 1156 | # ^ punctuation.separator 1157 | ValueFromPipeline=$true, 1158 | #^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.attribute 1159 | # ^^^^^^^^^^^^^^^^^ variable.parameter.attribute 1160 | # ^ keyword.operator.assignment 1161 | # ^ punctuation.definition.variable 1162 | # ^^^^ constant.language 1163 | # ^ punctuation.separator 1164 | ValueFromPipelineByPropertyName = $true, 1165 | #^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.attribute 1166 | # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ variable.parameter.attribute 1167 | # ^ keyword.operator.assignment 1168 | # ^ punctuation.definition.variable 1169 | # ^^^^^ constant.language 1170 | # ^ punctuation.separator 1171 | ValueFromRemainingArguments=$false, 1172 | #^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.attribute 1173 | # ^^^^^^^^^^^^^^^^^^^^^^^^^^^ variable.parameter.attribute 1174 | # ^ keyword.operator.assignment 1175 | # ^ punctuation.definition.variable 1176 | # ^^^^^ constant.language 1177 | # ^ punctuation.separator 1178 | Position=0, 1179 | #^^^^^^^^^^^^^^^^^^^^^^ meta.attribute 1180 | # ^^^^^^^^ variable.parameter.attribute 1181 | # ^ keyword.operator.assignment 1182 | # ^ meta.number.integer.decimal constant.numeric.value 1183 | # ^ punctuation.separator 1184 | SupportsPaging, 1185 | #^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.attribute 1186 | # ^^^^^^^^^^^^^^ variable.parameter.attribute 1187 | # ^ punctuation.separator 1188 | ParameterSetName = 'Parameter Set 1')] 1189 | #^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.attribute 1190 | # ^^^^^^^^^^^^^^^^ variable.parameter.attribute 1191 | # ^ keyword.operator.assignment 1192 | # ^^^^^^^^^^^^^^^^^ string.quoted.single 1193 | # ^ punctuation.section.group.end 1194 | # ^ punctuation.section.brackets.end 1195 | # ^ - meta.attribute 1196 | [ValidateNotNullOrEmpty()] 1197 | #^^^^^^^^^^^^^^^^^^^^^^^^^ meta.attribute 1198 | # <- punctuation.section.brackets.begin 1199 | # ^^^^^^^^^^^^^^^^^^^^^ support.function.attribute 1200 | # ^ punctuation.section.group.begin 1201 | # ^ punctuation.section.group.end 1202 | # ^ punctuation.section.brackets.end 1203 | [ValidateNotNull()] 1204 | #^^^^^^^^^^^^^^^^^^ meta.attribute 1205 | # <- punctuation.section.brackets.begin 1206 | # ^^^^^^^^^^^^^^ support.function.attribute 1207 | # ^ punctuation.section.group.begin 1208 | # ^ punctuation.section.group.end 1209 | # ^ punctuation.section.brackets.end 1210 | [ValidateNotNullOrEmpty()] 1211 | #^^^^^^^^^^^^^^^^^^^^^^^^^ meta.attribute 1212 | # <- punctuation.section.brackets.begin 1213 | # ^^^^^^^^^^^^^^^^^^^^^ support.function.attribute 1214 | # ^ punctuation.section.group.begin 1215 | # ^ punctuation.section.group.end 1216 | # ^ punctuation.section.brackets.end 1217 | [ValidateCount(0,5)] 1218 | #^^^^^^^^^^^^^^^^^^^ meta.attribute 1219 | # <- punctuation.section.brackets.begin 1220 | # ^^^^^^^^^^^^ support.function.attribute 1221 | # ^ punctuation.section.group.begin 1222 | # ^ meta.number.integer.decimal constant.numeric.value 1223 | # ^ punctuation.separator 1224 | # ^ meta.number.integer.decimal constant.numeric.value 1225 | # ^ punctuation.section.group.end 1226 | # ^ punctuation.section.brackets.end 1227 | [ValidateSet("sun", "moon", "earth")] 1228 | #^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.attribute 1229 | # <- punctuation.section.brackets.begin 1230 | # ^ support.function.attribute 1231 | # ^ punctuation.section.group.begin 1232 | # ^^^^ string.quoted.double 1233 | # ^ punctuation.separator 1234 | # ^^^^^^ string.quoted.double 1235 | # ^ punctuation.separator 1236 | # ^^^^^^^ string.quoted.double 1237 | # ^ punctuation.section.group.end 1238 | # ^ punctuation.section.brackets.end 1239 | [Alias("p1")] 1240 | #^^^^^^^^^^^^ meta.attribute 1241 | # <- punctuation.section.brackets.begin 1242 | # ^ support.function.attribute 1243 | # ^ punctuation.section.group.begin 1244 | # ^^^^ string.quoted.double 1245 | # ^ punctuation.section.group.end 1246 | # ^ punctuation.section.brackets.end 1247 | $Param1 1248 | # <- punctuation.definition.variable 1249 | # ^ variable.other.readwrite 1250 | ) 1251 | # <- punctuation.section.group.end 1252 | 1253 | # Do Something.... 1254 | 1255 | } 1256 | # <- punctuation.section.braces.end 1257 | 1258 | # Class 1259 | class Vehicle { 1260 | # <- storage.type.class 1261 | # ^^^^^^^ entity.name.class 1262 | # @@@@@@@ definition 1263 | # ^ punctuation.section.braces.begin 1264 | Vehicle() {} 1265 | # ^ punctuation.section.group.begin 1266 | # ^ punctuation.section.group.end 1267 | # ^ punctuation.section.braces.begin 1268 | # ^ punctuation.section.braces.end 1269 | Vehicle([string]$Owner) { 1270 | # ^ storage.type 1271 | # ^ punctuation.definition.variable 1272 | # ^ variable.other.readwrite 1273 | # ^ punctuation.section.braces.begin 1274 | $this.Owner = $Owner 1275 | } 1276 | 1277 | [int]$Mileage 1278 | # ^ storage.type 1279 | # ^ punctuation.definition.variable 1280 | # ^ variable.other.readwrite 1281 | [int]$Age 1282 | # ^ storage.type 1283 | # ^ punctuation.definition.variable 1284 | # ^ variable.other.readwrite 1285 | [string]$Owner 1286 | # ^ storage.type 1287 | # ^ punctuation.definition.variable 1288 | # ^ variable.other.readwrite 1289 | 1290 | [void]Drive([int]$NumberOfMiles) { 1291 | # ^^^^ storage.type 1292 | # ^^^^^ meta.function entity.name.function 1293 | # @@@@@ definition 1294 | # ^^^ storage.type 1295 | # ^ punctuation.definition.variable 1296 | # ^ variable.other.readwrite 1297 | $this.Mileage += $NumberOfMiles 1298 | # ^^^^^ variable.language 1299 | # ^ punctuation.definition.variable 1300 | # ^^^^^^^ variable.other.member 1301 | # ^^ keyword.operator.assignment 1302 | 1303 | } 1304 | # <- punctuation.section.braces.end 1305 | static [System.Array] GetAvailableColors() { 1306 | # ^^^^^^^^^^^^^^^^^^ meta.function entity.name.function 1307 | # @@@@@@@@@@@@@@@@@@ definition 1308 | # ^^^^^^ meta.function storage.modifier 1309 | # ^^^^^^^^^^^ meta.function storage.type 1310 | return 'yellow', 'red' 1311 | } 1312 | } 1313 | # <- punctuation.section.braces.end 1314 | 1315 | $fiat.Drive(42) 1316 | # ^^^^^ meta.function-call 1317 | # @@@@@ reference 1318 | [Vehicle]::GetAvailableColors() 1319 | # ^^^^^^^^^^^^^^^^^^ meta.function-call variable.function 1320 | # @@@@@@@@@@@@@@@@@@ reference 1321 | 1322 | # Control words 1323 | foreach ($item in $collection) { 1324 | # <- keyword.control 1325 | # ^ punctuation.section.group.begin 1326 | # ^^ keyword.control 1327 | # ^ punctuation.section.group.end 1328 | # ^ punctuation.section.braces.begin 1329 | # ^ punctuation.definition.variable 1330 | # ^ punctuation.definition.variable 1331 | } 1332 | # <- punctuation.section.braces.end 1333 | 1334 | try { } 1335 | # <- keyword.control 1336 | # ^ punctuation.section.braces.begin 1337 | # ^ punctuation.section.braces.end 1338 | catch { } 1339 | # <- keyword.control 1340 | # ^ punctuation.section.braces.begin 1341 | # ^ punctuation.section.braces.end 1342 | clean { } 1343 | # <- keyword.context.block.clean 1344 | # ^ punctuation.section.braces.begin 1345 | # ^ punctuation.section.braces.end 1346 | 1347 | # Reserved words 1348 | Configuration Crazyness { 1349 | # <- storage.type 1350 | # ^^^^^^^^^ entity.name.function 1351 | # @@@@@@@@@ definition 1352 | # ^ punctuation.section.braces.begin 1353 | Node Whatever { 1354 | # ^ punctuation.section.braces.begin 1355 | } 1356 | # <- punctuation.section.braces.end 1357 | } 1358 | # <- punctuation.section.braces.end 1359 | 1360 | # Redirection 1361 | notepad.exe > log.txt 1362 | #^^^^^^^^^^ variable.function 1363 | # ^ keyword.operator.redirection 1364 | notepad.exe 1> log.txt 1365 | #^^^^^^^^^^ variable.function 1366 | # ^ keyword.operator.redirection 1367 | notepad.exe *> log.txt 1368 | #^^^^^^^^^^ variable.function 1369 | # ^ keyword.operator.redirection 1370 | notepad.exe 2>&1 1371 | #^^^^^^^^^^ variable.function 1372 | # ^^ keyword.operator.redirection 1373 | notepad.exe 3>&1 1374 | #^^^^^^^^^^ variable.function 1375 | # ^^ keyword.operator.redirection 1376 | notepad.exe 4>&1 1377 | #^^^^^^^^^^ variable.function 1378 | # ^^ keyword.operator.redirection 1379 | notepad.exe 5>&1 1380 | #^^^^^^^^^^ variable.function 1381 | # ^^ keyword.operator.redirection 1382 | notepad.exe 6>&1 1383 | #^^^^^^^^^^ variable.function 1384 | # ^^ keyword.operator.redirection 1385 | notepad.exe 2>&1> log.txt 1386 | #^^^^^^^^^^ variable.function 1387 | # ^^ keyword.operator.redirection 1388 | # ^ keyword.operator.redirection 1389 | 1390 | # Operators 1391 | if (10 -cgt 100) { } 1392 | # <- keyword.control 1393 | # ^ punctuation.section.group.begin 1394 | # ^^ meta.number.integer.decimal constant.numeric.value 1395 | # ^^^^ keyword.operator.comparison 1396 | # ^^^ meta.number.integer.decimal constant.numeric.value 1397 | # ^ punctuation.section.group.end 1398 | # ^ punctuation.section.braces.begin 1399 | # ^ punctuation.section.braces.end 1400 | $a -is $b 1401 | # ^^^ keyword.operator.logical 1402 | $b -contains $c 1403 | # ^^^^^^^^^ keyword.operator.logical 1404 | $x -notcontains $c 1405 | # ^^^^^^^^^^^^ keyword.operator.logical 1406 | $c -in $b 1407 | # ^^^ keyword.operator.logical 1408 | $c -notin $x 1409 | # ^^^^^^ keyword.operator.logical 1410 | $a -match $b 1411 | # ^^^^^^ keyword.operator.logical 1412 | $a -notmatch $b 1413 | # ^^^^^^^^^ keyword.operator.logical 1414 | $x -like $c 1415 | # ^^^^^ keyword.operator.logical 1416 | 100 -and 0 1417 | # ^^^^ keyword.operator.logical 1418 | # ^ meta.number.integer.decimal constant.numeric.value 1419 | $a -ceq 4 -and $a -ine $d -or 1420 | # ^^^^ keyword.operator.comparison 1421 | # ^ meta.number.integer.decimal constant.numeric.value 1422 | # ^^^^ keyword.operator.logical 1423 | # ^ punctuation.definition.variable 1424 | # ^^^^ keyword.operator.comparison 1425 | # ^^^ keyword.operator.logical 1426 | $c -is [Type] 1427 | # ^^^ keyword.operator.logical 1428 | # ^ storage.type 1429 | $c -isnot [Type] 1430 | # ^^^^^^ keyword.operator.logical 1431 | # ^ storage.type 1432 | $c -as [Type] 1433 | # ^^^ keyword.operator.cast 1434 | # ^ storage.type 1435 | $k = $y -bor $k 1436 | # ^ keyword.operator.assignment 1437 | # ^ keyword.operator.bitwise 1438 | $x = $y -band $x 1439 | # ^ keyword.operator.assignment 1440 | # ^ keyword.operator.bitwise 1441 | $z = -bnot $x 1442 | # ^ keyword.operator.assignment 1443 | # ^ keyword.operator.bitwise 1444 | $l = 1 -shl 10 1445 | # ^ keyword.operator.assignment 1446 | # ^ meta.number.integer.decimal constant.numeric.value 1447 | # ^^ meta.number.integer.decimal constant.numeric.value 1448 | # ^^^^ keyword.operator.bitwise 1449 | $r = 10 -shr 1 1450 | # ^ keyword.operator.assignment 1451 | # ^^ meta.number.integer.decimal constant.numeric.value 1452 | # ^ meta.number.integer.decimal constant.numeric.value 1453 | # ^^^^ keyword.operator.bitwise 1454 | $k = $y -xor $b 1455 | # ^ keyword.operator.assignment 1456 | # ^ keyword.operator.logical 1457 | $k = $y -bxor $b 1458 | # ^ keyword.operator.assignment 1459 | # ^ keyword.operator.bitwise 1460 | $a -icontains $c 1461 | # ^^^^^^^^^^ keyword.operator.logical 1462 | $a -ccontains $c 1463 | # ^^^^^^^^^^ keyword.operator.logical 1464 | $a -iNotContains $c 1465 | # ^^^^^^^^^^^^^ keyword.operator.logical 1466 | $a -cNotContains $c 1467 | # ^^^^^^^^^^^^^ keyword.operator.logical 1468 | $a -cmatch $c 1469 | # ^^^^^^^ keyword.operator.logical 1470 | $x -iMatch $c 1471 | # ^^^^^^^ keyword.operator.logical 1472 | $x -iNotMatch $c 1473 | # ^^^^^^^^^^ keyword.operator.logical 1474 | $a -iLike $b 1475 | # ^^^^^^ keyword.operator.logical 1476 | $b -cLike $c 1477 | # ^^^^^^ keyword.operator.logical 1478 | "hey" -cgt "Hey" 1479 | # ^^^^ keyword.operator.comparison 1480 | "Hey" -igt "hey" 1481 | # ^^^^ keyword.operator.comparison 1482 | "hey" -cge "Hey" 1483 | # ^^^^ keyword.operator.comparison 1484 | "Hey" -ige "hey" 1485 | # ^^^^ keyword.operator.comparison 1486 | "HEY" -clt "hey" 1487 | # ^^^^ keyword.operator.comparison 1488 | "HEY" -ilt "hey" 1489 | # ^^^^ keyword.operator.comparison 1490 | "HEY" -cle "hey" 1491 | # ^^^^ keyword.operator.comparison 1492 | "HEY" -ile "hey" 1493 | # ^^^^ keyword.operator.comparison 1494 | 1495 | # format 1496 | "{0:N2}" -f $a 1497 | # ^^^^^^^^ string.quoted.double 1498 | # ^^ keyword.operator.string-format 1499 | "{0:D8}" -f $a 1500 | # ^^^^^^^^ string.quoted.double 1501 | # ^^ keyword.operator.string-format 1502 | "{0:C2}" -f $a 1503 | # ^^^^^^^^ string.quoted.double 1504 | # ^^ keyword.operator.string-format 1505 | "{0:P0}" -f $a 1506 | # ^^^^^^^^ string.quoted.double 1507 | # ^^ keyword.operator.string-format 1508 | "{0:X0}" -f $a 1509 | # ^^^^^^^^ string.quoted.double 1510 | # ^^ keyword.operator.string-format 1511 | (1.11).ToString("#.#") 1512 | # ^ punctuation.section.group.begin 1513 | # ^^^^ meta.number.float.decimal constant.numeric.value 1514 | # ^ punctuation.section.group.begin 1515 | # ^ string.quoted.double 1516 | "{1,10} {0,10} {2,10:x}" -f "First", "Second", 255 1517 | # ^^^^^^^^^^^^^^^^^^^^^^^^ string.quoted.double 1518 | # ^^ keyword.operator.string-format 1519 | # ^^^ meta.number.integer.decimal constant.numeric.value 1520 | ("{0,6}" -f 4.99), ("{0,6:##.00}" -f 15.9) 1521 | # ^^ keyword.operator.string-format 1522 | # ^^^^ meta.number.float.decimal constant.numeric.value 1523 | # ^^^^^^^^^^^^^ string.quoted.double 1524 | # ^^ keyword.operator.string-format 1525 | "{0:R}" -f (1mb/2.0) 1526 | # ^ keyword.operator.string-format 1527 | # ^ meta.number.integer.decimal constant.numeric.value 1528 | # ^^ meta.number.integer.decimal constant.numeric.suffix 1529 | "{0:00.0}" -f 4.12341234 1530 | # ^ keyword.operator.string-format 1531 | "{0:##.#}" -f 4.12341234 1532 | # ^ string.quoted.double 1533 | # ^ keyword.operator.string-format 1534 | # ^^^^^^^^^^ meta.number.float.decimal constant.numeric.value 1535 | "{0:#,#.#}" -f 1234.121234 1536 | # ^ string.quoted.double 1537 | # ^ keyword.operator.string-format 1538 | "{0:##,,.000}" -f 1048576 1539 | # ^ string.quoted.double 1540 | # ^ keyword.operator.string-format 1541 | "{this is not a #comment}" 1542 | # ^ - comment 1543 | "{0:##.#E000}" -f 2.71828 1544 | # ^ string.quoted.double 1545 | # ^ keyword.operator.string-format 1546 | "{0:#.00'##'}" -f 2.71828 1547 | # ^ string.quoted.double 1548 | # ^ keyword.operator.string-format 1549 | "{0:POS;NEG;ZERO}" -f -14 1550 | # ^ string.quoted.double 1551 | # ^ keyword.operator.string-format 1552 | "{0:$## Please}" -f 14 1553 | # ^ string.quoted.double 1554 | # ^ keyword.operator.string-format 1555 | "{0,-8:P1}" -f 1.75 1556 | # ^ string.quoted.double 1557 | # ^ keyword.operator.string-format 1558 | "{0,10:N3}{1,10:N3}{2,10:N3}{3,10:N3}" -f 0.2, 0.3, 0.45, 0.91 1559 | # ^ keyword.operator.string-format 1560 | '{0:00000.000}' -f 7.125 1561 | # ^ string.quoted.single 1562 | # ^ keyword.operator.string-format 1563 | 1564 | function Test-Function {} 1565 | # @@@@@@@@@@@@@ definition 1566 | function New-Object {} 1567 | # @@@@@@@@@@ definition 1568 | # Misc test cases 1569 | Test-Function -Class ClassName 1570 | # ^^^^^ - storage.type 1571 | #@@@@@@@@@@@@@ reference 1572 | New-Object -TypeName System.Diagnostics.Process 1573 | # ^^^^^^^ - keyword.control 1574 | #@@@@@@@@@@ reference 1575 | New-Object -TypeName System.Data 1576 | # ^^^^ - keyword.control 1577 | #@@@@@@@@@@ reference 1578 | New-Object -TypeName Sy-stem.if 1579 | # ^^ - keyword.control 1580 | #@@@@@@@@@@ reference 1581 | New-Object -TypeName S_ystem.Clean 1582 | # ^^^^^ - keyword.control 1583 | #@@@@@@@@@@ reference 1584 | New-Object -TypeName Sy_stem-.Throw 1585 | # ^^^^^ - keyword.control 1586 | #@@@@@@@@@@ reference 1587 | echo `"test`" 1588 | # ^^^^^^^^^ - string.quoted 1589 | # ^^ constant.character.escape 1590 | # ^^ constant.character.escape 1591 | @("any","array","has").foreach({ $_ }) 1592 | # <- keyword.other.array.begin 1593 | # ^ meta.group.array-expression 1594 | # ^ keyword.control 1595 | # ^ meta.block 1596 | @('any','array','has').foreach{ $_ } 1597 | # <- keyword.other.array.begin 1598 | # ^ meta.group.array-expression 1599 | # ^ keyword.control 1600 | # ^ meta.block 1601 | @("any","array","has").where({ $_.Length -gt 3 }) 1602 | # <- keyword.other.array.begin 1603 | # ^ meta.group.array-expression 1604 | # ^ keyword.control 1605 | # ^ meta.block 1606 | @("any","array","has").where{ $_.Length -gt 3 } 1607 | # <- keyword.other.array.begin 1608 | # ^ meta.group.array-expression 1609 | # ^ keyword.control 1610 | # ^ meta.block 1611 | function join-path {} 1612 | # @@@@@@@@@ definition 1613 | $file = join-path $env:SystemDrive "$([System.io.path]::GetRandomFileName()).ps1" 1614 | # <- punctuation.definition.variable 1615 | # @@@@@@@@@ reference 1616 | # ^ support.function 1617 | # ^ support.variable.drive 1618 | # ^ variable.other.readwrite 1619 | # ^^ meta.string meta.interpolation punctuation.section.interpolation.begin 1620 | # ^ storage.type 1621 | # @@@@@@@@@@@@@@@@@ reference 1622 | function out-file {} 1623 | # @@@@@@@@ definition 1624 | $ScriptBlock | Out-File $file -Force 1625 | # <- punctuation.definition.variable 1626 | # @@@@@@@@ reference 1627 | # ^ keyword.operator.logical.pipe 1628 | # ^ punctuation.definition.variable 1629 | # ^ punctuation.definition.parameter 1630 | # ^^^^^^ variable.parameter.option 1631 | workflow w1 {} 1632 | # <- storage.type 1633 | # ^^ entity.name.function 1634 | # @@ definition 1635 | # ^ punctuation.section.braces.begin 1636 | # ^ punctuation.section.braces.end 1637 | Workflow work { sequence {} } 1638 | # <- storage.type 1639 | # ^^^^ entity.name.function 1640 | # @@@@ definition 1641 | # ^ punctuation.section.braces.begin 1642 | # ^^^^^^^^ keyword.control 1643 | # ^ punctuation.section.braces.begin 1644 | # ^ punctuation.section.braces.end 1645 | # ^ punctuation.section.braces.end 1646 | function get-something {} 1647 | # @@@@@@@@@@@@@ definition 1648 | function Out-WithYou {} 1649 | # @@@@@@@@@@@ definition 1650 | get-thing | Out-WithYou > $null # destroy 1651 | #^^^^^^^^^ support.function 1652 | #@@@@@@@@@ reference 1653 | # ^^^^^^^^^^^ support.function 1654 | # @@@@@@@@@@@ reference 1655 | # ^ keyword.operator.logical.pipe 1656 | # ^ keyword.operator.redirection 1657 | # ^ punctuation.definition.variable 1658 | # ^ constant.language 1659 | # ^ punctuation.definition.comment 1660 | # ^^^^^^^^^ comment.line 1661 | "Escaped chars: `", `n, `$, `b, `t, `e, `u{10ffff}, `"" 1662 | #^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ string.quoted.double 1663 | # ^^ constant.character.escape 1664 | # ^^ constant.character.escape 1665 | # ^^ constant.character.escape 1666 | # ^^ constant.character.escape 1667 | # ^^ constant.character.escape 1668 | # ^^ constant.character.escape 1669 | # ^^^^^^^^^^ constant.character.escape 1670 | # ^^ constant.character.escape 1671 | 'But here they''re not escape chars: `", `n, `$, `b, `"' 1672 | # ^^ constant.character.escape 1673 | # ^^^^^^^^^^^^^^^^^^^ - constant 1674 | function get-number {} 1675 | # @@@@@@@@@@ definition 1676 | "When you call a method: $( get-number | %{ invoke-command $( [string]::format("Like (this{0})","what?") ) $var } )" 1677 | # ^^ punctuation.section.interpolation.begin - source.powershell.embedded 1678 | # @@@@@@@@@@ reference 1679 | # @@@@@@@@@@@@@@ reference 1680 | # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ source.powershell.embedded 1681 | # ^ keyword.operator.logical.pipe 1682 | # ^ meta.group.complex.subexpression punctuation.section.group.begin 1683 | # ^^^^^^ storage.type 1684 | # ^^ punctuation.accessor.double-colon 1685 | # ^^^^^^ meta.function-call variable.function 1686 | # @@@@@@ reference 1687 | # ^ meta.group.complex.subexpression punctuation.section.arguments.begin 1688 | # ^ meta.group.complex.subexpression punctuation.section.arguments.end 1689 | # ^ meta.group.complex.subexpression punctuation.section.group.end 1690 | # ^ punctuation.definition.variable 1691 | # ^ punctuation.section.interpolation.end - source.powershell.embedded 1692 | "This is the DebugPreference variable: $DebugPreference" 1693 | #^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.string string.quoted.double 1694 | # ^^^^^^^^^^^^^^^^ meta.string meta.interpolation variable.language - string 1695 | 1696 | $ConfirmPreference $DebugPreference $ErrorActionPreference $ErrorView 1697 | #^ variable.language punctuation 1698 | # ^^^^^^^^^^^^^^^^^ variable.language - punctuation 1699 | # ^ variable.language punctuation 1700 | # ^^^^^^^^^^^^^^^ variable.language - punctuation 1701 | # ^ variable.language punctuation 1702 | # ^^^^^^^^^^^^^^^^^^^^^ variable.language - punctuation 1703 | # ^ variable.language punctuation 1704 | # ^^^^^^^^^ variable.language - punctuation 1705 | $FormatEnumerationLimit $InformationPreference $LogCommandHealthEvent 1706 | #^ variable.language punctuation 1707 | # ^^^^^^^^^^^^^^^^^^^^^^ variable.language - punctuation 1708 | # ^ variable.language punctuation 1709 | # ^^^^^^^^^^^^^^^^^^^^^ variable.language - punctuation 1710 | # ^ variable.language punctuation 1711 | # ^^^^^^^^^^^^^^^^^^^^^ variable.language - punctuation 1712 | 1713 | $LogCommandLifecycleEvent $LogEngineHealthEvent $LogEngineLifecycleEvent 1714 | #^ variable.language punctuation 1715 | # ^^^^^^^^^^^^^^^^^^^^^^^^ variable.language - punctuation 1716 | # ^ variable.language punctuation 1717 | # ^^^^^^^^^^^^^^^^^^^^ variable.language - punctuation 1718 | # ^ variable.language punctuation 1719 | # ^^^^^^^^^^^^^^^^^^^^^^^ variable.language - punctuation 1720 | $LogProviderHealthEvent $LogProviderLifecycleEvent $MaximumAliasCount 1721 | #^ variable.language punctuation 1722 | # ^^^^^^^^^^^^^^^^^^^^^^ variable.language - punctuation 1723 | # ^ variable.language punctuation 1724 | # ^^^^^^^^^^^^^^^^^^^^^^^^^ variable.language - punctuation 1725 | # ^ variable.language punctuation 1726 | # ^^^^^^^^^^^^^^^^^ variable.language - punctuation 1727 | $MaximumDriveCount $MaximumErrorCount $MaximumFunctionCount $MaximumHistoryCount 1728 | #^ variable.language punctuation 1729 | # ^^^^^^^^^^^^^^^^^ variable.language - punctuation 1730 | # ^ variable.language punctuation 1731 | # ^^^^^^^^^^^^^^^^^ variable.language - punctuation 1732 | # ^ variable.language punctuation 1733 | # ^^^^^^^^^^^^^^^^^^^^ variable.language - punctuation 1734 | # ^ variable.language punctuation 1735 | # ^^^^^^^^^^^^^^^^^^^ variable.language - punctuation 1736 | $MaximumVariableCount $OFS $OutputEncoding $PSCulture $PSDebugContext 1737 | #^ variable.language punctuation 1738 | # ^^^^^^^^^^^^^^^^^^^^ variable.language - punctuation 1739 | # ^ variable.language punctuation 1740 | # ^^^ variable.language - punctuation 1741 | # ^ variable.language punctuation 1742 | # ^^^^^^^^^^^^^^ variable.language - punctuation 1743 | # ^ variable.language punctuation 1744 | # ^^^^^^^^^ variable.language - punctuation 1745 | # ^ variable.language punctuation 1746 | # ^^^^^^^^^^^^^^ variable.language - punctuation 1747 | $PSDefaultParameterValues $PSEmailServer $PSItem $PSModuleAutoLoadingPreference 1748 | #^ variable.language punctuation 1749 | # ^^^^^^^^^^^^^^^^^^^^^^^^ variable.language - punctuation 1750 | # ^ variable.language punctuation 1751 | # ^^^^^^^^^^^^^ variable.language - punctuation 1752 | # ^ variable.language punctuation 1753 | # ^^^^^^ variable.language - punctuation 1754 | # ^ variable.language punctuation 1755 | # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ variable.language - punctuation 1756 | $PSModuleAutoloadingPreference $PSSenderInfo $PSSessionApplicationName 1757 | #^ variable.language punctuation 1758 | # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ variable.language - punctuation 1759 | # ^ variable.language punctuation 1760 | # ^^^^^^^^^^^^ variable.language - punctuation 1761 | # ^ variable.language punctuation 1762 | # ^^^^^^^^^^^^^^^^^^^^^^^^ variable.language - punctuation 1763 | $PSSessionConfigurationName $PSSessionOption $ProgressPreference 1764 | #^ variable.language punctuation 1765 | # ^^^^^^^^^^^^^^^^^^^^^^^^^^ variable.language - punctuation 1766 | # ^ variable.language punctuation 1767 | # ^^^^^^^^^^^^^^^ variable.language - punctuation 1768 | # ^ variable.language punctuation 1769 | # ^^^^^^^^^^^^^^^^^^ variable.language - punctuation 1770 | $VerbosePreference $WarningPreference $WhatIfPreference 1771 | #^ variable.language punctuation 1772 | # ^^^^^^^^^^^^^^^^^ variable.language - punctuation 1773 | # ^ variable.language punctuation 1774 | # ^^^^^^^^^^^^^^^^^ variable.language - punctuation 1775 | # ^ variable.language punctuation 1776 | # ^^^^^^^^^^^^^^^^ variable.language - punctuation 1777 | <# 1778 | .SYNOPSIS 1779 | #<- comment.block comment.documentation.embedded punctuation.definition.keyword.documentation 1780 | #^^^^^^^^ keyword.other.documentation 1781 | .DESCRIPTION 1782 | #<- comment.block comment.documentation.embedded punctuation.definition.keyword.documentation 1783 | #^^^^^^^^^^^ keyword.other.documentation 1784 | .PARAMETER 1785 | #<- comment.block comment.documentation.embedded punctuation.definition.keyword.documentation 1786 | #^^^^^^^^ keyword.other.documentation 1787 | .EXAMPLE 1788 | #<- comment.block comment.documentation.embedded punctuation.definition.keyword.documentation 1789 | #^^^^^^^ keyword.other.documentation 1790 | .INPUTS 1791 | #<- comment.block comment.documentation.embedded punctuation.definition.keyword.documentation 1792 | #^^^^^^ keyword.other.documentation 1793 | .OUTPUTS 1794 | #<- comment.block comment.documentation.embedded punctuation.definition.keyword.documentation 1795 | #^^^^^^^ keyword.other.documentation 1796 | .NOTES 1797 | #<- comment.block comment.documentation.embedded punctuation.definition.keyword.documentation 1798 | #^^^^^ keyword.other.documentation 1799 | .LINK 1800 | #<- comment.block comment.documentation.embedded punctuation.definition.keyword.documentation 1801 | #^^^^ keyword.other.documentation 1802 | .COMPONENT 1803 | #<- comment.block comment.documentation.embedded punctuation.definition.keyword.documentation 1804 | #^^^^^^^^^ keyword.other.documentation 1805 | .ROLE 1806 | #<- comment.block comment.documentation.embedded punctuation.definition.keyword.documentation 1807 | #^^^^ keyword.other.documentation 1808 | .FUNCTIONALITY 1809 | #<- comment.block comment.documentation.embedded punctuation.definition.keyword.documentation 1810 | #^^^^^^^^^^^^^ keyword.other.documentation 1811 | .FORWARDHELPTARGETNAME 1812 | #<- comment.block comment.documentation.embedded punctuation.definition.keyword.documentation 1813 | #^^^^^^^^^^^^^^^^^^^^^ keyword.other.documentation 1814 | .FORWARDHELPCATEGORY 1815 | #<- comment.block comment.documentation.embedded punctuation.definition.keyword.documentation 1816 | #^^^^^^^^^^^^^^^^^^^ keyword.other.documentation 1817 | .REMOTEHELPRUNSPACE 1818 | #<- comment.block comment.documentation.embedded punctuation.definition.keyword.documentation 1819 | #^^^^^^^^^^^^^^^^^^ keyword.other.documentation 1820 | .EXTERNALHELP 1821 | #<- comment.block comment.documentation.embedded punctuation.definition.keyword.documentation 1822 | #^^^^^^^^^^^^ keyword.other.documentation 1823 | #> 1824 | 1825 | #region Test 1826 | #<- punctuation.definition.comment 1827 | #^^^^^^ keyword.other.region.begin 1828 | #<- comment.line.powershell 1829 | # ^^^^ meta.toc-list entity.name.section 1830 | # @@@@ local-definition 1831 | # ^ meta.fold.begin 1832 | #endregion (More comments) 1833 | #<- punctuation.definition.comment.powershell 1834 | #^^^^^^^^^ keyword.other.region.end.powershell 1835 | #<- comment.line 1836 | # ^ meta.fold.end 1837 | 1838 | #region 1839 | #<- punctuation.definition.comment 1840 | #^^^^^^ keyword.other.region.begin 1841 | #<- comment.line.powershell 1842 | # ^ meta.fold.begin 1843 | #endregion (More comments) 1844 | #<- punctuation.definition.comment.powershell 1845 | #^^^^^^^^^ keyword.other.region.end.powershell 1846 | #<- comment.line 1847 | # ^ meta.fold.end 1848 | -------------------------------------------------------------------------------- /Tests/syntax_test_reindent.ps1: -------------------------------------------------------------------------------- 1 | # SYNTAX TEST reindent "Packages/PowerShell/PowerShell.sublime-syntax" 2 | Function Get-ForegroundWindow { 3 | Add-Type @" 4 | using System; using System.Runtime.InteropServices; public class ClassGetForegroundWindow { 5 | [DllImport("user32.dll")] 6 | public static extern IntPtr GetForegroundWindow(); 7 | } 8 | "@ 9 | 10 | return [ClassGetForegroundWindow]::GetForegroundWindow() 11 | } 12 | 13 | Get-ForegroundWindow 14 | 15 | if ($true) { 16 | Write-Host 'test' 17 | } elseif ($false) { 18 | Write-Host 'test2' 19 | } else { 20 | Write-Host 'test3' 21 | } 22 | -------------------------------------------------------------------------------- /messages.json: -------------------------------------------------------------------------------- 1 | { 2 | "3.1.1": "messages/prerelease-invitation.md" 3 | } 4 | -------------------------------------------------------------------------------- /messages/prerelease-invitation.md: -------------------------------------------------------------------------------- 1 | # Prelease invitation 2 | 3 | Hello PowerShell user. There are improvements underway to bring the 4 | syntax highlighting for PS more in line with the other Sublime Text 5 | languages. This means your color scheme should start highlighting 6 | similar concepts the same colors as you are used to in those other 7 | languages. 8 | 9 | It is not perfect. And, as such, I'm inviting adventurous ST users to 10 | try it out ahead of time. If that sounds like you, open your Package 11 | Control Settings (usually `Cmd/Ctrl`+`Shift`+`P`, "Preferences: Package 12 | Control Settings") and add `"PowerShell"` to the array for 13 | `install_prereleases` in the right-hand pane. 14 | 15 | If you find bugs, especially egregious ones that break code 16 | highlighting further down in the file, please mention them at 17 | https://github.com/SublimeText/PowerShell/issues and include "v4" in 18 | the title. 19 | 20 | Thank you. Be well. 21 | --------------------------------------------------------------------------------