7
|
1 " Vim syntax file
|
|
2 " Language: Perl
|
1118
|
3 " Maintainer: Nick Hibma <nick@van-laarhoven.org>
|
|
4 " Last Change: 2006 November 23
|
7
|
5 " Location: http://www.van-laarhoven.org/vim/syntax/perl.vim
|
|
6 "
|
|
7 " Please download most recent version first before mailing
|
|
8 " any comments.
|
|
9 " See also the file perl.vim.regression.pl to check whether your
|
|
10 " modifications work in the most odd cases
|
|
11 " http://www.van-laarhoven.org/vim/syntax/perl.vim.regression.pl
|
|
12 "
|
|
13 " Original version: Sonia Heimann <niania@netsurf.org>
|
|
14 " Thanks to many people for their contribution.
|
|
15
|
|
16 " The following parameters are available for tuning the
|
|
17 " perl syntax highlighting, with defaults given:
|
|
18 "
|
|
19 " unlet perl_include_pod
|
1118
|
20 " unlet perl_want_scope_in_variables
|
|
21 " unlet perl_extended_vars
|
7
|
22 " unlet perl_string_as_statement
|
|
23 " unlet perl_no_sync_on_sub
|
|
24 " unlet perl_no_sync_on_global_var
|
|
25 " let perl_sync_dist = 100
|
|
26 " unlet perl_fold
|
|
27 " unlet perl_fold_blocks
|
1118
|
28 " let perl_nofold_packages = 1
|
|
29 " let perl_nofold_subs = 1
|
7
|
30
|
|
31 " Remove any old syntax stuff that was loaded (5.x) or quit when a syntax file
|
|
32 " was already loaded (6.x).
|
|
33 if version < 600
|
|
34 syntax clear
|
|
35 elseif exists("b:current_syntax")
|
|
36 finish
|
|
37 endif
|
|
38
|
|
39 " Unset perl_fold if it set but vim doesn't support it.
|
|
40 if version < 600 && exists("perl_fold")
|
|
41 unlet perl_fold
|
|
42 endif
|
|
43
|
|
44
|
|
45 " POD starts with ^=<word> and ends with ^=cut
|
|
46
|
|
47 if exists("perl_include_pod")
|
|
48 " Include a while extra syntax file
|
|
49 syn include @Pod syntax/pod.vim
|
|
50 unlet b:current_syntax
|
|
51 if exists("perl_fold")
|
557
|
52 syn region perlPOD start="^=[a-z]" end="^=cut" contains=@Pod,@Spell,perlTodo keepend fold
|
7
|
53 syn region perlPOD start="^=cut" end="^=cut" contains=perlTodo keepend fold
|
|
54 else
|
557
|
55 syn region perlPOD start="^=[a-z]" end="^=cut" contains=@Pod,@Spell,perlTodo keepend
|
7
|
56 syn region perlPOD start="^=cut" end="^=cut" contains=perlTodo keepend
|
|
57 endif
|
|
58 else
|
|
59 " Use only the bare minimum of rules
|
|
60 if exists("perl_fold")
|
1118
|
61 syn region perlPOD start="^=[a-z]" end="^=cut" fold
|
7
|
62 else
|
1118
|
63 syn region perlPOD start="^=[a-z]" end="^=cut"
|
7
|
64 endif
|
|
65 endif
|
|
66
|
|
67
|
|
68 " All keywords
|
|
69 "
|
|
70 if exists("perl_fold") && exists("perl_fold_blocks")
|
|
71 syn match perlConditional "\<if\>"
|
|
72 syn match perlConditional "\<elsif\>"
|
|
73 syn match perlConditional "\<unless\>"
|
|
74 syn match perlConditional "\<else\>" nextgroup=perlElseIfError skipwhite skipnl skipempty
|
|
75 else
|
|
76 syn keyword perlConditional if elsif unless
|
|
77 syn keyword perlConditional else nextgroup=perlElseIfError skipwhite skipnl skipempty
|
|
78 endif
|
|
79 syn keyword perlConditional switch eq ne gt lt ge le cmp not and or xor err
|
|
80 if exists("perl_fold") && exists("perl_fold_blocks")
|
|
81 syn match perlRepeat "\<while\>"
|
|
82 syn match perlRepeat "\<for\>"
|
|
83 syn match perlRepeat "\<foreach\>"
|
|
84 syn match perlRepeat "\<do\>"
|
|
85 syn match perlRepeat "\<until\>"
|
|
86 syn match perlRepeat "\<continue\>"
|
|
87 else
|
|
88 syn keyword perlRepeat while for foreach do until continue
|
|
89 endif
|
|
90 syn keyword perlOperator defined undef and or not bless ref
|
|
91 if exists("perl_fold")
|
1118
|
92 " if BEGIN/END would be a keyword the perlBEGINENDFold does not work
|
|
93 syn match perlControl "\<BEGIN\|CHECK\|INIT\|END\>" contained
|
7
|
94 else
|
548
|
95 syn keyword perlControl BEGIN END CHECK INIT
|
7
|
96 endif
|
|
97
|
|
98 syn keyword perlStatementStorage my local our
|
|
99 syn keyword perlStatementControl goto return last next redo
|
|
100 syn keyword perlStatementScalar chomp chop chr crypt index lc lcfirst length ord pack reverse rindex sprintf substr uc ucfirst
|
|
101 syn keyword perlStatementRegexp pos quotemeta split study
|
|
102 syn keyword perlStatementNumeric abs atan2 cos exp hex int log oct rand sin sqrt srand
|
|
103 syn keyword perlStatementList splice unshift shift push pop split join reverse grep map sort unpack
|
|
104 syn keyword perlStatementHash each exists keys values tie tied untie
|
|
105 syn keyword perlStatementIOfunc carp confess croak dbmclose dbmopen die syscall
|
|
106 syn keyword perlStatementFiledesc binmode close closedir eof fileno getc lstat print printf readdir readline readpipe rewinddir select stat tell telldir write nextgroup=perlFiledescStatementNocomma skipwhite
|
|
107 syn keyword perlStatementFiledesc fcntl flock ioctl open opendir read seek seekdir sysopen sysread sysseek syswrite truncate nextgroup=perlFiledescStatementComma skipwhite
|
|
108 syn keyword perlStatementVector pack vec
|
|
109 syn keyword perlStatementFiles chdir chmod chown chroot glob link mkdir readlink rename rmdir symlink umask unlink utime
|
|
110 syn match perlStatementFiles "-[rwxoRWXOezsfdlpSbctugkTBMAC]\>"
|
|
111 syn keyword perlStatementFlow caller die dump eval exit wantarray
|
|
112 syn keyword perlStatementInclude require
|
1118
|
113 syn match perlStatementInclude "\<\(use\|no\)\s\+\(\(integer\|strict\|lib\|sigtrap\|subs\|vars\|warnings\|utf8\|byte\|base\|fields\)\>\)\="
|
|
114 syn keyword perlStatementScope import
|
7
|
115 syn keyword perlStatementProc alarm exec fork getpgrp getppid getpriority kill pipe setpgrp setpriority sleep system times wait waitpid
|
|
116 syn keyword perlStatementSocket accept bind connect getpeername getsockname getsockopt listen recv send setsockopt shutdown socket socketpair
|
|
117 syn keyword perlStatementIPC msgctl msgget msgrcv msgsnd semctl semget semop shmctl shmget shmread shmwrite
|
|
118 syn keyword perlStatementNetwork endhostent endnetent endprotoent endservent gethostbyaddr gethostbyname gethostent getnetbyaddr getnetbyname getnetent getprotobyname getprotobynumber getprotoent getservbyname getservbyport getservent sethostent setnetent setprotoent setservent
|
|
119 syn keyword perlStatementPword getpwuid getpwnam getpwent setpwent endpwent getgrent getgrgid getlogin getgrnam setgrent endgrent
|
|
120 syn keyword perlStatementTime gmtime localtime time times
|
|
121
|
|
122 syn keyword perlStatementMisc warn formline reset scalar delete prototype lock
|
1118
|
123 syn keyword perlStatementNew new
|
|
124
|
7
|
125 syn keyword perlTodo TODO TBD FIXME XXX contained
|
|
126
|
|
127 " Perl Identifiers.
|
|
128 "
|
|
129 " Should be cleaned up to better handle identifiers in particular situations
|
|
130 " (in hash keys for example)
|
|
131 "
|
|
132 " Plain identifiers: $foo, @foo, $#foo, %foo, &foo and dereferences $$foo, @$foo, etc.
|
|
133 " We do not process complex things such as @{${"foo"}}. Too complicated, and
|
|
134 " too slow. And what is after the -> is *not* considered as part of the
|
|
135 " variable - there again, too complicated and too slow.
|
|
136
|
|
137 " Special variables first ($^A, ...) and ($|, $', ...)
|
|
138 syn match perlVarPlain "$^[ADEFHILMOPSTWX]\="
|
1118
|
139 syn match perlVarPlain "$[\\\"\[\]'&`+*.,;=%~!?@#$<>(-]"
|
|
140 syn match perlVarPlain "$\(0\|[1-9][0-9]*\)"
|
7
|
141 " Same as above, but avoids confusion in $::foo (equivalent to $main::foo)
|
|
142 syn match perlVarPlain "$:[^:]"
|
|
143 " These variables are not recognized within matches.
|
|
144 syn match perlVarNotInMatches "$[|)]"
|
1118
|
145 " This variable is not recognized within matches delimited by m//.
|
7
|
146 syn match perlVarSlash "$/"
|
|
147
|
|
148 " And plain identifiers
|
|
149 syn match perlPackageRef "\(\h\w*\)\=\(::\|'\)\I"me=e-1 contained
|
|
150
|
1118
|
151 " To highlight packages in variables as a scope reference - i.e. in $pack::var,
|
|
152 " pack:: is a scope, just set "perl_want_scope_in_variables"
|
|
153 " If you *want* complex things like @{${"foo"}} to be processed,
|
|
154 " just set the variable "perl_extended_vars"...
|
|
155
|
7
|
156 " FIXME value between {} should be marked as string. is treated as such by Perl.
|
|
157 " At the moment it is marked as something greyish instead of read. Probably todo
|
|
158 " with transparency. Or maybe we should handle the bare word in that case. or make it into
|
|
159
|
1118
|
160 if exists("perl_want_scope_in_variables")
|
|
161 syn match perlVarPlain "\\\=\([@$]\|\$#\)\$*\(\I\i*\)\=\(\(::\|'\)\I\i*\)*\>" contains=perlPackageRef nextgroup=perlVarMember,perlVarSimpleMember,perlMethod
|
|
162 syn match perlVarPlain2 "\\\=%\$*\(\I\i*\)\=\(\(::\|'\)\I\i*\)*\>" contains=perlPackageRef nextgroup=perlVarMember,perlVarSimpleMember,perlMethod
|
7
|
163 syn match perlFunctionName "\\\=&\$*\(\I\i*\)\=\(\(::\|'\)\I\i*\)*\>" contains=perlPackageRef nextgroup=perlVarMember,perlVarSimpleMember
|
|
164 else
|
1118
|
165 syn match perlVarPlain "\\\=\([@$]\|\$#\)\$*\(\I\i*\)\=\(\(::\|'\)\I\i*\)*\>" nextgroup=perlVarMember,perlVarSimpleMember,perlMethod
|
|
166 syn match perlVarPlain2 "\\\=%\$*\(\I\i*\)\=\(\(::\|'\)\I\i*\)*\>" nextgroup=perlVarMember,perlVarSimpleMember,perlMethod
|
7
|
167 syn match perlFunctionName "\\\=&\$*\(\I\i*\)\=\(\(::\|'\)\I\i*\)*\>" nextgroup=perlVarMember,perlVarSimpleMember
|
|
168 endif
|
|
169
|
1118
|
170 if exists("perl_extended_vars")
|
|
171 syn cluster perlExpr contains=perlStatementScalar,perlStatementRegexp,perlStatementNumeric,perlStatementList,perlStatementHash,perlStatementFiles,perlStatementTime,perlStatementMisc,perlVarPlain,perlVarPlain2,perlVarNotInMatches,perlVarSlash,perlVarBlock,perlShellCommand,perlFloat,perlNumber,perlStringUnexpanded,perlString,perlQQ
|
7
|
172 syn region perlVarBlock matchgroup=perlVarPlain start="\($#\|[@%$]\)\$*{" skip="\\}" end="}" contains=@perlExpr nextgroup=perlVarMember,perlVarSimpleMember
|
|
173 syn region perlVarBlock matchgroup=perlVarPlain start="&\$*{" skip="\\}" end="}" contains=@perlExpr
|
|
174 syn match perlVarPlain "\\\=\(\$#\|[@%&$]\)\$*{\I\i*}" nextgroup=perlVarMember,perlVarSimpleMember
|
|
175 syn region perlVarMember matchgroup=perlVarPlain start="\(->\)\={" skip="\\}" end="}" contained contains=@perlExpr nextgroup=perlVarMember,perlVarSimpleMember
|
|
176 syn match perlVarSimpleMember "\(->\)\={\I\i*}" nextgroup=perlVarMember,perlVarSimpleMember contains=perlVarSimpleMemberName contained
|
|
177 syn match perlVarSimpleMemberName "\I\i*" contained
|
|
178 syn region perlVarMember matchgroup=perlVarPlain start="\(->\)\=\[" skip="\\]" end="]" contained contains=@perlExpr nextgroup=perlVarMember,perlVarSimpleMember
|
|
179 syn match perlMethod "\(->\)\I\i*" contained
|
|
180 endif
|
|
181
|
|
182 " File Descriptors
|
|
183 syn match perlFiledescRead "[<]\h\w\+[>]"
|
|
184
|
|
185 syn match perlFiledescStatementComma "(\=\s*\u\w*\s*,"me=e-1 transparent contained contains=perlFiledescStatement
|
1118
|
186 syn match perlFiledescStatementNocomma "(\=\s*\u\w*\s*[^, \t]"me=e-1 transparent contained contains=perlFiledescStatement
|
7
|
187
|
|
188 syn match perlFiledescStatement "\u\w*" contained
|
|
189
|
|
190 " Special characters in strings and matches
|
|
191 syn match perlSpecialString "\\\(\d\+\|[xX]\x\+\|c\u\|.\)" contained
|
|
192 syn match perlSpecialStringU "\\['\\]" contained
|
1118
|
193 syn match perlSpecialMatch "{\d\+\(,\(\d\+\)\=\)\=}" contained
|
7
|
194 syn match perlSpecialMatch "\[\(\]\|-\)\=[^\[\]]*\(\[\|\-\)\=\]" contained
|
|
195 syn match perlSpecialMatch "[+*()?.]" contained
|
|
196 syn match perlSpecialMatch "(?[#:=!]" contained
|
|
197 syn match perlSpecialMatch "(?[imsx]\+)" contained
|
|
198 " FIXME the line below does not work. It should mark end of line and
|
|
199 " begin of line as perlSpecial.
|
|
200 " syn match perlSpecialBEOM "^\^\|\$$" contained
|
|
201
|
|
202 " Possible errors
|
|
203 "
|
|
204 " Highlight lines with only whitespace (only in blank delimited here documents) as errors
|
|
205 syn match perlNotEmptyLine "^\s\+$" contained
|
|
206 " Highlight '} else if (...) {', it should be '} else { if (...) { ' or
|
|
207 " '} elsif (...) {'.
|
|
208 "syn keyword perlElseIfError if contained
|
|
209
|
|
210 " Variable interpolation
|
|
211 "
|
|
212 " These items are interpolated inside "" strings and similar constructs.
|
1118
|
213 syn cluster perlInterpDQ contains=perlSpecialString,perlVarPlain,perlVarNotInMatches,perlVarSlash,perlVarBlock
|
7
|
214 " These items are interpolated inside '' strings and similar constructs.
|
|
215 syn cluster perlInterpSQ contains=perlSpecialStringU
|
|
216 " These items are interpolated inside m// matches and s/// substitutions.
|
|
217 syn cluster perlInterpSlash contains=perlSpecialString,perlSpecialMatch,perlVarPlain,perlVarBlock,perlSpecialBEOM
|
|
218 " These items are interpolated inside m## matches and s### substitutions.
|
1118
|
219 syn cluster perlInterpMatch contains=@perlInterpSlash,perlVarSlash
|
7
|
220
|
|
221 " Shell commands
|
|
222 syn region perlShellCommand matchgroup=perlMatchStartEnd start="`" end="`" contains=@perlInterpDQ
|
|
223
|
|
224 " Constants
|
|
225 "
|
|
226 " Numbers
|
|
227 syn match perlNumber "[-+]\=\(\<\d[[:digit:]_]*L\=\>\|0[xX]\x[[:xdigit:]_]*\>\)"
|
|
228 syn match perlFloat "[-+]\=\<\d[[:digit:]_]*[eE][\-+]\=\d\+"
|
|
229 syn match perlFloat "[-+]\=\<\d[[:digit:]_]*\.[[:digit:]_]*\([eE][\-+]\=\d\+\)\="
|
|
230 syn match perlFloat "[-+]\=\<\.[[:digit:]_]\+\([eE][\-+]\=\d\+\)\="
|
|
231
|
|
232
|
|
233 " Simple version of searches and matches
|
|
234 " caters for m//, m##, m{} and m[] (and the !/ variant)
|
|
235 syn region perlMatch matchgroup=perlMatchStartEnd start=+[m!]/+ end=+/[cgimosx]*+ contains=@perlInterpSlash
|
|
236 syn region perlMatch matchgroup=perlMatchStartEnd start=+[m!]#+ end=+#[cgimosx]*+ contains=@perlInterpMatch
|
|
237 syn region perlMatch matchgroup=perlMatchStartEnd start=+[m!]{+ end=+}[cgimosx]*+ contains=@perlInterpMatch
|
|
238 syn region perlMatch matchgroup=perlMatchStartEnd start=+[m!]\[+ end=+\][cgimosx]*+ contains=@perlInterpMatch
|
|
239
|
|
240 " A special case for m!!x which allows for comments and extra whitespace in the pattern
|
|
241 syn region perlMatch matchgroup=perlMatchStartEnd start=+[m!]!+ end=+![cgimosx]*+ contains=@perlInterpSlash,perlComment
|
|
242
|
|
243 " Below some hacks to recognise the // variant. This is virtually impossible to catch in all
|
|
244 " cases as the / is used in so many other ways, but these should be the most obvious ones.
|
1118
|
245 syn region perlMatch matchgroup=perlMatchStartEnd start=+^split /+lc=5 start=+[^$@%]\<split /+lc=6 start=+^while /+lc=5 start=+[^$@%]\<while /+lc=6 start=+^if /+lc=2 start=+[^$@%]\<if /+lc=3 start=+[!=]\~\s*/+lc=2 start=+[(~]/+lc=1 start=+\.\./+lc=2 start=+\s/[^= \t0-9$@%]+lc=1,me=e-1,rs=e-1 start=+^/+ skip=+\\/+ end=+/[cgimosx]*+ contains=@perlInterpSlash
|
7
|
246
|
|
247
|
|
248 " Substitutions
|
|
249 " caters for s///, s### and s[][]
|
|
250 " perlMatch is the first part, perlSubstitution* is the substitution part
|
|
251 syn region perlMatch matchgroup=perlMatchStartEnd start=+\<s'+ end=+'+me=e-1 contains=@perlInterpSQ nextgroup=perlSubstitutionSQ
|
|
252 syn region perlMatch matchgroup=perlMatchStartEnd start=+\<s"+ end=+"+me=e-1 contains=@perlInterpMatch nextgroup=perlSubstitutionDQ
|
|
253 syn region perlMatch matchgroup=perlMatchStartEnd start=+\<s/+ end=+/+me=e-1 contains=@perlInterpSlash nextgroup=perlSubstitutionSlash
|
|
254 syn region perlMatch matchgroup=perlMatchStartEnd start=+\<s#+ end=+#+me=e-1 contains=@perlInterpMatch nextgroup=perlSubstitutionHash
|
|
255 syn region perlMatch matchgroup=perlMatchStartEnd start=+\<s\[+ end=+\]+ contains=@perlInterpMatch nextgroup=perlSubstitutionBracket skipwhite skipempty skipnl
|
|
256 syn region perlMatch matchgroup=perlMatchStartEnd start=+\<s{+ end=+}+ contains=@perlInterpMatch nextgroup=perlSubstitutionCurly skipwhite skipempty skipnl
|
|
257 syn region perlSubstitutionSQ matchgroup=perlMatchStartEnd start=+'+ end=+'[ecgimosx]*+ contained contains=@perlInterpSQ
|
|
258 syn region perlSubstitutionDQ matchgroup=perlMatchStartEnd start=+"+ end=+"[ecgimosx]*+ contained contains=@perlInterpDQ
|
|
259 syn region perlSubstitutionSlash matchgroup=perlMatchStartEnd start=+/+ end=+/[ecgimosx]*+ contained contains=@perlInterpDQ
|
|
260 syn region perlSubstitutionHash matchgroup=perlMatchStartEnd start=+#+ end=+#[ecgimosx]*+ contained contains=@perlInterpDQ
|
|
261 syn region perlSubstitutionBracket matchgroup=perlMatchStartEnd start=+\[+ end=+\][ecgimosx]*+ contained contains=@perlInterpDQ
|
|
262 syn region perlSubstitutionCurly matchgroup=perlMatchStartEnd start=+{+ end=+}[ecgimosx]*+ contained contains=@perlInterpDQ
|
|
263
|
1118
|
264 " A special case for m!!x which allows for comments and extra whitespace in the pattern
|
7
|
265 syn region perlMatch matchgroup=perlMatchStartEnd start=+\<s!+ end=+!+me=e-1 contains=@perlInterpSlash,perlComment nextgroup=perlSubstitutionPling
|
|
266 syn region perlSubstitutionPling matchgroup=perlMatchStartEnd start=+!+ end=+![ecgimosx]*+ contained contains=@perlInterpDQ
|
|
267
|
|
268 " Substitutions
|
|
269 " caters for tr///, tr### and tr[][]
|
|
270 " perlMatch is the first part, perlTranslation* is the second, translator part.
|
|
271 syn region perlMatch matchgroup=perlMatchStartEnd start=+\<\(tr\|y\)'+ end=+'+me=e-1 contains=@perlInterpSQ nextgroup=perlTranslationSQ
|
|
272 syn region perlMatch matchgroup=perlMatchStartEnd start=+\<\(tr\|y\)"+ end=+"+me=e-1 contains=@perlInterpSQ nextgroup=perlTranslationDQ
|
|
273 syn region perlMatch matchgroup=perlMatchStartEnd start=+\<\(tr\|y\)/+ end=+/+me=e-1 contains=@perlInterpSQ nextgroup=perlTranslationSlash
|
|
274 syn region perlMatch matchgroup=perlMatchStartEnd start=+\<\(tr\|y\)#+ end=+#+me=e-1 contains=@perlInterpSQ nextgroup=perlTranslationHash
|
|
275 syn region perlMatch matchgroup=perlMatchStartEnd start=+\<\(tr\|y\)\[+ end=+\]+ contains=@perlInterpSQ nextgroup=perlTranslationBracket skipwhite skipempty skipnl
|
|
276 syn region perlMatch matchgroup=perlMatchStartEnd start=+\<\(tr\|y\){+ end=+}+ contains=@perlInterpSQ nextgroup=perlTranslationCurly skipwhite skipempty skipnl
|
|
277 syn region perlTranslationSQ matchgroup=perlMatchStartEnd start=+'+ end=+'[cds]*+ contained
|
|
278 syn region perlTranslationDQ matchgroup=perlMatchStartEnd start=+"+ end=+"[cds]*+ contained
|
|
279 syn region perlTranslationSlash matchgroup=perlMatchStartEnd start=+/+ end=+/[cds]*+ contained
|
|
280 syn region perlTranslationHash matchgroup=perlMatchStartEnd start=+#+ end=+#[cds]*+ contained
|
|
281 syn region perlTranslationBracket matchgroup=perlMatchStartEnd start=+\[+ end=+\][cds]*+ contained
|
|
282 syn region perlTranslationCurly matchgroup=perlMatchStartEnd start=+{+ end=+}[cds]*+ contained
|
|
283
|
|
284
|
|
285 " The => operator forces a bareword to the left of it to be interpreted as
|
|
286 " a string
|
|
287 syn match perlString "\<\I\i*\s*=>"me=e-2
|
|
288
|
|
289 " Strings and q, qq, qw and qr expressions
|
|
290
|
1118
|
291 " Brackets in qq()
|
|
292 syn region perlBrackets start=+(+ end=+)+ contained transparent contains=perlBrackets,@perlStringSQ
|
7
|
293
|
1118
|
294 syn region perlStringUnexpanded matchgroup=perlStringStartEnd start="'" end="'" contains=@perlInterpSQ
|
|
295 syn region perlString matchgroup=perlStringStartEnd start=+"+ end=+"+ contains=@perlInterpDQ
|
7
|
296 syn region perlQQ matchgroup=perlStringStartEnd start=+\<q#+ end=+#+ contains=@perlInterpSQ
|
|
297 syn region perlQQ matchgroup=perlStringStartEnd start=+\<q|+ end=+|+ contains=@perlInterpSQ
|
1118
|
298 syn region perlQQ matchgroup=perlStringStartEnd start=+\<q(+ end=+)+ contains=@perlInterpSQ,perlBrackets
|
7
|
299 syn region perlQQ matchgroup=perlStringStartEnd start=+\<q{+ end=+}+ contains=@perlInterpSQ
|
|
300 syn region perlQQ matchgroup=perlStringStartEnd start=+\<q/+ end=+/+ contains=@perlInterpSQ
|
|
301 syn region perlQQ matchgroup=perlStringStartEnd start=+\<q[qx]#+ end=+#+ contains=@perlInterpDQ
|
|
302 syn region perlQQ matchgroup=perlStringStartEnd start=+\<q[qx]|+ end=+|+ contains=@perlInterpDQ
|
1118
|
303 syn region perlQQ matchgroup=perlStringStartEnd start=+\<q[qx](+ end=+)+ contains=@perlInterpDQ,perlBrackets
|
7
|
304 syn region perlQQ matchgroup=perlStringStartEnd start=+\<q[qx]{+ end=+}+ contains=@perlInterpDQ
|
|
305 syn region perlQQ matchgroup=perlStringStartEnd start=+\<q[qx]/+ end=+/+ contains=@perlInterpDQ
|
|
306 syn region perlQQ matchgroup=perlStringStartEnd start=+\<qw#+ end=+#+ contains=@perlInterpSQ
|
|
307 syn region perlQQ matchgroup=perlStringStartEnd start=+\<qw|+ end=+|+ contains=@perlInterpSQ
|
1118
|
308 syn region perlQQ matchgroup=perlStringStartEnd start=+\<qw(+ end=+)+ contains=@perlInterpSQ,perlBrackets
|
7
|
309 syn region perlQQ matchgroup=perlStringStartEnd start=+\<qw{+ end=+}+ contains=@perlInterpSQ
|
|
310 syn region perlQQ matchgroup=perlStringStartEnd start=+\<qw/+ end=+/+ contains=@perlInterpSQ
|
|
311 syn region perlQQ matchgroup=perlStringStartEnd start=+\<qr#+ end=+#[imosx]*+ contains=@perlInterpMatch
|
|
312 syn region perlQQ matchgroup=perlStringStartEnd start=+\<qr|+ end=+|[imosx]*+ contains=@perlInterpMatch
|
|
313 syn region perlQQ matchgroup=perlStringStartEnd start=+\<qr(+ end=+)[imosx]*+ contains=@perlInterpMatch
|
|
314 syn region perlQQ matchgroup=perlStringStartEnd start=+\<qr{+ end=+}[imosx]*+ contains=@perlInterpMatch
|
|
315 syn region perlQQ matchgroup=perlStringStartEnd start=+\<qr/+ end=+/[imosx]*+ contains=@perlInterpSlash
|
|
316
|
|
317 " Constructs such as print <<EOF [...] EOF, 'here' documents
|
|
318 "
|
|
319 if version >= 600
|
|
320 " XXX Any statements after the identifier are in perlString colour (i.e.
|
|
321 " 'if $a' in 'print <<EOF if $a').
|
|
322 if exists("perl_fold")
|
1118
|
323 syn region perlHereDoc matchgroup=perlStringStartEnd start=+<<\z(\I\i*\).*+ end=+^\z1$+ contains=@perlInterpDQ fold
|
7
|
324 syn region perlHereDoc matchgroup=perlStringStartEnd start=+<<\s*"\z(.\{-}\)"+ end=+^\z1$+ contains=@perlInterpDQ fold
|
|
325 syn region perlHereDoc matchgroup=perlStringStartEnd start=+<<\s*'\z(.\{-}\)'+ end=+^\z1$+ contains=@perlInterpSQ fold
|
1118
|
326 syn region perlHereDoc matchgroup=perlStringStartEnd start=+<<\s*""+ end=+^$+ contains=@perlInterpDQ,perlNotEmptyLine fold
|
|
327 syn region perlHereDoc matchgroup=perlStringStartEnd start=+<<\s*''+ end=+^$+ contains=@perlInterpSQ,perlNotEmptyLine fold
|
7
|
328 syn region perlAutoload matchgroup=perlStringStartEnd start=+<<['"]\z(END_\(SUB\|OF_FUNC\|OF_AUTOLOAD\)\)['"]+ end=+^\z1$+ contains=ALL fold
|
|
329 else
|
1118
|
330 syn region perlHereDoc matchgroup=perlStringStartEnd start=+<<\z(\I\i*\)+ end=+^\z1$+ contains=@perlInterpDQ
|
7
|
331 syn region perlHereDoc matchgroup=perlStringStartEnd start=+<<\s*"\z(.\{-}\)"+ end=+^\z1$+ contains=@perlInterpDQ
|
|
332 syn region perlHereDoc matchgroup=perlStringStartEnd start=+<<\s*'\z(.\{-}\)'+ end=+^\z1$+ contains=@perlInterpSQ
|
1118
|
333 syn region perlHereDoc matchgroup=perlStringStartEnd start=+<<\s*""+ end=+^$+ contains=@perlInterpDQ,perlNotEmptyLine
|
|
334 syn region perlHereDoc matchgroup=perlStringStartEnd start=+<<\s*''+ end=+^$+ contains=@perlInterpSQ,perlNotEmptyLine
|
7
|
335 syn region perlAutoload matchgroup=perlStringStartEnd start=+<<\(['"]\|\)\z(END_\(SUB\|OF_FUNC\|OF_AUTOLOAD\)\)\1+ end=+^\z1$+ contains=ALL
|
|
336 endif
|
|
337 else
|
|
338 syn match perlUntilEOFStart "<<EOF.*"lc=5 nextgroup=perlUntilEOFDQ skipnl transparent
|
|
339 syn match perlUntilEOFStart "<<\s*\"EOF\".*" nextgroup=perlUntilEOFDQ skipnl transparent
|
|
340 syn match perlUntilEOFStart "<<\s*'EOF'.*" nextgroup=perlUntilEOFSQ skipnl transparent
|
|
341 syn match perlUntilEOFStart "<<\s*\"\".*" nextgroup=perlUntilEmptyDQ skipnl transparent
|
|
342 syn match perlUntilEOFStart "<<\s*''.*" nextgroup=perlUntilEmptySQ skipnl transparent
|
|
343 syn region perlUntilEOFDQ matchgroup=perlStringStartEnd start=++ end="^EOF$" contains=@perlInterpDQ contained
|
|
344 syn region perlUntilEOFSQ matchgroup=perlStringStartEnd start=++ end="^EOF$" contains=@perlInterpSQ contained
|
|
345 syn region perlUntilEmptySQ matchgroup=perlStringStartEnd start=++ end="^$" contains=@perlInterpDQ,perlNotEmptyLine contained
|
|
346 syn region perlUntilEmptyDQ matchgroup=perlStringStartEnd start=++ end="^$" contains=@perlInterpSQ,perlNotEmptyLine contained
|
|
347 syn match perlHereIdentifier "<<EOF"
|
|
348 syn region perlAutoload matchgroup=perlStringStartEnd start=+<<\(['"]\|\)\(END_\(SUB\|OF_FUNC\|OF_AUTOLOAD\)\)\1+ end=+^\(END_\(SUB\|OF_FUNC\|OF_AUTOLOAD\)\)$+ contains=ALL
|
|
349 endif
|
|
350
|
|
351
|
|
352 " Class declarations
|
|
353 "
|
|
354 syn match perlPackageDecl "^\s*\<package\s\+\S\+" contains=perlStatementPackage
|
|
355 syn keyword perlStatementPackage package contained
|
|
356
|
|
357 " Functions
|
|
358 " sub [name] [(prototype)] {
|
|
359 "
|
|
360 syn region perlFunction start="\s*\<sub\>" end="[;{]"he=e-1 contains=perlStatementSub,perlFunctionPrototype,perlFunctionPRef,perlFunctionName,perlComment
|
|
361 syn keyword perlStatementSub sub contained
|
|
362
|
|
363 syn match perlFunctionPrototype "([^)]*)" contained
|
1118
|
364 if exists("perl_want_scope_in_variables")
|
7
|
365 syn match perlFunctionPRef "\h\w*::" contained
|
|
366 syn match perlFunctionName "\h\w*[^:]" contained
|
|
367 else
|
|
368 syn match perlFunctionName "\h[[:alnum:]_:]*" contained
|
|
369 endif
|
|
370
|
|
371 " All other # are comments, except ^#!
|
1118
|
372 syn match perlComment "#.*" contains=perlTodo
|
7
|
373 syn match perlSharpBang "^#!.*"
|
|
374
|
|
375 " Formats
|
1118
|
376 syn region perlFormat matchgroup=perlStatementIOFunc start="^\s*\<format\s\+\k\+\s*=\s*$"rs=s+6 end="^\s*\.\s*$" contains=perlFormatName,perlFormatField,perlVarPlain,perlVarPlain2
|
7
|
377 syn match perlFormatName "format\s\+\k\+\s*="lc=7,me=e-1 contained
|
|
378 syn match perlFormatField "[@^][|<>~]\+\(\.\.\.\)\=" contained
|
|
379 syn match perlFormatField "[@^]#[#.]*" contained
|
|
380 syn match perlFormatField "@\*" contained
|
|
381 syn match perlFormatField "@[^A-Za-z_|<>~#*]"me=e-1 contained
|
|
382 syn match perlFormatField "@$" contained
|
|
383
|
|
384 " __END__ and __DATA__ clauses
|
|
385 if exists("perl_fold")
|
|
386 syntax region perlDATA start="^__\(DATA\|END\)__$" skip="." end="." contains=perlPOD,@perlDATA fold
|
|
387 else
|
|
388 syntax region perlDATA start="^__\(DATA\|END\)__$" skip="." end="." contains=perlPOD,@perlDATA
|
|
389 endif
|
|
390
|
|
391
|
|
392 "
|
|
393 " Folding
|
|
394
|
|
395 if exists("perl_fold")
|
1118
|
396 if !exists("perl_nofold_packages")
|
|
397 syn region perlPackageFold start="^package \S\+;\s*\(#.*\)\=$" end="^1;\s*\(#.*\)\=$" end="\n\+package"me=s-1 transparent fold keepend
|
|
398 endif
|
|
399 if !exists("perl_nofold_subs")
|
|
400 syn region perlSubFold start="^\z(\s*\)\<sub\>.*[^};]$" end="^\z1}\s*\(#.*\)\=$" transparent fold keepend
|
|
401 syn region perlSubFold start="^\z(\s*\)\<\(BEGIN\|END\|CHECK\|INIT\)\>.*[^};]$" end="^\z1}\s*$" transparent fold keepend
|
|
402 endif
|
7
|
403
|
|
404 if exists("perl_fold_blocks")
|
1118
|
405 syn region perlBlockFold start="^\z(\s*\)\(if\|elsif\|unless\|for\|while\|until\)\s*(.*)\(\s*{\)\=\s*\(#.*\)\=$" start="^\z(\s*\)foreach\s*\(\(my\|our\)\=\s*\S\+\s*\)\=(.*)\(\s*{\)\=\s*\(#.*\)\=$" end="^\z1}\s*;\=\(#.*\)\=$" transparent fold keepend
|
|
406 syn region perlBlockFold start="^\z(\s*\)\(do\|else\)\(\s*{\)\=\s*\(#.*\)\=$" end="^\z1}\s*while" end="^\z1}\s*;\=\(#.*\)\=$" transparent fold keepend
|
7
|
407 endif
|
|
408
|
|
409 setlocal foldmethod=syntax
|
|
410 syn sync fromstart
|
|
411 else
|
|
412 " fromstart above seems to set minlines even if perl_fold is not set.
|
|
413 syn sync minlines=0
|
|
414 endif
|
|
415
|
|
416
|
|
417 if version >= 508 || !exists("did_perl_syn_inits")
|
|
418 if version < 508
|
|
419 let did_perl_syn_inits = 1
|
|
420 command -nargs=+ HiLink hi link <args>
|
|
421 else
|
|
422 command -nargs=+ HiLink hi def link <args>
|
|
423 endif
|
|
424
|
|
425 " The default highlighting.
|
|
426 HiLink perlSharpBang PreProc
|
|
427 HiLink perlControl PreProc
|
|
428 HiLink perlInclude Include
|
|
429 HiLink perlSpecial Special
|
|
430 HiLink perlString String
|
|
431 HiLink perlCharacter Character
|
|
432 HiLink perlNumber Number
|
|
433 HiLink perlFloat Float
|
|
434 HiLink perlType Type
|
|
435 HiLink perlIdentifier Identifier
|
|
436 HiLink perlLabel Label
|
|
437 HiLink perlStatement Statement
|
|
438 HiLink perlConditional Conditional
|
|
439 HiLink perlRepeat Repeat
|
|
440 HiLink perlOperator Operator
|
|
441 HiLink perlFunction Function
|
|
442 HiLink perlFunctionPrototype perlFunction
|
|
443 HiLink perlComment Comment
|
|
444 HiLink perlTodo Todo
|
|
445 if exists("perl_string_as_statement")
|
|
446 HiLink perlStringStartEnd perlStatement
|
|
447 else
|
|
448 HiLink perlStringStartEnd perlString
|
|
449 endif
|
|
450 HiLink perlList perlStatement
|
|
451 HiLink perlMisc perlStatement
|
|
452 HiLink perlVarPlain perlIdentifier
|
1118
|
453 HiLink perlVarPlain2 perlIdentifier
|
7
|
454 HiLink perlFiledescRead perlIdentifier
|
|
455 HiLink perlFiledescStatement perlIdentifier
|
|
456 HiLink perlVarSimpleMember perlIdentifier
|
|
457 HiLink perlVarSimpleMemberName perlString
|
|
458 HiLink perlVarNotInMatches perlIdentifier
|
|
459 HiLink perlVarSlash perlIdentifier
|
|
460 HiLink perlQQ perlString
|
|
461 if version >= 600
|
|
462 HiLink perlHereDoc perlString
|
|
463 else
|
|
464 HiLink perlHereIdentifier perlStringStartEnd
|
|
465 HiLink perlUntilEOFDQ perlString
|
|
466 HiLink perlUntilEOFSQ perlString
|
|
467 HiLink perlUntilEmptyDQ perlString
|
|
468 HiLink perlUntilEmptySQ perlString
|
1118
|
469 HiLink perlUntilEOF perlString
|
7
|
470 endif
|
|
471 HiLink perlStringUnexpanded perlString
|
|
472 HiLink perlSubstitutionSQ perlString
|
|
473 HiLink perlSubstitutionDQ perlString
|
|
474 HiLink perlSubstitutionSlash perlString
|
|
475 HiLink perlSubstitutionHash perlString
|
|
476 HiLink perlSubstitutionBracket perlString
|
|
477 HiLink perlSubstitutionCurly perlString
|
|
478 HiLink perlSubstitutionPling perlString
|
|
479 HiLink perlTranslationSlash perlString
|
|
480 HiLink perlTranslationHash perlString
|
|
481 HiLink perlTranslationBracket perlString
|
|
482 HiLink perlTranslationCurly perlString
|
|
483 HiLink perlMatch perlString
|
|
484 HiLink perlMatchStartEnd perlStatement
|
|
485 HiLink perlFormatName perlIdentifier
|
|
486 HiLink perlFormatField perlString
|
|
487 HiLink perlPackageDecl perlType
|
|
488 HiLink perlStorageClass perlType
|
|
489 HiLink perlPackageRef perlType
|
|
490 HiLink perlStatementPackage perlStatement
|
|
491 HiLink perlStatementSub perlStatement
|
|
492 HiLink perlStatementStorage perlStatement
|
|
493 HiLink perlStatementControl perlStatement
|
|
494 HiLink perlStatementScalar perlStatement
|
|
495 HiLink perlStatementRegexp perlStatement
|
|
496 HiLink perlStatementNumeric perlStatement
|
|
497 HiLink perlStatementList perlStatement
|
|
498 HiLink perlStatementHash perlStatement
|
|
499 HiLink perlStatementIOfunc perlStatement
|
|
500 HiLink perlStatementFiledesc perlStatement
|
|
501 HiLink perlStatementVector perlStatement
|
|
502 HiLink perlStatementFiles perlStatement
|
|
503 HiLink perlStatementFlow perlStatement
|
|
504 HiLink perlStatementScope perlStatement
|
1118
|
505 HiLink perlStatementInclude perlStatement
|
7
|
506 HiLink perlStatementProc perlStatement
|
|
507 HiLink perlStatementSocket perlStatement
|
|
508 HiLink perlStatementIPC perlStatement
|
|
509 HiLink perlStatementNetwork perlStatement
|
|
510 HiLink perlStatementPword perlStatement
|
|
511 HiLink perlStatementTime perlStatement
|
|
512 HiLink perlStatementMisc perlStatement
|
|
513 HiLink perlStatementNew perlStatement
|
|
514 HiLink perlFunctionName perlIdentifier
|
|
515 HiLink perlMethod perlIdentifier
|
|
516 HiLink perlFunctionPRef perlType
|
|
517 HiLink perlPOD perlComment
|
|
518 HiLink perlShellCommand perlString
|
|
519 HiLink perlSpecialAscii perlSpecial
|
|
520 HiLink perlSpecialDollar perlSpecial
|
|
521 HiLink perlSpecialString perlSpecial
|
|
522 HiLink perlSpecialStringU perlSpecial
|
|
523 HiLink perlSpecialMatch perlSpecial
|
|
524 HiLink perlSpecialBEOM perlSpecial
|
|
525 HiLink perlDATA perlComment
|
1118
|
526
|
|
527 HiLink perlBrackets Error
|
|
528
|
7
|
529 " Possible errors
|
|
530 HiLink perlNotEmptyLine Error
|
|
531 HiLink perlElseIfError Error
|
|
532
|
|
533 delcommand HiLink
|
|
534 endif
|
|
535
|
|
536 " Syncing to speed up processing
|
|
537 "
|
|
538 if !exists("perl_no_sync_on_sub")
|
|
539 syn sync match perlSync grouphere NONE "^\s*\<package\s"
|
|
540 syn sync match perlSync grouphere perlFunction "^\s*\<sub\s"
|
|
541 syn sync match perlSync grouphere NONE "^}"
|
|
542 endif
|
|
543
|
|
544 if !exists("perl_no_sync_on_global_var")
|
|
545 syn sync match perlSync grouphere NONE "^$\I[[:alnum:]_:]+\s*=\s*{"
|
|
546 syn sync match perlSync grouphere NONE "^[@%]\I[[:alnum:]_:]+\s*=\s*("
|
|
547 endif
|
|
548
|
|
549 if exists("perl_sync_dist")
|
|
550 execute "syn sync maxlines=" . perl_sync_dist
|
|
551 else
|
|
552 syn sync maxlines=100
|
|
553 endif
|
|
554
|
|
555 syn sync match perlSyncPOD grouphere perlPOD "^=pod"
|
|
556 syn sync match perlSyncPOD grouphere perlPOD "^=head"
|
|
557 syn sync match perlSyncPOD grouphere perlPOD "^=item"
|
|
558 syn sync match perlSyncPOD grouphere NONE "^=cut"
|
|
559
|
|
560 let b:current_syntax = "perl"
|
|
561
|
|
562 " vim: ts=8
|