%YAML 1.2 --- # http://www.sublimetext.com/docs/3/syntax.html name: PowerShell file_extensions: - ps1 - psm1 - psd1 scope: source.powershell contexts: main: - match: "<#" captures: 0: punctuation.definition.comment.block.begin.powershell push: - meta_scope: comment.block.powershell - match: "#>" captures: 0: punctuation.definition.comment.block.end.powershell pop: true - include: commentEmbeddedDocs - match: '[2-6]>&1|>>|>|<<|<|>|>\||[1-6]>|[1-6]>>' scope: keyword.operator.redirection.powershell - include: commands - include: commentLine - include: variable - include: subexpression - include: function - include: attribute - include: UsingDirective - include: type - include: hashtable - include: doubleQuotedString - include: scriptblock - include: doubleQuotedStringEscapes - match: '[''\x{2018}-\x{201B}]' captures: 0: punctuation.definition.string.begin.powershell push: - meta_scope: string.quoted.single.powershell - match: '[''\x{2018}-\x{201B}]{2}' scope: constant.character.escape.powershell - match: '[''\x{2018}-\x{201B}]' captures: 0: punctuation.definition.string.end.powershell pop: true - match: '(@["\x{201C}-\x{201E}])\s*$' captures: 1: punctuation.definition.string.begin.powershell push: - meta_scope: string.quoted.double.heredoc.powershell - match: '^["\x{201C}-\x{201E}]@' captures: 0: punctuation.definition.string.end.powershell pop: true - include: variableNoProperty - include: doubleQuotedStringEscapes - include: interpolation - match: '(@[''\x{2018}-\x{201B}])\s*$' captures: 1: punctuation.definition.string.begin.powershell push: - meta_scope: string.quoted.single.heredoc.powershell - match: '^[''\x{2018}-\x{201B}]@' captures: 0: punctuation.definition.string.end.powershell pop: true - include: numericConstant - match: (@)(\() captures: 1: keyword.other.array.begin.powershell 2: punctuation.section.group.begin.powershell push: - meta_scope: meta.group.array-expression.powershell - match: \) captures: 0: punctuation.section.group.end.powershell pop: true - include: main - match: ((\$))(\() comment: "TODO: move to repo; make recursive." captures: 1: keyword.other.substatement.powershell 2: punctuation.definition.subexpression.powershell 3: punctuation.section.group.begin.powershell push: - meta_scope: meta.group.complex.subexpression.powershell - match: \) captures: 0: punctuation.section.group.end.powershell pop: true - include: main - match: '(\b(([A-Za-z0-9\-_\.]+)\.(?i:exe|com|cmd|bat))\b)' scope: support.function.powershell - match: (?{1,5})}' scope: constant.character.escape.powershell - match: '`u(?:\{[0-9a-fA-F]{,6}.)?' scope: invalid.character.escape.powershell variable: - match: (\$)(?i:(False|Null|True))\b comment: These are special constants. captures: 0: constant.language.powershell 1: punctuation.definition.variable.powershell - match: '(\$)(?i:(Error|ExecutionContext|Host|Home|PID|PsHome|PsVersionTable|ShellID))((?:\.(?:\p{L}|\d|_)+)*\b)?\b' comment: These are the other built-in constants. captures: 0: support.constant.variable.powershell 1: punctuation.definition.variable.powershell 3: variable.other.member.powershell - match: '(\$)((?:[$^?])|(?i:_|Args|ConsoleFileName|Event|EventArgs|EventSubscriber|ForEach|Input|LastExitCode|Matches|MyInvocation|NestedPromptLevel|Profile|PSBoundParameters|PsCmdlet|PsCulture|PSDebugContext|PSItem|PSCommandPath|PSScriptRoot|PsUICulture|Pwd|Sender|SourceArgs|SourceEventArgs|StackTrace|Switch|This)\b)((?:\.(?:\p{L}|\d|_)+)*\b)?' comment: Automatic variables are not constants, but they are read-only. In monokai (default) color schema support.variable doesn't have color, so we use constant. captures: 0: support.variable.automatic.powershell 1: punctuation.definition.variable.powershell 3: variable.other.member.powershell - match: '(\$)(?i:(ConfirmPreference|DebugPreference|ErrorActionPreference|ErrorView|FormatEnumerationLimit|InformationPreference|LogCommandHealthEvent|LogCommandLifecycleEvent|LogEngineHealthEvent|LogEngineLifecycleEvent|LogProviderHealthEvent|LogProviderLifecycleEvent|MaximumAliasCount|MaximumDriveCount|MaximumErrorCount|MaximumFunctionCount|MaximumHistoryCount|MaximumVariableCount|OFS|OutputEncoding|PSCulture|PSDebugContext|PSDefaultParameterValues|PSEmailServer|PSItem|PSModuleAutoLoadingPreference|PSModuleAutoloadingPreference|PSSenderInfo|PSSessionApplicationName|PSSessionConfigurationName|PSSessionOption|ProgressPreference|VerbosePreference|WarningPreference|WhatIfPreference))((?:\.(?:\p{L}|\d|_)+)*\b)?\b' comment: Style preference variables as language variables so that they stand out. captures: 0: variable.language.powershell 1: punctuation.definition.variable.powershell 3: variable.other.member.powershell - match: '(?i:(\$|@)(global|local|private|script|using|workflow):((?:\p{L}|\d|_)+))((?:\.(?:\p{L}|\d|_)+)*\b)?' captures: 0: variable.other.readwrite.powershell 1: punctuation.definition.variable.powershell 2: storage.modifier.scope.powershell 4: variable.other.member.powershell - match: '(?i:(\$)(\{)(global|local|private|script|using|workflow):([^}]*[^}`])(\}))((?:\.(?:\p{L}|\d|_)+)*\b)?' captures: 0: variable.other.readwrite.powershell 1: punctuation.definition.variable.powershell 2: punctuation.section.braces.begin.powershell 3: storage.modifier.scope.powershell 5: punctuation.section.braces.end.powershell 6: variable.other.member.powershell - match: '(?i:(\$|@)((?:\p{L}|\d|_)+:)?((?:\p{L}|\d|_)+))((?:\.(?:\p{L}|\d|_)+)*\b)?' captures: 0: variable.other.readwrite.powershell 1: punctuation.definition.variable.powershell 2: support.variable.drive.powershell 4: variable.other.member.powershell - match: '(?i:(\$)(\{)((?:\p{L}|\d|_)+:)?([^}]*[^}`])(\}))((?:\.(?:\p{L}|\d|_)+)*\b)?' captures: 0: variable.other.readwrite.powershell 1: punctuation.definition.variable.powershell 2: punctuation.section.braces.begin.powershell 3: support.variable.drive.powershell 5: punctuation.section.braces.end.powershell 6: variable.other.member.powershell variableNoProperty: - match: (\$)(?i:(False|Null|True))\b comment: These are special constants. captures: 0: constant.language.powershell 1: punctuation.definition.variable.powershell - match: (\$)(?i:(Error|ExecutionContext|Host|Home|PID|PsHome|PsVersionTable|ShellID))\b comment: These are the other built-in constants. captures: 0: support.constant.variable.powershell 1: punctuation.definition.variable.powershell 3: variable.other.member.powershell - match: '(\$)((?:[$^?])|(?i:_|Args|ConsoleFileName|Event|EventArgs|EventSubscriber|ForEach|Input|LastExitCode|Matches|MyInvocation|NestedPromptLevel|Profile|PSBoundParameters|PsCmdlet|PsCulture|PSDebugContext|PSItem|PSCommandPath|PSScriptRoot|PsUICulture|Pwd|Sender|SourceArgs|SourceEventArgs|StackTrace|Switch|This)\b)' comment: Automatic variables are not constants, but they are read-only... captures: 0: support.variable.automatic.powershell 1: punctuation.definition.variable.powershell 3: variable.other.member.powershell - match: (\$)(?i:(ConfirmPreference|DebugPreference|ErrorActionPreference|ErrorView|FormatEnumerationLimit|InformationPreference|LogCommandHealthEvent|LogCommandLifecycleEvent|LogEngineHealthEvent|LogEngineLifecycleEvent|LogProviderHealthEvent|LogProviderLifecycleEvent|MaximumAliasCount|MaximumDriveCount|MaximumErrorCount|MaximumFunctionCount|MaximumHistoryCount|MaximumVariableCount|OFS|OutputEncoding|PSCulture|PSDebugContext|PSDefaultParameterValues|PSEmailServer|PSItem|PSModuleAutoLoadingPreference|PSModuleAutoloadingPreference|PSSenderInfo|PSSessionApplicationName|PSSessionConfigurationName|PSSessionOption|ProgressPreference|VerbosePreference|WarningPreference|WhatIfPreference))\b comment: Style preference variables as language variables so that they stand out. captures: 0: variable.language.powershell 1: punctuation.definition.variable.powershell 3: variable.other.member.powershell - match: '(?i:(\$)(global|local|private|script|using|workflow):((?:\p{L}|\d|_)+))' captures: 0: variable.other.readwrite.powershell 1: punctuation.definition.variable.powershell 2: storage.modifier.scope.powershell 4: variable.other.member.powershell - match: '(?i:(\$)(\{)(global|local|private|script|using|workflow):([^}]*[^}`])(\}))' captures: 0: variable.other.readwrite.powershell 1: punctuation.definition.variable.powershell 2: storage.modifier.scope.powershell 4: keyword.other.powershell 5: variable.other.member.powershell - match: '(?i:(\$)((?:\p{L}|\d|_)+:)?((?:\p{L}|\d|_)+))' captures: 0: variable.other.readwrite.powershell 1: punctuation.definition.variable.powershell 2: support.variable.drive.powershell 4: variable.other.member.powershell - match: '(?i:(\$)(\{)((?:\p{L}|\d|_)+:)?([^}]*[^}`])(\}))' captures: 0: variable.other.readwrite.powershell 1: punctuation.definition.variable.powershell 2: punctuation.section.braces.begin 3: support.variable.drive.powershell 5: punctuation.section.braces.end