Mercurial > vim
comparison runtime/syntax/ps1.vim @ 24387:5c98ea5f5d6e
Update runtime files
Commit: https://github.com/vim/vim/commit/130cbfc31235c6cb52ffe718ea0a5bb50fbbc9fd
Author: Bram Moolenaar <Bram@vim.org>
Date: Wed Apr 7 21:07:20 2021 +0200
Update runtime files
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Wed, 07 Apr 2021 21:15:05 +0200 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
24386:2e1bd6b629ff | 24387:5c98ea5f5d6e |
---|---|
1 " Vim syntax file | |
2 " Language: Windows PowerShell | |
3 " URL: https://github.com/PProvost/vim-ps1 | |
4 " Last Change: 2020 Nov 24 | |
5 " | |
6 " The following settings are available for tuning syntax highlighting: | |
7 " let ps1_nofold_blocks = 1 | |
8 " let ps1_nofold_sig = 1 | |
9 " let ps1_nofold_region = 1 | |
10 | |
11 if exists("b:current_syntax") | |
12 finish | |
13 endif | |
14 | |
15 " Operators contain dashes | |
16 setlocal iskeyword+=- | |
17 | |
18 " PowerShell doesn't care about case | |
19 syn case ignore | |
20 | |
21 " Sync-ing method | |
22 syn sync minlines=100 | |
23 | |
24 " Certain tokens can't appear at the top level of the document | |
25 syn cluster ps1NotTop contains=@ps1Comment,ps1CDocParam,ps1FunctionDeclaration | |
26 | |
27 " Comments and special comment words | |
28 syn keyword ps1CommentTodo TODO FIXME XXX TBD HACK NOTE contained | |
29 syn match ps1CDocParam /.*/ contained | |
30 syn match ps1CommentDoc /^\s*\zs\.\w\+\>/ nextgroup=ps1CDocParam contained | |
31 syn match ps1CommentDoc /#\s*\zs\.\w\+\>/ nextgroup=ps1CDocParam contained | |
32 syn match ps1Comment /#.*/ contains=ps1CommentTodo,ps1CommentDoc,@Spell | |
33 syn region ps1Comment start="<#" end="#>" contains=ps1CommentTodo,ps1CommentDoc,@Spell | |
34 | |
35 " Language keywords and elements | |
36 syn keyword ps1Conditional if else elseif switch default | |
37 syn keyword ps1Repeat while for do until break continue foreach in | |
38 syn match ps1Repeat /\<foreach\>/ nextgroup=ps1Block skipwhite | |
39 syn match ps1Keyword /\<while\>/ nextgroup=ps1Block skipwhite | |
40 syn match ps1Keyword /\<where\>/ nextgroup=ps1Block skipwhite | |
41 | |
42 syn keyword ps1Exception begin process end exit inlinescript parallel sequence | |
43 syn keyword ps1Keyword try catch finally throw | |
44 syn keyword ps1Keyword return filter in trap param data dynamicparam | |
45 syn keyword ps1Constant $true $false $null | |
46 syn match ps1Constant +\$?+ | |
47 syn match ps1Constant +\$_+ | |
48 syn match ps1Constant +\$\$+ | |
49 syn match ps1Constant +\$^+ | |
50 | |
51 " Keywords reserved for future use | |
52 syn keyword ps1Keyword class define from using var | |
53 | |
54 " Function declarations | |
55 syn keyword ps1Keyword function nextgroup=ps1Function skipwhite | |
56 syn keyword ps1Keyword filter nextgroup=ps1Function skipwhite | |
57 syn keyword ps1Keyword workflow nextgroup=ps1Function skipwhite | |
58 syn keyword ps1Keyword configuration nextgroup=ps1Function skipwhite | |
59 syn keyword ps1Keyword class nextgroup=ps1Function skipwhite | |
60 syn keyword ps1Keyword enum nextgroup=ps1Function skipwhite | |
61 | |
62 " Function declarations and invocations | |
63 syn match ps1Cmdlet /\v(add|clear|close|copy|enter|exit|find|format|get|hide|join|lock|move|new|open|optimize|pop|push|redo|remove|rename|reset|search|select|Set|show|skip|split|step|switch|undo|unlock|watch)(-\w+)+/ contained | |
64 syn match ps1Cmdlet /\v(connect|disconnect|read|receive|send|write)(-\w+)+/ contained | |
65 syn match ps1Cmdlet /\v(backup|checkpoint|compare|compress|convert|convertfrom|convertto|dismount|edit|expand|export|group|import|initialize|limit|merge|mount|out|publish|restore|save|sync|unpublish|update)(-\w+)+/ contained | |
66 syn match ps1Cmdlet /\v(debug|measure|ping|repair|resolve|test|trace)(-\w+)+/ contained | |
67 syn match ps1Cmdlet /\v(approve|assert|build|complete|confirm|deny|deploy|disable|enable|install|invoke|register|request|restart|resume|start|stop|submit|suspend|uninstall|unregister|wait)(-\w+)+/ contained | |
68 syn match ps1Cmdlet /\v(block|grant|protect|revoke|unblock|unprotect)(-\w+)+/ contained | |
69 syn match ps1Cmdlet /\v(use)(-\w+)+/ contained | |
70 | |
71 " Other functions | |
72 syn match ps1Function /\w\+\(-\w\+\)\+/ contains=ps1Cmdlet | |
73 | |
74 " Type declarations | |
75 syn match ps1Type /\[[a-z_][a-z0-9_.,\[\]]\+\]/ | |
76 | |
77 " Variable references | |
78 syn match ps1ScopeModifier /\(global:\|local:\|private:\|script:\)/ contained | |
79 syn match ps1Variable /\$\w\+\(:\w\+\)\?/ contains=ps1ScopeModifier | |
80 syn match ps1Variable /\${\w\+\(:\?[[:alnum:]_()]\+\)\?}/ contains=ps1ScopeModifier | |
81 | |
82 " Operators | |
83 syn keyword ps1Operator -eq -ne -ge -gt -lt -le -like -notlike -match -notmatch -replace -split -contains -notcontains | |
84 syn keyword ps1Operator -ieq -ine -ige -igt -ile -ilt -ilike -inotlike -imatch -inotmatch -ireplace -isplit -icontains -inotcontains | |
85 syn keyword ps1Operator -ceq -cne -cge -cgt -clt -cle -clike -cnotlike -cmatch -cnotmatch -creplace -csplit -ccontains -cnotcontains | |
86 syn keyword ps1Operator -in -notin | |
87 syn keyword ps1Operator -is -isnot -as -join | |
88 syn keyword ps1Operator -and -or -not -xor -band -bor -bnot -bxor | |
89 syn keyword ps1Operator -f | |
90 syn match ps1Operator /!/ | |
91 syn match ps1Operator /=/ | |
92 syn match ps1Operator /+=/ | |
93 syn match ps1Operator /-=/ | |
94 syn match ps1Operator /\*=/ | |
95 syn match ps1Operator /\/=/ | |
96 syn match ps1Operator /%=/ | |
97 syn match ps1Operator /+/ | |
98 syn match ps1Operator /-\(\s\|\d\|\.\|\$\|(\)\@=/ | |
99 syn match ps1Operator /\*/ | |
100 syn match ps1Operator /\// | |
101 syn match ps1Operator /|/ | |
102 syn match ps1Operator /%/ | |
103 syn match ps1Operator /&/ | |
104 syn match ps1Operator /::/ | |
105 syn match ps1Operator /,/ | |
106 syn match ps1Operator /\(^\|\s\)\@<=\. \@=/ | |
107 | |
108 " Regular Strings | |
109 " These aren't precisely correct and could use some work | |
110 syn region ps1String start=/"/ skip=/`"/ end=/"/ contains=@ps1StringSpecial,@Spell | |
111 syn region ps1String start=/'/ skip=/''/ end=/'/ | |
112 | |
113 " Here-Strings | |
114 syn region ps1String start=/@"$/ end=/^"@/ contains=@ps1StringSpecial,@Spell | |
115 syn region ps1String start=/@'$/ end=/^'@/ | |
116 | |
117 " Interpolation | |
118 syn match ps1Escape /`./ | |
119 syn region ps1Interpolation matchgroup=ps1InterpolationDelimiter start="$(" end=")" contained contains=ALLBUT,@ps1NotTop | |
120 syn region ps1NestedParentheses start="(" skip="\\\\\|\\)" matchgroup=ps1Interpolation end=")" transparent contained | |
121 syn cluster ps1StringSpecial contains=ps1Escape,ps1Interpolation,ps1Variable,ps1Boolean,ps1Constant,ps1BuiltIn,@Spell | |
122 | |
123 " Numbers | |
124 syn match ps1Number "\(\<\|-\)\@<=\(0[xX]\x\+\|\d\+\)\([KMGTP][B]\)\=\(\>\|-\)\@=" | |
125 syn match ps1Number "\(\(\<\|-\)\@<=\d\+\.\d*\|\.\d\+\)\([eE][-+]\=\d\+\)\=[dD]\=" | |
126 syn match ps1Number "\<\d\+[eE][-+]\=\d\+[dD]\=\>" | |
127 syn match ps1Number "\<\d\+\([eE][-+]\=\d\+\)\=[dD]\>" | |
128 | |
129 " Constants | |
130 syn match ps1Boolean "$\%(true\|false\)\>" | |
131 syn match ps1Constant /\$null\>/ | |
132 syn match ps1BuiltIn "$^\|$?\|$_\|$\$" | |
133 syn match ps1BuiltIn "$\%(args\|error\|foreach\|home\|input\)\>" | |
134 syn match ps1BuiltIn "$\%(match\(es\)\?\|myinvocation\|host\|lastexitcode\)\>" | |
135 syn match ps1BuiltIn "$\%(ofs\|shellid\|stacktrace\)\>" | |
136 | |
137 " Named Switch | |
138 syn match ps1Label /\s-\w\+/ | |
139 | |
140 " Folding blocks | |
141 if !exists('g:ps1_nofold_blocks') | |
142 syn region ps1Block start=/{/ end=/}/ transparent fold | |
143 endif | |
144 | |
145 if !exists('g:ps1_nofold_region') | |
146 syn region ps1Region start=/#region/ end=/#endregion/ transparent fold keepend extend | |
147 endif | |
148 | |
149 if !exists('g:ps1_nofold_sig') | |
150 syn region ps1Signature start=/# SIG # Begin signature block/ end=/# SIG # End signature block/ transparent fold | |
151 endif | |
152 | |
153 " Setup default color highlighting | |
154 hi def link ps1Number Number | |
155 hi def link ps1Block Block | |
156 hi def link ps1Region Region | |
157 hi def link ps1Exception Exception | |
158 hi def link ps1Constant Constant | |
159 hi def link ps1String String | |
160 hi def link ps1Escape SpecialChar | |
161 hi def link ps1InterpolationDelimiter Delimiter | |
162 hi def link ps1Conditional Conditional | |
163 hi def link ps1Cmdlet Function | |
164 hi def link ps1Function Identifier | |
165 hi def link ps1Variable Identifier | |
166 hi def link ps1Boolean Boolean | |
167 hi def link ps1Constant Constant | |
168 hi def link ps1BuiltIn StorageClass | |
169 hi def link ps1Type Type | |
170 hi def link ps1ScopeModifier StorageClass | |
171 hi def link ps1Comment Comment | |
172 hi def link ps1CommentTodo Todo | |
173 hi def link ps1CommentDoc Tag | |
174 hi def link ps1CDocParam Identifier | |
175 hi def link ps1Operator Operator | |
176 hi def link ps1Repeat Repeat | |
177 hi def link ps1RepeatAndCmdlet Repeat | |
178 hi def link ps1Keyword Keyword | |
179 hi def link ps1KeywordAndCmdlet Keyword | |
180 hi def link ps1Label Label | |
181 | |
182 let b:current_syntax = "ps1" |