7
|
1 " Vim syntax file
|
|
2 " Language: Perl
|
|
3 " Maintainer: Nick Hibma <n_hibma@van-laarhoven.org>
|
557
|
4 " Last Change: 2005 October 18
|
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")
|
557
|
50 syn region perlPOD start="^=[a-z]" end="^=cut" contains=@Pod,@Spell,perlTodo keepend fold
|
7
|
51 syn region perlPOD start="^=cut" end="^=cut" contains=perlTodo keepend fold
|
|
52 else
|
557
|
53 syn region perlPOD start="^=[a-z]" end="^=cut" contains=@Pod,@Spell,perlTodo keepend
|
7
|
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")
|
557
|
59 syn region perlPOD start="^=[a-z]" end="^=cut" contains=@Spell fold
|
7
|
60 else
|
557
|
61 syn region perlPOD start="^=[a-z]" end="^=cut" contains=@Spell
|
7
|
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")
|
557
|
90 " if BEGIN/END is a keyword the perlBEGINENDFold does not work
|
|
91 syn match perlControl "\<BEGIN\|END\|CHECK\|INIT\>" 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
|
557
|
111 syn match perlStatementInclude "\<\(use\|no\)\s\+\(\(attributes\|autouse\|base\|big\(int\|num\|rat\)\|blib\|bytes\|charnames\|constant\|diagnostics\|encoding\|fields\|filetest\|if\|integer\|less\|lib\|locale\|open\|ops\|overload\|re\|sigtrap\|sort\|strict\|subs\|threads\(::shared\)\=\|utf8\|vars\|vmsish\|warnings\(::register\)\=\)\>\)\="
|
|
112
|
7
|
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
|
557
|
121 if !exists("perl_no_semi_keywords")
|
|
122 syn keyword perlStatementScope import
|
|
123 syn keyword perlStatementNew new
|
|
124 syn keyword perlStatementCarp carp confess croak
|
|
125 endif
|
7
|
126 syn keyword perlTodo TODO TBD FIXME XXX contained
|
|
127
|
|
128 " Perl Identifiers.
|
|
129 "
|
|
130 " Should be cleaned up to better handle identifiers in particular situations
|
|
131 " (in hash keys for example)
|
|
132 "
|
|
133 " Plain identifiers: $foo, @foo, $#foo, %foo, &foo and dereferences $$foo, @$foo, etc.
|
|
134 " We do not process complex things such as @{${"foo"}}. Too complicated, and
|
|
135 " too slow. And what is after the -> is *not* considered as part of the
|
|
136 " variable - there again, too complicated and too slow.
|
|
137
|
|
138 " Special variables first ($^A, ...) and ($|, $', ...)
|
|
139 syn match perlVarPlain "$^[ADEFHILMOPSTWX]\="
|
557
|
140 syn match perlVarPlain "$[\\\"\[\]'&`+*.,;=%~?@$<>(-]"
|
|
141 syn match perlVarPlain "$\(0\|[1-9]\d*\)"
|
7
|
142 " Same as above, but avoids confusion in $::foo (equivalent to $main::foo)
|
|
143 syn match perlVarPlain "$:[^:]"
|
|
144 " These variables are not recognized within matches.
|
|
145 syn match perlVarNotInMatches "$[|)]"
|
557
|
146 " This variable is not recognized within matches delimited by '/'.
|
7
|
147 syn match perlVarSlash "$/"
|
557
|
148 " This variable is not recognized within matches delimited by '!'.
|
|
149 syn match perlVarBang "$!"
|
7
|
150
|
|
151 " And plain identifiers
|
|
152 syn match perlPackageRef "\(\h\w*\)\=\(::\|'\)\I"me=e-1 contained
|
|
153
|
|
154 " FIXME value between {} should be marked as string. is treated as such by Perl.
|
|
155 " At the moment it is marked as something greyish instead of read. Probably todo
|
|
156 " with transparency. Or maybe we should handle the bare word in that case. or make it into
|
|
157
|
22
|
158 if !exists("perl_no_scope_in_variables")
|
7
|
159 syn match perlVarPlain "\\\=\([@%$]\|\$#\)\$*\(\I\i*\)\=\(\(::\|'\)\I\i*\)*\>" contains=perlPackageRef nextgroup=perlVarMember,perlVarSimpleMember,perlMethod
|
|
160 syn match perlFunctionName "\\\=&\$*\(\I\i*\)\=\(\(::\|'\)\I\i*\)*\>" contains=perlPackageRef nextgroup=perlVarMember,perlVarSimpleMember
|
|
161 else
|
|
162 syn match perlVarPlain "\\\=\([@%$]\|\$#\)\$*\(\I\i*\)\=\(\(::\|'\)\I\i*\)*\>" nextgroup=perlVarMember,perlVarSimpleMember,perlMethod
|
|
163 syn match perlFunctionName "\\\=&\$*\(\I\i*\)\=\(\(::\|'\)\I\i*\)*\>" nextgroup=perlVarMember,perlVarSimpleMember
|
|
164 endif
|
|
165
|
22
|
166 if !exists("perl_no_extended_vars")
|
557
|
167 syn cluster perlExpr contains=perlStatementScalar,perlStatementRegexp,perlStatementNumeric,perlStatementList,perlStatementHash,perlStatementFiles,perlStatementTime,perlStatementMisc,perlVarPlain,perlVarNotInMatches,perlVarSlash,perlVarBang,perlVarBlock,perlShellCommand,perlFloat,perlNumber,perlStringUnexpanded,perlString,perlQQ
|
7
|
168 syn region perlVarBlock matchgroup=perlVarPlain start="\($#\|[@%$]\)\$*{" skip="\\}" end="}" contains=@perlExpr nextgroup=perlVarMember,perlVarSimpleMember
|
|
169 syn region perlVarBlock matchgroup=perlVarPlain start="&\$*{" skip="\\}" end="}" contains=@perlExpr
|
|
170 syn match perlVarPlain "\\\=\(\$#\|[@%&$]\)\$*{\I\i*}" nextgroup=perlVarMember,perlVarSimpleMember
|
|
171 syn region perlVarMember matchgroup=perlVarPlain start="\(->\)\={" skip="\\}" end="}" contained contains=@perlExpr nextgroup=perlVarMember,perlVarSimpleMember
|
|
172 syn match perlVarSimpleMember "\(->\)\={\I\i*}" nextgroup=perlVarMember,perlVarSimpleMember contains=perlVarSimpleMemberName contained
|
|
173 syn match perlVarSimpleMemberName "\I\i*" contained
|
|
174 syn region perlVarMember matchgroup=perlVarPlain start="\(->\)\=\[" skip="\\]" end="]" contained contains=@perlExpr nextgroup=perlVarMember,perlVarSimpleMember
|
|
175 syn match perlMethod "\(->\)\I\i*" contained
|
|
176 endif
|
|
177
|
|
178 " File Descriptors
|
|
179 syn match perlFiledescRead "[<]\h\w\+[>]"
|
|
180
|
|
181 syn match perlFiledescStatementComma "(\=\s*\u\w*\s*,"me=e-1 transparent contained contains=perlFiledescStatement
|
557
|
182 syn match perlFiledescStatementNocomma "(\=\s*\u\w*\s*[^,[:space:]]"me=e-1 transparent contained contains=perlFiledescStatement
|
7
|
183
|
|
184 syn match perlFiledescStatement "\u\w*" contained
|
|
185
|
|
186 " Special characters in strings and matches
|
|
187 syn match perlSpecialString "\\\(\d\+\|[xX]\x\+\|c\u\|.\)" contained
|
|
188 syn match perlSpecialStringU "\\['\\]" contained
|
557
|
189 syn match perlSpecialMatch "{\d\+\(,\d*\)\=}" contained
|
7
|
190 syn match perlSpecialMatch "\[\(\]\|-\)\=[^\[\]]*\(\[\|\-\)\=\]" contained
|
|
191 syn match perlSpecialMatch "[+*()?.]" contained
|
|
192 syn match perlSpecialMatch "(?[#:=!]" contained
|
557
|
193 syn match perlSpecialMatch "(?<[=!]" contained
|
7
|
194 syn match perlSpecialMatch "(?[imsx]\+)" contained
|
|
195 " FIXME the line below does not work. It should mark end of line and
|
|
196 " begin of line as perlSpecial.
|
|
197 " syn match perlSpecialBEOM "^\^\|\$$" contained
|
|
198
|
|
199 " Possible errors
|
|
200 "
|
|
201 " Highlight lines with only whitespace (only in blank delimited here documents) as errors
|
|
202 syn match perlNotEmptyLine "^\s\+$" contained
|
|
203 " Highlight '} else if (...) {', it should be '} else { if (...) { ' or
|
|
204 " '} elsif (...) {'.
|
|
205 "syn keyword perlElseIfError if contained
|
|
206
|
|
207 " Variable interpolation
|
|
208 "
|
|
209 " These items are interpolated inside "" strings and similar constructs.
|
557
|
210 syn cluster perlInterpDQ contains=perlSpecialString,perlVarPlain,perlVarNotInMatches,perlVarSlash,perlVarBang,perlVarBlock
|
7
|
211 " These items are interpolated inside '' strings and similar constructs.
|
|
212 syn cluster perlInterpSQ contains=perlSpecialStringU
|
|
213 " These items are interpolated inside m// matches and s/// substitutions.
|
|
214 syn cluster perlInterpSlash contains=perlSpecialString,perlSpecialMatch,perlVarPlain,perlVarBlock,perlSpecialBEOM
|
|
215 " These items are interpolated inside m## matches and s### substitutions.
|
557
|
216 syn cluster perlInterpMatch contains=@perlInterpSlash,perlVarSlash,perlVarBang
|
7
|
217
|
|
218 " Shell commands
|
|
219 syn region perlShellCommand matchgroup=perlMatchStartEnd start="`" end="`" contains=@perlInterpDQ
|
|
220
|
|
221 " Constants
|
|
222 "
|
|
223 " Numbers
|
|
224 syn match perlNumber "[-+]\=\(\<\d[[:digit:]_]*L\=\>\|0[xX]\x[[:xdigit:]_]*\>\)"
|
|
225 syn match perlFloat "[-+]\=\<\d[[:digit:]_]*[eE][\-+]\=\d\+"
|
|
226 syn match perlFloat "[-+]\=\<\d[[:digit:]_]*\.[[:digit:]_]*\([eE][\-+]\=\d\+\)\="
|
|
227 syn match perlFloat "[-+]\=\<\.[[:digit:]_]\+\([eE][\-+]\=\d\+\)\="
|
|
228
|
|
229
|
|
230 " Simple version of searches and matches
|
|
231 " caters for m//, m##, m{} and m[] (and the !/ variant)
|
|
232 syn region perlMatch matchgroup=perlMatchStartEnd start=+[m!]/+ end=+/[cgimosx]*+ contains=@perlInterpSlash
|
|
233 syn region perlMatch matchgroup=perlMatchStartEnd start=+[m!]#+ end=+#[cgimosx]*+ contains=@perlInterpMatch
|
|
234 syn region perlMatch matchgroup=perlMatchStartEnd start=+[m!]{+ end=+}[cgimosx]*+ contains=@perlInterpMatch
|
|
235 syn region perlMatch matchgroup=perlMatchStartEnd start=+[m!]\[+ end=+\][cgimosx]*+ contains=@perlInterpMatch
|
|
236
|
|
237 " A special case for m!!x which allows for comments and extra whitespace in the pattern
|
|
238 syn region perlMatch matchgroup=perlMatchStartEnd start=+[m!]!+ end=+![cgimosx]*+ contains=@perlInterpSlash,perlComment
|
|
239
|
|
240 " Below some hacks to recognise the // variant. This is virtually impossible to catch in all
|
|
241 " cases as the / is used in so many other ways, but these should be the most obvious ones.
|
557
|
242 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/[^=[:space:][:digit:]$@%&]+lc=1,me=e-1,rs=e-1 start=+^/+ skip=+\\/+ end=+/[cgimosx]*+ contains=@perlInterpSlash
|
7
|
243
|
|
244
|
|
245 " Substitutions
|
|
246 " caters for s///, s### and s[][]
|
|
247 " perlMatch is the first part, perlSubstitution* is the substitution part
|
|
248 syn region perlMatch matchgroup=perlMatchStartEnd start=+\<s'+ end=+'+me=e-1 contains=@perlInterpSQ nextgroup=perlSubstitutionSQ
|
|
249 syn region perlMatch matchgroup=perlMatchStartEnd start=+\<s"+ end=+"+me=e-1 contains=@perlInterpMatch nextgroup=perlSubstitutionDQ
|
|
250 syn region perlMatch matchgroup=perlMatchStartEnd start=+\<s/+ end=+/+me=e-1 contains=@perlInterpSlash nextgroup=perlSubstitutionSlash
|
|
251 syn region perlMatch matchgroup=perlMatchStartEnd start=+\<s#+ end=+#+me=e-1 contains=@perlInterpMatch nextgroup=perlSubstitutionHash
|
|
252 syn region perlMatch matchgroup=perlMatchStartEnd start=+\<s\[+ end=+\]+ contains=@perlInterpMatch nextgroup=perlSubstitutionBracket skipwhite skipempty skipnl
|
|
253 syn region perlMatch matchgroup=perlMatchStartEnd start=+\<s{+ end=+}+ contains=@perlInterpMatch nextgroup=perlSubstitutionCurly skipwhite skipempty skipnl
|
|
254 syn region perlSubstitutionSQ matchgroup=perlMatchStartEnd start=+'+ end=+'[ecgimosx]*+ contained contains=@perlInterpSQ
|
|
255 syn region perlSubstitutionDQ matchgroup=perlMatchStartEnd start=+"+ end=+"[ecgimosx]*+ contained contains=@perlInterpDQ
|
|
256 syn region perlSubstitutionSlash matchgroup=perlMatchStartEnd start=+/+ end=+/[ecgimosx]*+ contained contains=@perlInterpDQ
|
|
257 syn region perlSubstitutionHash matchgroup=perlMatchStartEnd start=+#+ end=+#[ecgimosx]*+ contained contains=@perlInterpDQ
|
|
258 syn region perlSubstitutionBracket matchgroup=perlMatchStartEnd start=+\[+ end=+\][ecgimosx]*+ contained contains=@perlInterpDQ
|
|
259 syn region perlSubstitutionCurly matchgroup=perlMatchStartEnd start=+{+ end=+}[ecgimosx]*+ contained contains=@perlInterpDQ
|
|
260
|
557
|
261 " A special case for s!!!x which allows for comments and extra whitespace in the pattern
|
7
|
262 syn region perlMatch matchgroup=perlMatchStartEnd start=+\<s!+ end=+!+me=e-1 contains=@perlInterpSlash,perlComment nextgroup=perlSubstitutionPling
|
|
263 syn region perlSubstitutionPling matchgroup=perlMatchStartEnd start=+!+ end=+![ecgimosx]*+ contained contains=@perlInterpDQ
|
|
264
|
|
265 " Substitutions
|
|
266 " caters for tr///, tr### and tr[][]
|
|
267 " perlMatch is the first part, perlTranslation* is the second, translator part.
|
|
268 syn region perlMatch matchgroup=perlMatchStartEnd start=+\<\(tr\|y\)'+ end=+'+me=e-1 contains=@perlInterpSQ nextgroup=perlTranslationSQ
|
|
269 syn region perlMatch matchgroup=perlMatchStartEnd start=+\<\(tr\|y\)"+ end=+"+me=e-1 contains=@perlInterpSQ nextgroup=perlTranslationDQ
|
|
270 syn region perlMatch matchgroup=perlMatchStartEnd start=+\<\(tr\|y\)/+ end=+/+me=e-1 contains=@perlInterpSQ nextgroup=perlTranslationSlash
|
|
271 syn region perlMatch matchgroup=perlMatchStartEnd start=+\<\(tr\|y\)#+ end=+#+me=e-1 contains=@perlInterpSQ nextgroup=perlTranslationHash
|
|
272 syn region perlMatch matchgroup=perlMatchStartEnd start=+\<\(tr\|y\)\[+ end=+\]+ contains=@perlInterpSQ nextgroup=perlTranslationBracket skipwhite skipempty skipnl
|
|
273 syn region perlMatch matchgroup=perlMatchStartEnd start=+\<\(tr\|y\){+ end=+}+ contains=@perlInterpSQ nextgroup=perlTranslationCurly skipwhite skipempty skipnl
|
|
274 syn region perlTranslationSQ matchgroup=perlMatchStartEnd start=+'+ end=+'[cds]*+ contained
|
|
275 syn region perlTranslationDQ matchgroup=perlMatchStartEnd start=+"+ end=+"[cds]*+ contained
|
|
276 syn region perlTranslationSlash matchgroup=perlMatchStartEnd start=+/+ end=+/[cds]*+ contained
|
|
277 syn region perlTranslationHash matchgroup=perlMatchStartEnd start=+#+ end=+#[cds]*+ contained
|
|
278 syn region perlTranslationBracket matchgroup=perlMatchStartEnd start=+\[+ end=+\][cds]*+ contained
|
|
279 syn region perlTranslationCurly matchgroup=perlMatchStartEnd start=+{+ end=+}[cds]*+ contained
|
|
280
|
|
281
|
|
282 " The => operator forces a bareword to the left of it to be interpreted as
|
|
283 " a string
|
|
284 syn match perlString "\<\I\i*\s*=>"me=e-2
|
|
285
|
|
286 " Strings and q, qq, qw and qr expressions
|
|
287
|
557
|
288 " Parentheses in qq()
|
|
289 syn region perlParens start=+(+ end=+)+ contained transparent contains=perlParens,@perlStringSQ
|
7
|
290
|
557
|
291 syn region perlStringUnexpanded matchgroup=perlStringStartEnd start="'" end="'" contains=@Spell,@perlInterpSQ
|
|
292 syn region perlString matchgroup=perlStringStartEnd start=+"+ end=+"+ contains=@Spell,@perlInterpDQ
|
7
|
293 syn region perlQQ matchgroup=perlStringStartEnd start=+\<q#+ end=+#+ contains=@perlInterpSQ
|
|
294 syn region perlQQ matchgroup=perlStringStartEnd start=+\<q|+ end=+|+ contains=@perlInterpSQ
|
557
|
295 syn region perlQQ matchgroup=perlStringStartEnd start=+\<q(+ end=+)+ contains=@perlInterpSQ,perlParens
|
7
|
296 syn region perlQQ matchgroup=perlStringStartEnd start=+\<q{+ end=+}+ contains=@perlInterpSQ
|
|
297 syn region perlQQ matchgroup=perlStringStartEnd start=+\<q/+ end=+/+ contains=@perlInterpSQ
|
|
298 syn region perlQQ matchgroup=perlStringStartEnd start=+\<q[qx]#+ end=+#+ contains=@perlInterpDQ
|
|
299 syn region perlQQ matchgroup=perlStringStartEnd start=+\<q[qx]|+ end=+|+ contains=@perlInterpDQ
|
557
|
300 syn region perlQQ matchgroup=perlStringStartEnd start=+\<q[qx](+ end=+)+ contains=@perlInterpDQ,perlParens
|
7
|
301 syn region perlQQ matchgroup=perlStringStartEnd start=+\<q[qx]{+ end=+}+ contains=@perlInterpDQ
|
|
302 syn region perlQQ matchgroup=perlStringStartEnd start=+\<q[qx]/+ end=+/+ contains=@perlInterpDQ
|
|
303 syn region perlQQ matchgroup=perlStringStartEnd start=+\<qw#+ end=+#+ contains=@perlInterpSQ
|
|
304 syn region perlQQ matchgroup=perlStringStartEnd start=+\<qw|+ end=+|+ contains=@perlInterpSQ
|
557
|
305 syn region perlQQ matchgroup=perlStringStartEnd start=+\<qw(+ end=+)+ contains=@perlInterpSQ,perlParens
|
7
|
306 syn region perlQQ matchgroup=perlStringStartEnd start=+\<qw{+ end=+}+ contains=@perlInterpSQ
|
|
307 syn region perlQQ matchgroup=perlStringStartEnd start=+\<qw/+ end=+/+ contains=@perlInterpSQ
|
|
308 syn region perlQQ matchgroup=perlStringStartEnd start=+\<qr#+ end=+#[imosx]*+ contains=@perlInterpMatch
|
|
309 syn region perlQQ matchgroup=perlStringStartEnd start=+\<qr|+ end=+|[imosx]*+ contains=@perlInterpMatch
|
|
310 syn region perlQQ matchgroup=perlStringStartEnd start=+\<qr(+ end=+)[imosx]*+ contains=@perlInterpMatch
|
|
311 syn region perlQQ matchgroup=perlStringStartEnd start=+\<qr{+ end=+}[imosx]*+ contains=@perlInterpMatch
|
|
312 syn region perlQQ matchgroup=perlStringStartEnd start=+\<qr/+ end=+/[imosx]*+ contains=@perlInterpSlash
|
|
313
|
|
314 " Constructs such as print <<EOF [...] EOF, 'here' documents
|
|
315 "
|
|
316 if version >= 600
|
|
317 " XXX Any statements after the identifier are in perlString colour (i.e.
|
|
318 " 'if $a' in 'print <<EOF if $a').
|
|
319 if exists("perl_fold")
|
|
320 syn region perlHereDoc matchgroup=perlStringStartEnd start=+<<\z(\I\i*\)+ end=+^\z1$+ contains=@perlInterpDQ fold
|
|
321 syn region perlHereDoc matchgroup=perlStringStartEnd start=+<<\s*"\z(.\{-}\)"+ end=+^\z1$+ contains=@perlInterpDQ fold
|
|
322 syn region perlHereDoc matchgroup=perlStringStartEnd start=+<<\s*'\z(.\{-}\)'+ end=+^\z1$+ contains=@perlInterpSQ fold
|
|
323 syn region perlHereDoc matchgroup=perlStringStartEnd start=+<<\s*""+ end=+^$+ contains=@perlInterpDQ,perlNotEmptyLine fold
|
|
324 syn region perlHereDoc matchgroup=perlStringStartEnd start=+<<\s*''+ end=+^$+ contains=@perlInterpSQ,perlNotEmptyLine fold
|
|
325 syn region perlAutoload matchgroup=perlStringStartEnd start=+<<['"]\z(END_\(SUB\|OF_FUNC\|OF_AUTOLOAD\)\)['"]+ end=+^\z1$+ contains=ALL fold
|
|
326 else
|
|
327 syn region perlHereDoc matchgroup=perlStringStartEnd start=+<<\z(\I\i*\)+ end=+^\z1$+ contains=@perlInterpDQ
|
|
328 syn region perlHereDoc matchgroup=perlStringStartEnd start=+<<\s*"\z(.\{-}\)"+ end=+^\z1$+ contains=@perlInterpDQ
|
|
329 syn region perlHereDoc matchgroup=perlStringStartEnd start=+<<\s*'\z(.\{-}\)'+ end=+^\z1$+ contains=@perlInterpSQ
|
|
330 syn region perlHereDoc matchgroup=perlStringStartEnd start=+<<\s*""+ end=+^$+ contains=@perlInterpDQ,perlNotEmptyLine
|
|
331 syn region perlHereDoc matchgroup=perlStringStartEnd start=+<<\s*''+ end=+^$+ contains=@perlInterpSQ,perlNotEmptyLine
|
|
332 syn region perlAutoload matchgroup=perlStringStartEnd start=+<<\(['"]\|\)\z(END_\(SUB\|OF_FUNC\|OF_AUTOLOAD\)\)\1+ end=+^\z1$+ contains=ALL
|
|
333 endif
|
|
334 else
|
|
335 syn match perlUntilEOFStart "<<EOF.*"lc=5 nextgroup=perlUntilEOFDQ skipnl transparent
|
|
336 syn match perlUntilEOFStart "<<\s*\"EOF\".*" nextgroup=perlUntilEOFDQ skipnl transparent
|
|
337 syn match perlUntilEOFStart "<<\s*'EOF'.*" nextgroup=perlUntilEOFSQ skipnl transparent
|
|
338 syn match perlUntilEOFStart "<<\s*\"\".*" nextgroup=perlUntilEmptyDQ skipnl transparent
|
|
339 syn match perlUntilEOFStart "<<\s*''.*" nextgroup=perlUntilEmptySQ skipnl transparent
|
|
340 syn region perlUntilEOFDQ matchgroup=perlStringStartEnd start=++ end="^EOF$" contains=@perlInterpDQ contained
|
|
341 syn region perlUntilEOFSQ matchgroup=perlStringStartEnd start=++ end="^EOF$" contains=@perlInterpSQ contained
|
|
342 syn region perlUntilEmptySQ matchgroup=perlStringStartEnd start=++ end="^$" contains=@perlInterpDQ,perlNotEmptyLine contained
|
|
343 syn region perlUntilEmptyDQ matchgroup=perlStringStartEnd start=++ end="^$" contains=@perlInterpSQ,perlNotEmptyLine contained
|
|
344 syn match perlHereIdentifier "<<EOF"
|
|
345 syn region perlAutoload matchgroup=perlStringStartEnd start=+<<\(['"]\|\)\(END_\(SUB\|OF_FUNC\|OF_AUTOLOAD\)\)\1+ end=+^\(END_\(SUB\|OF_FUNC\|OF_AUTOLOAD\)\)$+ contains=ALL
|
|
346 endif
|
|
347
|
|
348
|
|
349 " Class declarations
|
|
350 "
|
|
351 syn match perlPackageDecl "^\s*\<package\s\+\S\+" contains=perlStatementPackage
|
|
352 syn keyword perlStatementPackage package contained
|
|
353
|
|
354 " Functions
|
|
355 " sub [name] [(prototype)] {
|
|
356 "
|
|
357 syn region perlFunction start="\s*\<sub\>" end="[;{]"he=e-1 contains=perlStatementSub,perlFunctionPrototype,perlFunctionPRef,perlFunctionName,perlComment
|
|
358 syn keyword perlStatementSub sub contained
|
|
359
|
|
360 syn match perlFunctionPrototype "([^)]*)" contained
|
22
|
361 if !exists("perl_no_scope_in_variables")
|
7
|
362 syn match perlFunctionPRef "\h\w*::" contained
|
|
363 syn match perlFunctionName "\h\w*[^:]" contained
|
|
364 else
|
|
365 syn match perlFunctionName "\h[[:alnum:]_:]*" contained
|
|
366 endif
|
|
367
|
|
368
|
|
369 " All other # are comments, except ^#!
|
557
|
370 syn match perlComment "#.*" contains=@Spell,perlTodo
|
7
|
371 syn match perlSharpBang "^#!.*"
|
|
372
|
|
373 " Formats
|
|
374 syn region perlFormat matchgroup=perlStatementIOFunc start="^\s*\<format\s\+\k\+\s*=\s*$"rs=s+6 end="^\s*\.\s*$" contains=perlFormatName,perlFormatField,perlVarPlain
|
|
375 syn match perlFormatName "format\s\+\k\+\s*="lc=7,me=e-1 contained
|
|
376 syn match perlFormatField "[@^][|<>~]\+\(\.\.\.\)\=" contained
|
|
377 syn match perlFormatField "[@^]#[#.]*" contained
|
|
378 syn match perlFormatField "@\*" contained
|
|
379 syn match perlFormatField "@[^A-Za-z_|<>~#*]"me=e-1 contained
|
|
380 syn match perlFormatField "@$" contained
|
|
381
|
|
382 " __END__ and __DATA__ clauses
|
|
383 if exists("perl_fold")
|
|
384 syntax region perlDATA start="^__\(DATA\|END\)__$" skip="." end="." contains=perlPOD,@perlDATA fold
|
|
385 else
|
|
386 syntax region perlDATA start="^__\(DATA\|END\)__$" skip="." end="." contains=perlPOD,@perlDATA
|
|
387 endif
|
|
388
|
|
389
|
|
390 "
|
|
391 " Folding
|
|
392
|
|
393 if exists("perl_fold")
|
|
394 syn region perlPackageFold start="^package \S\+;$" end="^1;$" end="\n\+package"me=s-1 transparent fold keepend
|
|
395 syn region perlSubFold start="^\z(\s*\)\<sub\>.*[^};]$" end="^\z1}\s*$" end="^\z1}\s*\#.*$" transparent fold keepend
|
548
|
396 syn region perlBEGINENDFold start="^\z(\s*\)\<\(BEGIN\|END\|CHECK\|INIT\)\>.*[^};]$" end="^\z1}\s*$" transparent fold keepend
|
7
|
397
|
|
398 if exists("perl_fold_blocks")
|
557
|
399 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*$" start="\z(\s*\)else\s*{\s*$" end="^\z1}\s*;\=$" transparent fold keepend
|
|
400 syn region perlIfFold start="^\z(\s*\)do\(\s*{\)\=\s*$" end="^\z1}\s*while" end="^\z1}\s*;\=$" transparent fold keepend
|
7
|
401 endif
|
|
402
|
|
403 setlocal foldmethod=syntax
|
|
404 syn sync fromstart
|
|
405 else
|
|
406 " fromstart above seems to set minlines even if perl_fold is not set.
|
|
407 syn sync minlines=0
|
|
408 endif
|
|
409
|
|
410
|
|
411 if version >= 508 || !exists("did_perl_syn_inits")
|
|
412 if version < 508
|
|
413 let did_perl_syn_inits = 1
|
|
414 command -nargs=+ HiLink hi link <args>
|
|
415 else
|
|
416 command -nargs=+ HiLink hi def link <args>
|
|
417 endif
|
|
418
|
|
419 " The default highlighting.
|
|
420 HiLink perlSharpBang PreProc
|
|
421 HiLink perlControl PreProc
|
|
422 HiLink perlInclude Include
|
|
423 HiLink perlSpecial Special
|
|
424 HiLink perlString String
|
|
425 HiLink perlCharacter Character
|
|
426 HiLink perlNumber Number
|
|
427 HiLink perlFloat Float
|
|
428 HiLink perlType Type
|
|
429 HiLink perlIdentifier Identifier
|
|
430 HiLink perlLabel Label
|
|
431 HiLink perlStatement Statement
|
|
432 HiLink perlConditional Conditional
|
|
433 HiLink perlRepeat Repeat
|
|
434 HiLink perlOperator Operator
|
|
435 HiLink perlFunction Function
|
|
436 HiLink perlFunctionPrototype perlFunction
|
|
437 HiLink perlComment Comment
|
|
438 HiLink perlTodo Todo
|
|
439 if exists("perl_string_as_statement")
|
|
440 HiLink perlStringStartEnd perlStatement
|
|
441 else
|
|
442 HiLink perlStringStartEnd perlString
|
|
443 endif
|
|
444 HiLink perlList perlStatement
|
|
445 HiLink perlMisc perlStatement
|
|
446 HiLink perlVarPlain perlIdentifier
|
|
447 HiLink perlFiledescRead perlIdentifier
|
|
448 HiLink perlFiledescStatement perlIdentifier
|
|
449 HiLink perlVarSimpleMember perlIdentifier
|
|
450 HiLink perlVarSimpleMemberName perlString
|
|
451 HiLink perlVarNotInMatches perlIdentifier
|
|
452 HiLink perlVarSlash perlIdentifier
|
557
|
453 HiLink perlVarBang perlIdentifier
|
7
|
454 HiLink perlQQ perlString
|
|
455 if version >= 600
|
|
456 HiLink perlHereDoc perlString
|
|
457 else
|
|
458 HiLink perlHereIdentifier perlStringStartEnd
|
|
459 HiLink perlUntilEOFDQ perlString
|
|
460 HiLink perlUntilEOFSQ perlString
|
|
461 HiLink perlUntilEmptyDQ perlString
|
|
462 HiLink perlUntilEmptySQ perlString
|
557
|
463 HiLink perlUntilEOF perlString
|
7
|
464 endif
|
|
465 HiLink perlStringUnexpanded perlString
|
|
466 HiLink perlSubstitutionSQ perlString
|
|
467 HiLink perlSubstitutionDQ perlString
|
|
468 HiLink perlSubstitutionSlash perlString
|
|
469 HiLink perlSubstitutionHash perlString
|
|
470 HiLink perlSubstitutionBracket perlString
|
|
471 HiLink perlSubstitutionCurly perlString
|
|
472 HiLink perlSubstitutionPling perlString
|
|
473 HiLink perlTranslationSlash perlString
|
|
474 HiLink perlTranslationHash perlString
|
|
475 HiLink perlTranslationBracket perlString
|
|
476 HiLink perlTranslationCurly perlString
|
|
477 HiLink perlMatch perlString
|
|
478 HiLink perlMatchStartEnd perlStatement
|
|
479 HiLink perlFormatName perlIdentifier
|
|
480 HiLink perlFormatField perlString
|
|
481 HiLink perlPackageDecl perlType
|
|
482 HiLink perlStorageClass perlType
|
|
483 HiLink perlPackageRef perlType
|
|
484 HiLink perlStatementPackage perlStatement
|
|
485 HiLink perlStatementSub perlStatement
|
|
486 HiLink perlStatementStorage perlStatement
|
|
487 HiLink perlStatementControl perlStatement
|
|
488 HiLink perlStatementScalar perlStatement
|
|
489 HiLink perlStatementRegexp perlStatement
|
|
490 HiLink perlStatementNumeric perlStatement
|
|
491 HiLink perlStatementList perlStatement
|
|
492 HiLink perlStatementHash perlStatement
|
|
493 HiLink perlStatementIOfunc perlStatement
|
|
494 HiLink perlStatementFiledesc perlStatement
|
|
495 HiLink perlStatementVector perlStatement
|
|
496 HiLink perlStatementFiles perlStatement
|
|
497 HiLink perlStatementFlow perlStatement
|
|
498 HiLink perlStatementScope perlStatement
|
557
|
499 HiLink perlStatementInclude perlInclude
|
7
|
500 HiLink perlStatementProc perlStatement
|
|
501 HiLink perlStatementSocket perlStatement
|
|
502 HiLink perlStatementIPC perlStatement
|
|
503 HiLink perlStatementNetwork perlStatement
|
|
504 HiLink perlStatementPword perlStatement
|
|
505 HiLink perlStatementTime perlStatement
|
|
506 HiLink perlStatementMisc perlStatement
|
|
507 HiLink perlStatementNew perlStatement
|
|
508 HiLink perlFunctionName perlIdentifier
|
|
509 HiLink perlMethod perlIdentifier
|
|
510 HiLink perlFunctionPRef perlType
|
|
511 HiLink perlPOD perlComment
|
|
512 HiLink perlShellCommand perlString
|
|
513 HiLink perlSpecialAscii perlSpecial
|
|
514 HiLink perlSpecialDollar perlSpecial
|
|
515 HiLink perlSpecialString perlSpecial
|
|
516 HiLink perlSpecialStringU perlSpecial
|
|
517 HiLink perlSpecialMatch perlSpecial
|
|
518 HiLink perlSpecialBEOM perlSpecial
|
|
519 HiLink perlDATA perlComment
|
557
|
520
|
|
521 HiLink perlParens Error
|
|
522
|
7
|
523 " Possible errors
|
|
524 HiLink perlNotEmptyLine Error
|
|
525 HiLink perlElseIfError Error
|
|
526
|
|
527 delcommand HiLink
|
|
528 endif
|
|
529
|
|
530 " Syncing to speed up processing
|
|
531 "
|
|
532 if !exists("perl_no_sync_on_sub")
|
|
533 syn sync match perlSync grouphere NONE "^\s*\<package\s"
|
|
534 syn sync match perlSync grouphere perlFunction "^\s*\<sub\s"
|
|
535 syn sync match perlSync grouphere NONE "^}"
|
|
536 endif
|
|
537
|
|
538 if !exists("perl_no_sync_on_global_var")
|
|
539 syn sync match perlSync grouphere NONE "^$\I[[:alnum:]_:]+\s*=\s*{"
|
|
540 syn sync match perlSync grouphere NONE "^[@%]\I[[:alnum:]_:]+\s*=\s*("
|
|
541 endif
|
|
542
|
|
543 if exists("perl_sync_dist")
|
|
544 execute "syn sync maxlines=" . perl_sync_dist
|
|
545 else
|
|
546 syn sync maxlines=100
|
|
547 endif
|
|
548
|
|
549 syn sync match perlSyncPOD grouphere perlPOD "^=pod"
|
|
550 syn sync match perlSyncPOD grouphere perlPOD "^=head"
|
|
551 syn sync match perlSyncPOD grouphere perlPOD "^=item"
|
|
552 syn sync match perlSyncPOD grouphere NONE "^=cut"
|
|
553
|
|
554 let b:current_syntax = "perl"
|
|
555
|
|
556 " vim: ts=8
|