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