Add Perl language files
This commit is contained in:
parent
9d92f10375
commit
2686fb60f4
@ -51,6 +51,7 @@ Optionally download one of the [releases](https://github.com/sheerun/vim-polyglo
|
|||||||
- [nginx](https://github.com/mutewinter/nginx.vim) (syntax, ftdetect)
|
- [nginx](https://github.com/mutewinter/nginx.vim) (syntax, ftdetect)
|
||||||
- [ocaml](https://github.com/jrk/vim-ocaml) (syntax, indent, ftplugin)
|
- [ocaml](https://github.com/jrk/vim-ocaml) (syntax, indent, ftplugin)
|
||||||
- [octave](https://github.com/vim-scripts/octave.vim--) (syntax)
|
- [octave](https://github.com/vim-scripts/octave.vim--) (syntax)
|
||||||
|
- [perl](https://github.com/vim-perl/vim-perl) (syntax, indent, ftplugin, ftdetect)
|
||||||
- [php](https://github.com/StanAngeloff/php.vim) (syntax)
|
- [php](https://github.com/StanAngeloff/php.vim) (syntax)
|
||||||
- [puppet](https://github.com/ajf/puppet-vim) (syntax, indent, ftplugin, ftdetect)
|
- [puppet](https://github.com/ajf/puppet-vim) (syntax, indent, ftplugin, ftdetect)
|
||||||
- [protobuf](https://github.com/uarun/vim-protobuf) (syntax, ftdetect)
|
- [protobuf](https://github.com/uarun/vim-protobuf) (syntax, ftdetect)
|
||||||
|
1
build
1
build
@ -91,6 +91,7 @@ PACKS="
|
|||||||
nginx:mutewinter/nginx.vim
|
nginx:mutewinter/nginx.vim
|
||||||
ocaml:jrk/vim-ocaml
|
ocaml:jrk/vim-ocaml
|
||||||
octave:vim-scripts/octave.vim--
|
octave:vim-scripts/octave.vim--
|
||||||
|
perl:vim-perl/vim-perl
|
||||||
php:StanAngeloff/php.vim
|
php:StanAngeloff/php.vim
|
||||||
puppet:ajf/puppet-vim
|
puppet:ajf/puppet-vim
|
||||||
protobuf:uarun/vim-protobuf
|
protobuf:uarun/vim-protobuf
|
||||||
|
88
ftplugin/perl.vim
Normal file
88
ftplugin/perl.vim
Normal file
@ -0,0 +1,88 @@
|
|||||||
|
" Vim filetype plugin file
|
||||||
|
" Language: Perl
|
||||||
|
" Maintainer: vim-perl <vim-perl@googlegroups.com>
|
||||||
|
" Homepage: http://github.com/vim-perl/vim-perl
|
||||||
|
" Bugs/requests: http://github.com/vim-perl/vim-perl/issues
|
||||||
|
" Last Change: {{LAST_CHANGE}}
|
||||||
|
|
||||||
|
if exists("b:did_ftplugin") | finish | endif
|
||||||
|
let b:did_ftplugin = 1
|
||||||
|
|
||||||
|
" Make sure the continuation lines below do not cause problems in
|
||||||
|
" compatibility mode.
|
||||||
|
let s:save_cpo = &cpo
|
||||||
|
set cpo-=C
|
||||||
|
|
||||||
|
setlocal formatoptions-=t
|
||||||
|
setlocal formatoptions+=crqol
|
||||||
|
setlocal keywordprg=perldoc\ -f
|
||||||
|
|
||||||
|
setlocal comments=:#
|
||||||
|
setlocal commentstring=#%s
|
||||||
|
|
||||||
|
" Change the browse dialog on Win32 to show mainly Perl-related files
|
||||||
|
if has("gui_win32")
|
||||||
|
let b:browsefilter = "Perl Source Files (*.pl)\t*.pl\n" .
|
||||||
|
\ "Perl Modules (*.pm)\t*.pm\n" .
|
||||||
|
\ "Perl Documentation Files (*.pod)\t*.pod\n" .
|
||||||
|
\ "All Files (*.*)\t*.*\n"
|
||||||
|
endif
|
||||||
|
|
||||||
|
" Provided by Ned Konz <ned at bike-nomad dot com>
|
||||||
|
"---------------------------------------------
|
||||||
|
setlocal include=\\<\\(use\\\|require\\)\\>
|
||||||
|
setlocal includeexpr=substitute(substitute(substitute(v:fname,'::','/','g'),'->\*','',''),'$','.pm','')
|
||||||
|
setlocal define=[^A-Za-z_]
|
||||||
|
|
||||||
|
" The following line changes a global variable but is necessary to make
|
||||||
|
" gf and similar commands work. The change to iskeyword was incorrect.
|
||||||
|
" Thanks to Andrew Pimlott for pointing out the problem. If this causes a
|
||||||
|
" problem for you, add an after/ftplugin/perl.vim file that contains
|
||||||
|
" set isfname-=:
|
||||||
|
set isfname+=:
|
||||||
|
set iskeyword+=:
|
||||||
|
|
||||||
|
" Set this once, globally.
|
||||||
|
if !exists("perlpath")
|
||||||
|
if executable("perl")
|
||||||
|
try
|
||||||
|
if &shellxquote != '"'
|
||||||
|
let perlpath = system('perl -e "print join(q/,/,@INC)"')
|
||||||
|
else
|
||||||
|
let perlpath = system("perl -e 'print join(q/,/,@INC)'")
|
||||||
|
endif
|
||||||
|
let perlpath = substitute(perlpath,',.$',',,','')
|
||||||
|
catch /E145:/
|
||||||
|
let perlpath = ".,,"
|
||||||
|
endtry
|
||||||
|
else
|
||||||
|
" If we can't call perl to get its path, just default to using the
|
||||||
|
" current directory and the directory of the current file.
|
||||||
|
let perlpath = ".,,"
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
|
||||||
|
" Append perlpath to the existing path value, if it is set. Since we don't
|
||||||
|
" use += to do it because of the commas in perlpath, we have to handle the
|
||||||
|
" global / local settings, too.
|
||||||
|
if &l:path == ""
|
||||||
|
if &g:path == ""
|
||||||
|
let &l:path=perlpath
|
||||||
|
else
|
||||||
|
let &l:path=&g:path.",".perlpath
|
||||||
|
endif
|
||||||
|
else
|
||||||
|
let &l:path=&l:path.",".perlpath
|
||||||
|
endif
|
||||||
|
"---------------------------------------------
|
||||||
|
|
||||||
|
" Undo the stuff we changed.
|
||||||
|
let b:undo_ftplugin = "setlocal fo< com< cms< inc< inex< def< isf< kp< path<" .
|
||||||
|
\ " | unlet! b:browsefilter"
|
||||||
|
|
||||||
|
" proper matching for matchit plugin
|
||||||
|
let b:match_skip = 's:comment\|string\|perlQQ\|perlShellCommand\|perlHereDoc\|perlSubstitution\|perlTranslation\|perlMatch\|perlFormatField'
|
||||||
|
|
||||||
|
" Restore the saved compatibility options.
|
||||||
|
let &cpo = s:save_cpo
|
||||||
|
unlet s:save_cpo
|
77
ftplugin/perl6.vim
Normal file
77
ftplugin/perl6.vim
Normal file
@ -0,0 +1,77 @@
|
|||||||
|
" Vim filetype plugin file
|
||||||
|
" Language: Perl 6
|
||||||
|
" Maintainer: vim-perl <vim-perl@googlegroups.com>
|
||||||
|
" Homepage: http://github.com/vim-perl/vim-perl
|
||||||
|
" Bugs/requests: http://github.com/vim-perl/vim-perl/issues
|
||||||
|
" Last Change: {{LAST_CHANGE}}
|
||||||
|
" Contributors: Hinrik Örn Sigurðsson <hinrik.sig@gmail.com>
|
||||||
|
"
|
||||||
|
" Based on ftplugin/perl.vim by Dan Sharp <dwsharp at hotmail dot com>
|
||||||
|
|
||||||
|
if exists("b:did_ftplugin") | finish | endif
|
||||||
|
let b:did_ftplugin = 1
|
||||||
|
|
||||||
|
" Make sure the continuation lines below do not cause problems in
|
||||||
|
" compatibility mode.
|
||||||
|
let s:save_cpo = &cpo
|
||||||
|
set cpo-=C
|
||||||
|
|
||||||
|
setlocal formatoptions-=t
|
||||||
|
setlocal formatoptions+=crqol
|
||||||
|
setlocal keywordprg=p6doc
|
||||||
|
|
||||||
|
setlocal comments=:#
|
||||||
|
setlocal commentstring=#%s
|
||||||
|
|
||||||
|
" Change the browse dialog on Win32 to show mainly Perl-related files
|
||||||
|
if has("gui_win32")
|
||||||
|
let b:browsefilter = "Perl Source Files (*.pl)\t*.pl\n" .
|
||||||
|
\ "Perl Modules (*.pm)\t*.pm\n" .
|
||||||
|
\ "Perl Documentation Files (*.pod)\t*.pod\n" .
|
||||||
|
\ "All Files (*.*)\t*.*\n"
|
||||||
|
endif
|
||||||
|
|
||||||
|
" Provided by Ned Konz <ned at bike-nomad dot com>
|
||||||
|
"---------------------------------------------
|
||||||
|
setlocal include=\\<\\(use\\\|require\\)\\>
|
||||||
|
setlocal includeexpr=substitute(substitute(v:fname,'::','/','g'),'$','.pm','')
|
||||||
|
setlocal define=[^A-Za-z_]
|
||||||
|
|
||||||
|
" The following line changes a global variable but is necessary to make
|
||||||
|
" gf and similar commands work. Thanks to Andrew Pimlott for pointing out
|
||||||
|
" the problem. If this causes a " problem for you, add an
|
||||||
|
" after/ftplugin/perl6.vim file that contains
|
||||||
|
" set isfname-=:
|
||||||
|
set isfname+=:
|
||||||
|
setlocal iskeyword=48-57,_,A-Z,a-z,:,-
|
||||||
|
|
||||||
|
" Set this once, globally.
|
||||||
|
if !exists("perlpath")
|
||||||
|
if executable("perl6")
|
||||||
|
try
|
||||||
|
if &shellxquote != '"'
|
||||||
|
let perlpath = system('perl6 -e "@*INC.join(q/,/).say"')
|
||||||
|
else
|
||||||
|
let perlpath = system("perl6 -e '@*INC.join(q/,/).say'")
|
||||||
|
endif
|
||||||
|
let perlpath = substitute(perlpath,',.$',',,','')
|
||||||
|
catch /E145:/
|
||||||
|
let perlpath = ".,,"
|
||||||
|
endtry
|
||||||
|
else
|
||||||
|
" If we can't call perl to get its path, just default to using the
|
||||||
|
" current directory and the directory of the current file.
|
||||||
|
let perlpath = ".,,"
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
|
||||||
|
let &l:path=perlpath
|
||||||
|
"---------------------------------------------
|
||||||
|
|
||||||
|
" Undo the stuff we changed.
|
||||||
|
let b:undo_ftplugin = "setlocal fo< com< cms< inc< inex< def< isk<" .
|
||||||
|
\ " | unlet! b:browsefilter"
|
||||||
|
|
||||||
|
" Restore the saved compatibility options.
|
||||||
|
let &cpo = s:save_cpo
|
||||||
|
unlet s:save_cpo
|
13
ftplugin/tt2html.vim
Normal file
13
ftplugin/tt2html.vim
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
" Language: TT2 embedded with HTML
|
||||||
|
" Maintainer: vim-perl <vim-perl@googlegroups.com>
|
||||||
|
" Homepage: http://github.com/vim-perl/vim-perl
|
||||||
|
" Bugs/requests: http://github.com/vim-perl/vim-perl/issues
|
||||||
|
" Last Change: {{LAST_CHANGE}}
|
||||||
|
|
||||||
|
" Only do this when not done yet for this buffer
|
||||||
|
if exists("b:did_ftplugin")
|
||||||
|
finish
|
||||||
|
endif
|
||||||
|
|
||||||
|
" Just use the HTML plugin for now.
|
||||||
|
runtime! ftplugin/html.vim ftplugin/html_*.vim ftplugin/html/*.vim
|
14
ftplugin/xs.vim
Normal file
14
ftplugin/xs.vim
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
" Vim filetype plugin file
|
||||||
|
" Language: XS (Perl extension interface language)
|
||||||
|
" Maintainer: vim-perl <vim-perl@googlegroups.com>
|
||||||
|
" Homepage: http://github.com/vim-perl/vim-perl
|
||||||
|
" Bugs/requests: http://github.com/vim-perl/vim-perl/issues
|
||||||
|
" Last Change: {{LAST_CHANGE}}
|
||||||
|
|
||||||
|
" Only do this when not done yet for this buffer
|
||||||
|
if exists("b:did_ftplugin")
|
||||||
|
finish
|
||||||
|
endif
|
||||||
|
|
||||||
|
" Just use the C plugin for now.
|
||||||
|
runtime! ftplugin/c.vim ftplugin/c_*.vim ftplugin/c/*.vim
|
183
indent/perl.vim
Normal file
183
indent/perl.vim
Normal file
@ -0,0 +1,183 @@
|
|||||||
|
" Vim indent file
|
||||||
|
" Language: Perl 5
|
||||||
|
" Maintainer: vim-perl <vim-perl@googlegroups.com>
|
||||||
|
" Homepage: http://github.com/vim-perl/vim-perl
|
||||||
|
" Bugs/requests: http://github.com/vim-perl/vim-perl/issues
|
||||||
|
" Last Change: {{LAST_CHANGE}}
|
||||||
|
|
||||||
|
" Suggestions and improvements by :
|
||||||
|
" Aaron J. Sherman (use syntax for hints)
|
||||||
|
" Artem Chuprina (play nice with folding)
|
||||||
|
|
||||||
|
" TODO things that are not or not properly indented (yet) :
|
||||||
|
" - Continued statements
|
||||||
|
" print "foo",
|
||||||
|
" "bar";
|
||||||
|
" print "foo"
|
||||||
|
" if bar();
|
||||||
|
" - Multiline regular expressions (m//x)
|
||||||
|
" (The following probably needs modifying the perl syntax file)
|
||||||
|
" - qw() lists
|
||||||
|
" - Heredocs with terminators that don't match \I\i*
|
||||||
|
|
||||||
|
" Only load this indent file when no other was loaded.
|
||||||
|
if exists("b:did_indent")
|
||||||
|
finish
|
||||||
|
endif
|
||||||
|
let b:did_indent = 1
|
||||||
|
|
||||||
|
" Is syntax highlighting active ?
|
||||||
|
let b:indent_use_syntax = has("syntax")
|
||||||
|
|
||||||
|
setlocal indentexpr=GetPerlIndent()
|
||||||
|
setlocal indentkeys+=0=,0),0],0=or,0=and
|
||||||
|
if !b:indent_use_syntax
|
||||||
|
setlocal indentkeys+=0=EO
|
||||||
|
endif
|
||||||
|
|
||||||
|
let s:cpo_save = &cpo
|
||||||
|
set cpo-=C
|
||||||
|
|
||||||
|
function! GetPerlIndent()
|
||||||
|
|
||||||
|
" Get the line to be indented
|
||||||
|
let cline = getline(v:lnum)
|
||||||
|
|
||||||
|
" Indent POD markers to column 0
|
||||||
|
if cline =~ '^\s*=\L\@!'
|
||||||
|
return 0
|
||||||
|
endif
|
||||||
|
|
||||||
|
" Don't reindent comments on first column
|
||||||
|
if cline =~ '^#.'
|
||||||
|
return 0
|
||||||
|
endif
|
||||||
|
|
||||||
|
" Get current syntax item at the line's first char
|
||||||
|
let csynid = ''
|
||||||
|
if b:indent_use_syntax
|
||||||
|
let csynid = synIDattr(synID(v:lnum,1,0),"name")
|
||||||
|
endif
|
||||||
|
|
||||||
|
" Don't reindent POD and heredocs
|
||||||
|
if csynid == "perlPOD" || csynid == "perlHereDoc" || csynid =~ "^pod"
|
||||||
|
return indent(v:lnum)
|
||||||
|
endif
|
||||||
|
|
||||||
|
" Indent end-of-heredocs markers to column 0
|
||||||
|
if b:indent_use_syntax
|
||||||
|
" Assumes that an end-of-heredoc marker matches \I\i* to avoid
|
||||||
|
" confusion with other types of strings
|
||||||
|
if csynid == "perlStringStartEnd" && cline =~ '^\I\i*$'
|
||||||
|
return 0
|
||||||
|
endif
|
||||||
|
else
|
||||||
|
" Without syntax hints, assume that end-of-heredocs markers begin with EO
|
||||||
|
if cline =~ '^\s*EO'
|
||||||
|
return 0
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
|
||||||
|
" Now get the indent of the previous perl line.
|
||||||
|
|
||||||
|
" Find a non-blank line above the current line.
|
||||||
|
let lnum = prevnonblank(v:lnum - 1)
|
||||||
|
" Hit the start of the file, use zero indent.
|
||||||
|
if lnum == 0
|
||||||
|
return 0
|
||||||
|
endif
|
||||||
|
let line = getline(lnum)
|
||||||
|
let ind = indent(lnum)
|
||||||
|
" Skip heredocs, POD, and comments on 1st column
|
||||||
|
if b:indent_use_syntax
|
||||||
|
let skippin = 2
|
||||||
|
while skippin
|
||||||
|
let synid = synIDattr(synID(lnum,1,0),"name")
|
||||||
|
if (synid == "perlStringStartEnd" && line =~ '^\I\i*$')
|
||||||
|
\ || (skippin != 2 && synid == "perlPOD")
|
||||||
|
\ || (skippin != 2 && synid == "perlHereDoc")
|
||||||
|
\ || synid == "perlComment"
|
||||||
|
\ || synid =~ "^pod"
|
||||||
|
let lnum = prevnonblank(lnum - 1)
|
||||||
|
if lnum == 0
|
||||||
|
return 0
|
||||||
|
endif
|
||||||
|
let line = getline(lnum)
|
||||||
|
let ind = indent(lnum)
|
||||||
|
let skippin = 1
|
||||||
|
else
|
||||||
|
let skippin = 0
|
||||||
|
endif
|
||||||
|
endwhile
|
||||||
|
else
|
||||||
|
if line =~ "^EO"
|
||||||
|
let lnum = search("<<[\"']\\=EO", "bW")
|
||||||
|
let line = getline(lnum)
|
||||||
|
let ind = indent(lnum)
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
|
||||||
|
" Indent blocks enclosed by {}, (), or []
|
||||||
|
if b:indent_use_syntax
|
||||||
|
" Find a real opening brace
|
||||||
|
" NOTE: Unlike Perl character classes, we do NOT need to escape the
|
||||||
|
" closing brackets with a backslash. Doing so just puts a backslash
|
||||||
|
" in the character class and causes sorrow. Instead, put the closing
|
||||||
|
" bracket as the first character in the class.
|
||||||
|
let braceclass = '[][(){}]'
|
||||||
|
let bracepos = match(line, braceclass, matchend(line, '^\s*[])}]'))
|
||||||
|
while bracepos != -1
|
||||||
|
let synid = synIDattr(synID(lnum, bracepos + 1, 0), "name")
|
||||||
|
" If the brace is highlighted in one of those groups, indent it.
|
||||||
|
" 'perlHereDoc' is here only to handle the case '&foo(<<EOF)'.
|
||||||
|
if synid == ""
|
||||||
|
\ || synid == "perlMatchStartEnd"
|
||||||
|
\ || synid == "perlHereDoc"
|
||||||
|
\ || synid == "perlBraces"
|
||||||
|
\ || synid =~ "^perlFiledescStatement"
|
||||||
|
\ || synid =~ '^perl\(Sub\|Block\|Package\)Fold'
|
||||||
|
let brace = strpart(line, bracepos, 1)
|
||||||
|
if brace == '(' || brace == '{' || brace == '['
|
||||||
|
let ind = ind + &sw
|
||||||
|
else
|
||||||
|
let ind = ind - &sw
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
let bracepos = match(line, braceclass, bracepos + 1)
|
||||||
|
endwhile
|
||||||
|
let bracepos = matchend(cline, '^\s*[])}]')
|
||||||
|
if bracepos != -1
|
||||||
|
let synid = synIDattr(synID(v:lnum, bracepos, 0), "name")
|
||||||
|
if synid == ""
|
||||||
|
\ || synid == "perlMatchStartEnd"
|
||||||
|
\ || synid == "perlBraces"
|
||||||
|
\ || synid =~ '^perl\(Sub\|Block\|Package\)Fold'
|
||||||
|
let ind = ind - &sw
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
else
|
||||||
|
if line =~ '[{[(]\s*\(#[^])}]*\)\=$'
|
||||||
|
let ind = ind + &sw
|
||||||
|
endif
|
||||||
|
if cline =~ '^\s*[])}]'
|
||||||
|
let ind = ind - &sw
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
|
||||||
|
" Indent lines that begin with 'or' or 'and'
|
||||||
|
if cline =~ '^\s*\(or\|and\)\>'
|
||||||
|
if line !~ '^\s*\(or\|and\)\>'
|
||||||
|
let ind = ind + &sw
|
||||||
|
endif
|
||||||
|
elseif line =~ '^\s*\(or\|and\)\>'
|
||||||
|
let ind = ind - &sw
|
||||||
|
endif
|
||||||
|
|
||||||
|
return ind
|
||||||
|
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
let &cpo = s:cpo_save
|
||||||
|
unlet s:cpo_save
|
||||||
|
|
||||||
|
" vim:ts=8:sts=4:sw=4:expandtab:ft=vim
|
132
indent/perl6.vim
Normal file
132
indent/perl6.vim
Normal file
@ -0,0 +1,132 @@
|
|||||||
|
" Vim indent file
|
||||||
|
" Language: Perl 6
|
||||||
|
" Maintainer: vim-perl <vim-perl@googlegroups.com>
|
||||||
|
" Homepage: http://github.com/vim-perl/vim-perl
|
||||||
|
" Bugs/requests: http://github.com/vim-perl/vim-perl/issues
|
||||||
|
" Last Change: {{LAST_CHANGE}}
|
||||||
|
" Contributors: Andy Lester <andy@petdance.com>
|
||||||
|
" Hinrik Örn Sigurðsson <hinrik.sig@gmail.com>
|
||||||
|
"
|
||||||
|
" Adapted from indent/perl.vim by Rafael Garcia-Suarez <rgarciasuarez@free.fr>
|
||||||
|
|
||||||
|
" Suggestions and improvements by :
|
||||||
|
" Aaron J. Sherman (use syntax for hints)
|
||||||
|
" Artem Chuprina (play nice with folding)
|
||||||
|
" TODO:
|
||||||
|
" This file still relies on stuff from the Perl 5 syntax file, which Perl 6
|
||||||
|
" does not use.
|
||||||
|
"
|
||||||
|
" Things that are not or not properly indented (yet) :
|
||||||
|
" - Continued statements
|
||||||
|
" print "foo",
|
||||||
|
" "bar";
|
||||||
|
" print "foo"
|
||||||
|
" if bar();
|
||||||
|
" - Multiline regular expressions (m//x)
|
||||||
|
" (The following probably needs modifying the perl syntax file)
|
||||||
|
" - qw() lists
|
||||||
|
" - Heredocs with terminators that don't match \I\i*
|
||||||
|
|
||||||
|
" Only load this indent file when no other was loaded.
|
||||||
|
if exists("b:did_indent")
|
||||||
|
finish
|
||||||
|
endif
|
||||||
|
let b:did_indent = 1
|
||||||
|
|
||||||
|
" Is syntax highlighting active ?
|
||||||
|
let b:indent_use_syntax = has("syntax")
|
||||||
|
|
||||||
|
setlocal indentexpr=GetPerl6Indent()
|
||||||
|
|
||||||
|
" we reset it first because the Perl 5 indent file might have been loaded due
|
||||||
|
" to a .pl/pm file extension, and indent files don't clean up afterwards
|
||||||
|
setlocal indentkeys&
|
||||||
|
|
||||||
|
setlocal indentkeys+=0=,0),0],0>,0»,0=or,0=and
|
||||||
|
if !b:indent_use_syntax
|
||||||
|
setlocal indentkeys+=0=EO
|
||||||
|
endif
|
||||||
|
|
||||||
|
let s:cpo_save = &cpo
|
||||||
|
set cpo-=C
|
||||||
|
|
||||||
|
function! GetPerl6Indent()
|
||||||
|
|
||||||
|
" Get the line to be indented
|
||||||
|
let cline = getline(v:lnum)
|
||||||
|
|
||||||
|
" Indent POD markers to column 0
|
||||||
|
if cline =~ '^\s*=\L\@!'
|
||||||
|
return 0
|
||||||
|
endif
|
||||||
|
|
||||||
|
" Don't reindent coments on first column
|
||||||
|
if cline =~ '^#'
|
||||||
|
return 0
|
||||||
|
endif
|
||||||
|
|
||||||
|
" Get current syntax item at the line's first char
|
||||||
|
let csynid = ''
|
||||||
|
if b:indent_use_syntax
|
||||||
|
let csynid = synIDattr(synID(v:lnum,1,0),"name")
|
||||||
|
endif
|
||||||
|
|
||||||
|
" Don't reindent POD and heredocs
|
||||||
|
if csynid =~ "^p6Pod"
|
||||||
|
return indent(v:lnum)
|
||||||
|
endif
|
||||||
|
|
||||||
|
|
||||||
|
" Now get the indent of the previous perl line.
|
||||||
|
|
||||||
|
" Find a non-blank line above the current line.
|
||||||
|
let lnum = prevnonblank(v:lnum - 1)
|
||||||
|
" Hit the start of the file, use zero indent.
|
||||||
|
if lnum == 0
|
||||||
|
return 0
|
||||||
|
endif
|
||||||
|
let line = getline(lnum)
|
||||||
|
let ind = indent(lnum)
|
||||||
|
" Skip heredocs, POD, and comments on 1st column
|
||||||
|
if b:indent_use_syntax
|
||||||
|
let skippin = 2
|
||||||
|
while skippin
|
||||||
|
let synid = synIDattr(synID(lnum,1,0),"name")
|
||||||
|
if (synid =~ "^p6Pod" || synid =~ "p6Comment")
|
||||||
|
let lnum = prevnonblank(lnum - 1)
|
||||||
|
if lnum == 0
|
||||||
|
return 0
|
||||||
|
endif
|
||||||
|
let line = getline(lnum)
|
||||||
|
let ind = indent(lnum)
|
||||||
|
let skippin = 1
|
||||||
|
else
|
||||||
|
let skippin = 0
|
||||||
|
endif
|
||||||
|
endwhile
|
||||||
|
endif
|
||||||
|
|
||||||
|
if line =~ '[<«\[{(]\s*\(#[^)}\]»>]*\)\=$'
|
||||||
|
let ind = ind + &sw
|
||||||
|
endif
|
||||||
|
if cline =~ '^\s*[)}\]»>]'
|
||||||
|
let ind = ind - &sw
|
||||||
|
endif
|
||||||
|
|
||||||
|
" Indent lines that begin with 'or' or 'and'
|
||||||
|
if cline =~ '^\s*\(or\|and\)\>'
|
||||||
|
if line !~ '^\s*\(or\|and\)\>'
|
||||||
|
let ind = ind + &sw
|
||||||
|
endif
|
||||||
|
elseif line =~ '^\s*\(or\|and\)\>'
|
||||||
|
let ind = ind - &sw
|
||||||
|
endif
|
||||||
|
|
||||||
|
return ind
|
||||||
|
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
let &cpo = s:cpo_save
|
||||||
|
unlet s:cpo_save
|
||||||
|
|
||||||
|
" vim:ts=8:sts=4:sw=4:expandtab:ft=vim
|
589
syntax/perl.vim
Normal file
589
syntax/perl.vim
Normal file
@ -0,0 +1,589 @@
|
|||||||
|
" Vim syntax file
|
||||||
|
" Language: Perl 5
|
||||||
|
" Maintainer: vim-perl <vim-perl@googlegroups.com>
|
||||||
|
" Homepage: http://github.com/vim-perl/vim-perl/tree/master
|
||||||
|
" Bugs/requests: http://github.com/vim-perl/vim-perl/issues
|
||||||
|
" Last Change: {{LAST_CHANGE}}
|
||||||
|
" Contributors: Andy Lester <andy@petdance.com>
|
||||||
|
" Hinrik Örn Sigurðsson <hinrik.sig@gmail.com>
|
||||||
|
" Lukas Mai <l.mai.web.de>
|
||||||
|
" Nick Hibma <nick@van-laarhoven.org>
|
||||||
|
" Sonia Heimann <niania@netsurf.org>
|
||||||
|
" Rob Hoelz <rob@hoelz.ro>
|
||||||
|
" and many others.
|
||||||
|
"
|
||||||
|
" Please download the most recent version first, before mailing
|
||||||
|
" any comments.
|
||||||
|
"
|
||||||
|
" The following parameters are available for tuning the
|
||||||
|
" perl syntax highlighting, with defaults given:
|
||||||
|
"
|
||||||
|
" let perl_include_pod = 1
|
||||||
|
" unlet perl_no_scope_in_variables
|
||||||
|
" unlet perl_no_extended_vars
|
||||||
|
" unlet perl_string_as_statement
|
||||||
|
" unlet perl_no_sync_on_sub
|
||||||
|
" unlet perl_no_sync_on_global_var
|
||||||
|
" let perl_sync_dist = 100
|
||||||
|
" unlet perl_fold
|
||||||
|
" unlet perl_fold_blocks
|
||||||
|
" unlet perl_nofold_packages
|
||||||
|
" let perl_nofold_subs = 1
|
||||||
|
" unlet perl_fold_anonymous_subs
|
||||||
|
|
||||||
|
if exists("b:current_syntax")
|
||||||
|
finish
|
||||||
|
endif
|
||||||
|
|
||||||
|
let s:cpo_save = &cpo
|
||||||
|
set cpo&vim
|
||||||
|
|
||||||
|
if exists('®expengine')
|
||||||
|
let s:regexpengine=®expengine
|
||||||
|
set regexpengine=1
|
||||||
|
endif
|
||||||
|
|
||||||
|
" POD starts with ^=<word> and ends with ^=cut
|
||||||
|
|
||||||
|
if !exists("perl_include_pod") || perl_include_pod == 1
|
||||||
|
" Include a while extra syntax file
|
||||||
|
syn include @Pod syntax/pod.vim
|
||||||
|
unlet b:current_syntax
|
||||||
|
if exists("perl_fold")
|
||||||
|
syn region perlPOD start="^=[a-z]" end="^=cut" contains=@Pod,@Spell,perlTodo keepend fold extend
|
||||||
|
syn region perlPOD start="^=cut" end="^=cut" contains=perlTodo keepend fold extend
|
||||||
|
else
|
||||||
|
syn region perlPOD start="^=[a-z]" end="^=cut" contains=@Pod,@Spell,perlTodo keepend
|
||||||
|
syn region perlPOD start="^=cut" end="^=cut" contains=perlTodo keepend
|
||||||
|
endif
|
||||||
|
else
|
||||||
|
" Use only the bare minimum of rules
|
||||||
|
if exists("perl_fold")
|
||||||
|
syn region perlPOD start="^=[a-z]" end="^=cut" fold
|
||||||
|
else
|
||||||
|
syn region perlPOD start="^=[a-z]" end="^=cut"
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
|
||||||
|
|
||||||
|
syn cluster perlTop contains=TOP
|
||||||
|
|
||||||
|
syn region perlBraces start="{" end="}" transparent extend
|
||||||
|
|
||||||
|
" All keywords
|
||||||
|
"
|
||||||
|
syn match perlConditional "\<\%(if\|elsif\|unless\|given\|when\|default\)\>"
|
||||||
|
syn match perlConditional "\<else\%(\%(\_s\*if\>\)\|\>\)" contains=perlElseIfError skipwhite skipnl skipempty
|
||||||
|
syn match perlRepeat "\<\%(while\|for\%(each\)\=\|do\|until\|continue\)\>"
|
||||||
|
syn match perlOperator "\<\%(defined\|undef\|eq\|ne\|[gl][et]\|cmp\|not\|and\|or\|xor\|not\|bless\|ref\|do\)\>"
|
||||||
|
" for some reason, adding this as the nextgroup for perlControl fixes BEGIN
|
||||||
|
" folding issues...
|
||||||
|
syn match perlFakeGroup "" contained
|
||||||
|
syn match perlControl "\<\%(BEGIN\|CHECK\|INIT\|END\|UNITCHECK\)\>\_s*" nextgroup=perlFakeGroup
|
||||||
|
|
||||||
|
syn match perlStatementStorage "\<\%(my\|our\|local\|state\)\>"
|
||||||
|
syn match perlStatementControl "\<\%(return\|last\|next\|redo\|goto\|break\)\>"
|
||||||
|
syn match perlStatementScalar "\<\%(chom\=p\|chr\|crypt\|r\=index\|lc\%(first\)\=\|length\|ord\|pack\|sprintf\|substr\|uc\%(first\)\=\)\>"
|
||||||
|
syn match perlStatementRegexp "\<\%(pos\|quotemeta\|split\|study\)\>"
|
||||||
|
syn match perlStatementNumeric "\<\%(abs\|atan2\|cos\|exp\|hex\|int\|log\|oct\|rand\|sin\|sqrt\|srand\)\>"
|
||||||
|
syn match perlStatementList "\<\%(splice\|unshift\|shift\|push\|pop\|join\|reverse\|grep\|map\|sort\|unpack\)\>"
|
||||||
|
syn match perlStatementHash "\<\%(delete\|each\|exists\|keys\|values\)\>"
|
||||||
|
syn match perlStatementIOfunc "\<\%(syscall\|dbmopen\|dbmclose\)\>"
|
||||||
|
syn match perlStatementFiledesc "\<\%(binmode\|close\%(dir\)\=\|eof\|fileno\|getc\|lstat\|printf\=\|read\%(dir\|line\|pipe\)\|rewinddir\|say\|select\|stat\|tell\%(dir\)\=\|write\)\>" nextgroup=perlFiledescStatementNocomma skipwhite
|
||||||
|
syn match perlStatementFiledesc "\<\%(fcntl\|flock\|ioctl\|open\%(dir\)\=\|read\|seek\%(dir\)\=\|sys\%(open\|read\|seek\|write\)\|truncate\)\>" nextgroup=perlFiledescStatementComma skipwhite
|
||||||
|
syn match perlStatementVector "\<vec\>"
|
||||||
|
syn match perlStatementFiles "\<\%(ch\%(dir\|mod\|own\|root\)\|glob\|link\|mkdir\|readlink\|rename\|rmdir\|symlink\|umask\|unlink\|utime\)\>"
|
||||||
|
syn match perlStatementFiles "-[rwxoRWXOezsfdlpSbctugkTBMAC]\>"
|
||||||
|
syn match perlStatementFlow "\<\%(caller\|die\|dump\|eval\|exit\|wantarray\)\>"
|
||||||
|
syn match perlStatementInclude "\<\%(require\|import\)\>"
|
||||||
|
syn match perlStatementInclude "\<\%(use\|no\)\s\+\%(\%(attributes\|attrs\|autouse\|parent\|base\|big\%(int\|num\|rat\)\|blib\|bytes\|charnames\|constant\|diagnostics\|encoding\%(::warnings\)\=\|feature\|fields\|filetest\|if\|integer\|less\|lib\|locale\|mro\|open\|ops\|overload\|re\|sigtrap\|sort\|strict\|subs\|threads\%(::shared\)\=\|utf8\|vars\|version\|vmsish\|warnings\%(::register\)\=\)\>\)\="
|
||||||
|
syn match perlStatementProc "\<\%(alarm\|exec\|fork\|get\%(pgrp\|ppid\|priority\)\|kill\|pipe\|set\%(pgrp\|priority\)\|sleep\|system\|times\|wait\%(pid\)\=\)\>"
|
||||||
|
syn match perlStatementSocket "\<\%(accept\|bind\|connect\|get\%(peername\|sock\%(name\|opt\)\)\|listen\|recv\|send\|setsockopt\|shutdown\|socket\%(pair\)\=\)\>"
|
||||||
|
syn match perlStatementIPC "\<\%(msg\%(ctl\|get\|rcv\|snd\)\|sem\%(ctl\|get\|op\)\|shm\%(ctl\|get\|read\|write\)\)\>"
|
||||||
|
syn match perlStatementNetwork "\<\%(\%(end\|[gs]et\)\%(host\|net\|proto\|serv\)ent\|get\%(\%(host\|net\)by\%(addr\|name\)\|protoby\%(name\|number\)\|servby\%(name\|port\)\)\)\>"
|
||||||
|
syn match perlStatementPword "\<\%(get\%(pw\%(uid\|nam\)\|gr\%(gid\|nam\)\|login\)\)\|\%(end\|[gs]et\)\%(pw\|gr\)ent\>"
|
||||||
|
syn match perlStatementTime "\<\%(gmtime\|localtime\|time\)\>"
|
||||||
|
|
||||||
|
syn match perlStatementMisc "\<\%(warn\|format\|formline\|reset\|scalar\|prototype\|lock\|tied\=\|untie\)\>"
|
||||||
|
|
||||||
|
syn keyword perlTodo TODO TODO: TBD TBD: FIXME FIXME: XXX XXX: NOTE NOTE: contained
|
||||||
|
|
||||||
|
syn region perlStatementIndirObjWrap matchgroup=perlStatementIndirObj start="\<\%(map\|grep\|sort\|printf\=\|say\|system\|exec\)\>\s*{" end="}" contains=@perlTop,perlBraces extend
|
||||||
|
|
||||||
|
syn match perlLabel "^\s*\h\w*\s*::\@!\%(\<v\d\+\s*:\)\@<!"
|
||||||
|
|
||||||
|
" Perl Identifiers.
|
||||||
|
"
|
||||||
|
" Should be cleaned up to better handle identifiers in particular situations
|
||||||
|
" (in hash keys for example)
|
||||||
|
"
|
||||||
|
" Plain identifiers: $foo, @foo, $#foo, %foo, &foo and dereferences $$foo, @$foo, etc.
|
||||||
|
" We do not process complex things such as @{${"foo"}}. Too complicated, and
|
||||||
|
" too slow. And what is after the -> is *not* considered as part of the
|
||||||
|
" variable - there again, too complicated and too slow.
|
||||||
|
|
||||||
|
" Special variables first ($^A, ...) and ($|, $', ...)
|
||||||
|
syn match perlVarPlain "$^[ACDEFHILMNOPRSTVWX]\="
|
||||||
|
syn match perlVarPlain "$[\\\"\[\]'&`+*.,;=%~!?@#$<>(-]"
|
||||||
|
syn match perlVarPlain "%+"
|
||||||
|
syn match perlVarPlain "$\%(0\|[1-9]\d*\)"
|
||||||
|
" Same as above, but avoids confusion in $::foo (equivalent to $main::foo)
|
||||||
|
syn match perlVarPlain "$::\@!"
|
||||||
|
" These variables are not recognized within matches.
|
||||||
|
syn match perlVarNotInMatches "$[|)]"
|
||||||
|
" This variable is not recognized within matches delimited by m//.
|
||||||
|
syn match perlVarSlash "$/"
|
||||||
|
|
||||||
|
" And plain identifiers
|
||||||
|
syn match perlPackageRef "[$@#%*&]\%(\%(::\|'\)\=\I\i*\%(\%(::\|'\)\I\i*\)*\)\=\%(::\|'\)\I"ms=s+1,me=e-1 contained
|
||||||
|
|
||||||
|
" To not highlight packages in variables as a scope reference - i.e. in
|
||||||
|
" $pack::var, pack:: is a scope, just set "perl_no_scope_in_variables"
|
||||||
|
" If you don't want complex things like @{${"foo"}} to be processed,
|
||||||
|
" just set the variable "perl_no_extended_vars"...
|
||||||
|
|
||||||
|
if !exists("perl_no_scope_in_variables")
|
||||||
|
syn match perlVarPlain "\%([@$]\|\$#\)\$*\%(\I\i*\)\=\%(\%(::\|'\)\I\i*\)*\%(::\|\i\@<=\)" contains=perlPackageRef nextgroup=perlVarMember,perlVarSimpleMember,perlMethod
|
||||||
|
syn match perlVarPlain2 "%\$*\%(\I\i*\)\=\%(\%(::\|'\)\I\i*\)*\%(::\|\i\@<=\)" contains=perlPackageRef
|
||||||
|
syn match perlFunctionName "&\$*\%(\I\i*\)\=\%(\%(::\|'\)\I\i*\)*\%(::\|\i\@<=\)" contains=perlPackageRef nextgroup=perlVarMember,perlVarSimpleMember,perlMethod
|
||||||
|
else
|
||||||
|
syn match perlVarPlain "\%([@$]\|\$#\)\$*\%(\I\i*\)\=\%(\%(::\|'\)\I\i*\)*\%(::\|\i\@<=\)" nextgroup=perlVarMember,perlVarSimpleMember,perlMethod
|
||||||
|
syn match perlVarPlain2 "%\$*\%(\I\i*\)\=\%(\%(::\|'\)\I\i*\)*\%(::\|\i\@<=\)"
|
||||||
|
syn match perlFunctionName "&\$*\%(\I\i*\)\=\%(\%(::\|'\)\I\i*\)*\%(::\|\i\@<=\)" nextgroup=perlVarMember,perlVarSimpleMember,perlMethod
|
||||||
|
endif
|
||||||
|
|
||||||
|
if !exists("perl_no_extended_vars")
|
||||||
|
syn cluster perlExpr contains=perlStatementIndirObjWrap,perlStatementScalar,perlStatementRegexp,perlStatementNumeric,perlStatementList,perlStatementHash,perlStatementFiles,perlStatementTime,perlStatementMisc,perlVarPlain,perlVarPlain2,perlVarNotInMatches,perlVarSlash,perlVarBlock,perlVarBlock2,perlShellCommand,perlFloat,perlNumber,perlStringUnexpanded,perlString,perlQQ,perlArrow,perlBraces
|
||||||
|
syn region perlArrow matchgroup=perlArrow start="->\s*(" end=")" contains=@perlExpr nextgroup=perlVarMember,perlVarSimpleMember,perlMethod contained
|
||||||
|
syn region perlArrow matchgroup=perlArrow start="->\s*\[" end="\]" contains=@perlExpr nextgroup=perlVarMember,perlVarSimpleMember,perlMethod contained
|
||||||
|
syn region perlArrow matchgroup=perlArrow start="->\s*{" end="}" contains=@perlExpr nextgroup=perlVarMember,perlVarSimpleMember,perlMethod contained
|
||||||
|
syn match perlArrow "->\s*{\s*\I\i*\s*}" contains=perlVarSimpleMemberName nextgroup=perlVarMember,perlVarSimpleMember,perlMethod contained
|
||||||
|
syn region perlArrow matchgroup=perlArrow start="->\s*\$*\I\i*\s*(" end=")" contains=@perlExpr nextgroup=perlVarMember,perlVarSimpleMember,perlMethod contained
|
||||||
|
syn region perlVarBlock matchgroup=perlVarPlain start="\%($#\|[$@]\)\$*{" skip="\\}" end=+}\|\%(\%(<<\%('\|"\)\?\)\@=\)+ contains=@perlExpr nextgroup=perlVarMember,perlVarSimpleMember,perlMethod extend
|
||||||
|
syn region perlVarBlock2 matchgroup=perlVarPlain start="[%&*]\$*{" skip="\\}" end=+}\|\%(\%(<<\%('\|"\)\?\)\@=\)+ contains=@perlExpr nextgroup=perlVarMember,perlVarSimpleMember,perlMethod extend
|
||||||
|
syn match perlVarPlain2 "[%&*]\$*{\I\i*}" nextgroup=perlVarMember,perlVarSimpleMember,perlMethod extend
|
||||||
|
syn match perlVarPlain "\%(\$#\|[@$]\)\$*{\I\i*}" nextgroup=perlVarMember,perlVarSimpleMember,perlMethod extend
|
||||||
|
syn region perlVarMember matchgroup=perlVarPlain start="\%(->\)\={" skip="\\}" end="}" contained contains=@perlExpr nextgroup=perlVarMember,perlVarSimpleMember,perlMethod extend
|
||||||
|
syn match perlVarSimpleMember "\%(->\)\={\s*\I\i*\s*}" nextgroup=perlVarMember,perlVarSimpleMember,perlMethod contains=perlVarSimpleMemberName contained extend
|
||||||
|
syn match perlVarSimpleMemberName "\I\i*" contained
|
||||||
|
syn region perlVarMember matchgroup=perlVarPlain start="\%(->\)\=\[" skip="\\]" end="]" contained contains=@perlExpr nextgroup=perlVarMember,perlVarSimpleMember,perlMethod extend
|
||||||
|
syn match perlPackageConst "__PACKAGE__" nextgroup=perlMethod
|
||||||
|
syn match perlMethod "->\$*\I\i*" contained nextgroup=perlVarSimpleMember,perlVarMember,perlMethod
|
||||||
|
endif
|
||||||
|
|
||||||
|
" File Descriptors
|
||||||
|
syn match perlFiledescRead "<\h\w*>"
|
||||||
|
|
||||||
|
syn match perlFiledescStatementComma "(\=\s*\u\w*\s*,"me=e-1 transparent contained contains=perlFiledescStatement
|
||||||
|
syn match perlFiledescStatementNocomma "(\=\s*\u\w*\s*[^, \t]"me=e-1 transparent contained contains=perlFiledescStatement
|
||||||
|
|
||||||
|
syn match perlFiledescStatement "\u\w*" contained
|
||||||
|
|
||||||
|
" Special characters in strings and matches
|
||||||
|
syn match perlSpecialString "\\\%(\o\{1,3}\|x\%({\x\+}\|\x\{1,2}\)\|c.\|[^cx]\)" contained extend
|
||||||
|
syn match perlSpecialStringU2 "\\." extend contained contains=NONE
|
||||||
|
syn match perlSpecialStringU "\\\\" contained
|
||||||
|
syn match perlSpecialMatch "\\[1-9]" contained extend
|
||||||
|
syn match perlSpecialMatch "\\g\%(\d\+\|{\%(-\=\d\+\|\h\w*\)}\)" contained
|
||||||
|
syn match perlSpecialMatch "\\k\%(<\h\w*>\|'\h\w*'\)" contained
|
||||||
|
syn match perlSpecialMatch "{\d\+\%(,\%(\d\+\)\=\)\=}" contained
|
||||||
|
syn match perlSpecialMatch "\[[]-]\=[^\[\]]*[]-]\=\]" contained extend
|
||||||
|
syn match perlSpecialMatch "[+*()?.]" contained
|
||||||
|
syn match perlSpecialMatch "(?[#:=!]" contained
|
||||||
|
syn match perlSpecialMatch "(?[impsx]*\%(-[imsx]\+\)\=)" contained
|
||||||
|
syn match perlSpecialMatch "(?\%([-+]\=\d\+\|R\))" contained
|
||||||
|
syn match perlSpecialMatch "(?\%(&\|P[>=]\)\h\w*)" contained
|
||||||
|
syn match perlSpecialMatch "(\*\%(\%(PRUNE\|SKIP\|THEN\)\%(:[^)]*\)\=\|\%(MARK\|\):[^)]*\|COMMIT\|F\%(AIL\)\=\|ACCEPT\))" contained
|
||||||
|
|
||||||
|
" Possible errors
|
||||||
|
"
|
||||||
|
" Highlight lines with only whitespace (only in blank delimited here documents) as errors
|
||||||
|
syn match perlNotEmptyLine "^\s\+$" contained
|
||||||
|
" Highlight "} else if (...) {", it should be "} else { if (...) { " or "} elsif (...) {"
|
||||||
|
syn match perlElseIfError "else\_s*if" containedin=perlConditional
|
||||||
|
syn keyword perlElseIfError elseif containedin=perlConditional
|
||||||
|
|
||||||
|
" Variable interpolation
|
||||||
|
"
|
||||||
|
" These items are interpolated inside "" strings and similar constructs.
|
||||||
|
syn cluster perlInterpDQ contains=perlSpecialString,perlVarPlain,perlVarNotInMatches,perlVarSlash,perlVarBlock
|
||||||
|
" These items are interpolated inside '' strings and similar constructs.
|
||||||
|
syn cluster perlInterpSQ contains=perlSpecialStringU,perlSpecialStringU2
|
||||||
|
" These items are interpolated inside m// matches and s/// substitutions.
|
||||||
|
syn cluster perlInterpSlash contains=perlSpecialString,perlSpecialMatch,perlVarPlain,perlVarBlock
|
||||||
|
" These items are interpolated inside m## matches and s### substitutions.
|
||||||
|
syn cluster perlInterpMatch contains=@perlInterpSlash,perlVarSlash
|
||||||
|
|
||||||
|
" Shell commands
|
||||||
|
syn region perlShellCommand matchgroup=perlMatchStartEnd start="`" end="`" contains=@perlInterpDQ keepend
|
||||||
|
|
||||||
|
" Constants
|
||||||
|
"
|
||||||
|
" Numbers
|
||||||
|
syn match perlNumber "\<\%(0\%(x\x[[:xdigit:]_]*\|b[01][01_]*\|\o[0-7_]*\|\)\|[1-9][[:digit:]_]*\)\>"
|
||||||
|
syn match perlFloat "\<\d[[:digit:]_]*[eE][\-+]\=\d\+"
|
||||||
|
syn match perlFloat "\<\d[[:digit:]_]*\.[[:digit:]_]*\%([eE][\-+]\=\d\+\)\="
|
||||||
|
syn match perlFloat "\.[[:digit:]][[:digit:]_]*\%([eE][\-+]\=\d\+\)\="
|
||||||
|
|
||||||
|
syn match perlString "\<\%(v\d\+\%(\.\d\+\)*\|\d\+\%(\.\d\+\)\{2,}\)\>" contains=perlVStringV
|
||||||
|
syn match perlVStringV "\<v" contained
|
||||||
|
|
||||||
|
|
||||||
|
syn region perlParensSQ start=+(+ end=+)+ extend contained contains=perlParensSQ,@perlInterpSQ keepend
|
||||||
|
syn region perlBracketsSQ start=+\[+ end=+\]+ extend contained contains=perlBracketsSQ,@perlInterpSQ keepend
|
||||||
|
syn region perlBracesSQ start=+{+ end=+}+ extend contained contains=perlBracesSQ,@perlInterpSQ keepend
|
||||||
|
syn region perlAnglesSQ start=+<+ end=+>+ extend contained contains=perlAnglesSQ,@perlInterpSQ keepend
|
||||||
|
|
||||||
|
syn region perlParensDQ start=+(+ end=+)+ extend contained contains=perlParensDQ,@perlInterpDQ keepend
|
||||||
|
syn region perlBracketsDQ start=+\[+ end=+\]+ extend contained contains=perlBracketsDQ,@perlInterpDQ keepend
|
||||||
|
syn region perlBracesDQ start=+{+ end=+}+ extend contained contains=perlBracesDQ,@perlInterpDQ keepend
|
||||||
|
syn region perlAnglesDQ start=+<+ end=+>+ extend contained contains=perlAnglesDQ,@perlInterpDQ keepend
|
||||||
|
|
||||||
|
|
||||||
|
" Simple version of searches and matches
|
||||||
|
syn region perlMatch matchgroup=perlMatchStartEnd start=+\<\%(::\|'\|->\)\@<!m\>\s*\z([^[:space:]'([{<#]\)+ end=+\z1[msixpodualgc]*+ contains=@perlInterpMatch keepend extend
|
||||||
|
syn region perlMatch matchgroup=perlMatchStartEnd start=+\<\%(::\|'\|->\)\@<!m#+ end=+#[msixpodualgc]*+ contains=@perlInterpMatch keepend extend
|
||||||
|
syn region perlMatch matchgroup=perlMatchStartEnd start=+\<\%(::\|'\|->\)\@<!m\s*'+ end=+'[msixpodualgc]*+ contains=@perlInterpSQ keepend extend
|
||||||
|
syn region perlMatch matchgroup=perlMatchStartEnd start=+\<\%(::\|'\|->\)\@<!m\s*/+ end=+/[msixpodualgc]*+ contains=@perlInterpSlash keepend extend
|
||||||
|
syn region perlMatch matchgroup=perlMatchStartEnd start=+\<\%(::\|'\|->\)\@<!m\s*(+ end=+)[msixpodualgc]*+ contains=@perlInterpMatch,perlParensDQ keepend extend
|
||||||
|
|
||||||
|
" A special case for m{}, m<> and m[] which allows for comments and extra whitespace in the pattern
|
||||||
|
syn region perlMatch matchgroup=perlMatchStartEnd start=+\<\%(::\|'\|->\)\@<!m\s*{+ end=+}[msixpodualgc]*+ contains=@perlInterpMatch,perlComment,perlBracesDQ extend
|
||||||
|
syn region perlMatch matchgroup=perlMatchStartEnd start=+\<\%(::\|'\|->\)\@<!m\s*<+ end=+>[msixpodualgc]*+ contains=@perlInterpMatch,perlAnglesDQ keepend extend
|
||||||
|
syn region perlMatch matchgroup=perlMatchStartEnd start=+\<\%(::\|'\|->\)\@<!m\s*\[+ end=+\][msixpodualgc]*+ contains=@perlInterpMatch,perlComment,perlBracketsDQ keepend extend
|
||||||
|
|
||||||
|
" Below some hacks to recognise the // variant. This is virtually impossible to catch in all
|
||||||
|
" cases as the / is used in so many other ways, but these should be the most obvious ones.
|
||||||
|
syn region perlMatch matchgroup=perlMatchStartEnd start="\%([$@%&*]\@<!\%(\<split\|\<while\|\<if\|\<unless\|\.\.\|[-+*!~(\[{=]\)\s*\)\@<=/\%(/=\)\@!" start=+^/\%(/=\)\@!+ start=+\s\@<=/\%(/=\)\@![^[:space:][:digit:]$@%=]\@=\%(/\_s*\%([([{$@%&*[:digit:]"'`]\|\_s\w\|[[:upper:]_abd-fhjklnqrt-wyz]\)\)\@!+ skip=+\\/+ end=+/[msixpodualgc]*+ contains=@perlInterpSlash extend
|
||||||
|
|
||||||
|
|
||||||
|
" Substitutions
|
||||||
|
" perlMatch is the first part, perlSubstitution* is the substitution part
|
||||||
|
syn region perlMatch matchgroup=perlMatchStartEnd start=+\<\%(::\|'\|->\)\@<!s\>\s*\z([^[:space:]'([{<#]\)+ end=+\z1+me=e-1 contains=@perlInterpMatch nextgroup=perlSubstitutionGQQ keepend extend
|
||||||
|
syn region perlMatch matchgroup=perlMatchStartEnd start=+\<\%(::\|'\|->\)\@<!s\s*'+ end=+'+me=e-1 contains=@perlInterpSQ nextgroup=perlSubstitutionSQ keepend extend
|
||||||
|
syn region perlMatch matchgroup=perlMatchStartEnd start=+\<\%(::\|'\|->\)\@<!s\s*/+ end=+/+me=e-1 contains=@perlInterpSlash nextgroup=perlSubstitutionGQQ keepend extend
|
||||||
|
syn region perlMatch matchgroup=perlMatchStartEnd start=+\<\%(::\|'\|->\)\@<!s#+ end=+#+me=e-1 contains=@perlInterpMatch nextgroup=perlSubstitutionGQQ keepend extend
|
||||||
|
syn region perlMatch matchgroup=perlMatchStartEnd start=+\<\%(::\|'\|->\)\@<!s\s*(+ end=+)+ contains=@perlInterpMatch,perlParensDQ nextgroup=perlSubstitutionGQQ skipwhite skipempty skipnl keepend extend
|
||||||
|
syn region perlMatch matchgroup=perlMatchStartEnd start=+\<\%(::\|'\|->\)\@<!s\s*<+ end=+>+ contains=@perlInterpMatch,perlAnglesDQ nextgroup=perlSubstitutionGQQ skipwhite skipempty skipnl keepend extend
|
||||||
|
syn region perlMatch matchgroup=perlMatchStartEnd start=+\<\%(::\|'\|->\)\@<!s\s*\[+ end=+\]+ contains=@perlInterpMatch,perlBracketsDQ nextgroup=perlSubstitutionGQQ skipwhite skipempty skipnl keepend extend
|
||||||
|
syn region perlMatch matchgroup=perlMatchStartEnd start=+\<\%(::\|'\|->\)\@<!s\s*{+ end=+}+ contains=@perlInterpMatch,perlBracesDQ nextgroup=perlSubstitutionGQQ skipwhite skipempty skipnl keepend extend
|
||||||
|
syn region perlSubstitutionGQQ matchgroup=perlMatchStartEnd start=+\z([^[:space:]'([{<]\)+ end=+\z1[msixpodualgcer]*+ keepend contained contains=@perlInterpDQ extend
|
||||||
|
syn region perlSubstitutionGQQ matchgroup=perlMatchStartEnd start=+(+ end=+)[msixpodualgcer]*+ contained contains=@perlInterpDQ,perlParensDQ keepend extend
|
||||||
|
syn region perlSubstitutionGQQ matchgroup=perlMatchStartEnd start=+\[+ end=+\][msixpodualgcer]*+ contained contains=@perlInterpDQ,perlBracketsDQ keepend extend
|
||||||
|
syn region perlSubstitutionGQQ matchgroup=perlMatchStartEnd start=+{+ end=+}[msixpodualgcer]*+ contained contains=@perlInterpDQ,perlBracesDQ keepend extend extend
|
||||||
|
syn region perlSubstitutionGQQ matchgroup=perlMatchStartEnd start=+<+ end=+>[msixpodualgcer]*+ contained contains=@perlInterpDQ,perlAnglesDQ keepend extend
|
||||||
|
syn region perlSubstitutionSQ matchgroup=perlMatchStartEnd start=+'+ end=+'[msixpodualgcer]*+ contained contains=@perlInterpSQ keepend extend
|
||||||
|
|
||||||
|
" Translations
|
||||||
|
" perlMatch is the first part, perlTranslation* is the second, translator part.
|
||||||
|
syn region perlMatch matchgroup=perlMatchStartEnd start=+\<\%(::\|'\|->\)\@<!\%(tr\|y\)\>\s*\z([^[:space:]([{<#]\)+ end=+\z1+me=e-1 contains=@perlInterpSQ nextgroup=perlTranslationGQ
|
||||||
|
syn region perlMatch matchgroup=perlMatchStartEnd start=+\<\%(::\|'\|->\)\@<!\%(tr\|y\)#+ end=+#+me=e-1 contains=@perlInterpSQ nextgroup=perlTranslationGQ
|
||||||
|
syn region perlMatch matchgroup=perlMatchStartEnd start=+\<\%(::\|'\|->\)\@<!\%(tr\|y\)\s*\[+ end=+\]+ contains=@perlInterpSQ,perlBracketsSQ nextgroup=perlTranslationGQ skipwhite skipempty skipnl
|
||||||
|
syn region perlMatch matchgroup=perlMatchStartEnd start=+\<\%(::\|'\|->\)\@<!\%(tr\|y\)\s*(+ end=+)+ contains=@perlInterpSQ,perlParensSQ nextgroup=perlTranslationGQ skipwhite skipempty skipnl
|
||||||
|
syn region perlMatch matchgroup=perlMatchStartEnd start=+\<\%(::\|'\|->\)\@<!\%(tr\|y\)\s*<+ end=+>+ contains=@perlInterpSQ,perlAnglesSQ nextgroup=perlTranslationGQ skipwhite skipempty skipnl
|
||||||
|
syn region perlMatch matchgroup=perlMatchStartEnd start=+\<\%(::\|'\|->\)\@<!\%(tr\|y\)\s*{+ end=+}+ contains=@perlInterpSQ,perlBracesSQ nextgroup=perlTranslationGQ skipwhite skipempty skipnl
|
||||||
|
syn region perlTranslationGQ matchgroup=perlMatchStartEnd start=+\z([^[:space:]([{<]\)+ end=+\z1[cdsr]*+ contained
|
||||||
|
syn region perlTranslationGQ matchgroup=perlMatchStartEnd start=+(+ end=+)[cdsr]*+ contains=perlParensSQ contained
|
||||||
|
syn region perlTranslationGQ matchgroup=perlMatchStartEnd start=+\[+ end=+\][cdsr]*+ contains=perlBracketsSQ contained
|
||||||
|
syn region perlTranslationGQ matchgroup=perlMatchStartEnd start=+{+ end=+}[cdsr]*+ contains=perlBracesSQ contained
|
||||||
|
syn region perlTranslationGQ matchgroup=perlMatchStartEnd start=+<+ end=+>[cdsr]*+ contains=perlAnglesSQ contained
|
||||||
|
|
||||||
|
|
||||||
|
" Strings and q, qq, qw and qr expressions
|
||||||
|
|
||||||
|
syn region perlStringUnexpanded matchgroup=perlStringStartEnd start="'" end="'" contains=@perlInterpSQ keepend extend
|
||||||
|
syn region perlString matchgroup=perlStringStartEnd start=+"+ end=+"+ contains=@perlInterpDQ keepend extend
|
||||||
|
syn region perlQQ matchgroup=perlStringStartEnd start=+\<\%(::\|'\|->\)\@<!q\>\s*\z([^[:space:]#([{<]\)+ end=+\z1+ contains=@perlInterpSQ keepend extend
|
||||||
|
syn region perlQQ matchgroup=perlStringStartEnd start=+\<\%(::\|'\|->\)\@<!q#+ end=+#+ contains=@perlInterpSQ keepend extend
|
||||||
|
syn region perlQQ matchgroup=perlStringStartEnd start=+\<\%(::\|'\|->\)\@<!q\s*(+ end=+)+ contains=@perlInterpSQ,perlParensSQ keepend extend
|
||||||
|
syn region perlQQ matchgroup=perlStringStartEnd start=+\<\%(::\|'\|->\)\@<!q\s*\[+ end=+\]+ contains=@perlInterpSQ,perlBracketsSQ keepend extend
|
||||||
|
syn region perlQQ matchgroup=perlStringStartEnd start=+\<\%(::\|'\|->\)\@<!q\s*{+ end=+}+ contains=@perlInterpSQ,perlBracesSQ keepend extend
|
||||||
|
syn region perlQQ matchgroup=perlStringStartEnd start=+\<\%(::\|'\|->\)\@<!q\s*<+ end=+>+ contains=@perlInterpSQ,perlAnglesSQ keepend extend
|
||||||
|
|
||||||
|
syn region perlQQ matchgroup=perlStringStartEnd start=+\<\%(::\|'\|->\)\@<!q[qx]\>\s*\z([^[:space:]#([{<]\)+ end=+\z1+ contains=@perlInterpDQ keepend extend
|
||||||
|
syn region perlQQ matchgroup=perlStringStartEnd start=+\<\%(::\|'\|->\)\@<!q[qx]#+ end=+#+ contains=@perlInterpDQ keepend extend
|
||||||
|
syn region perlQQ matchgroup=perlStringStartEnd start=+\<\%(::\|'\|->\)\@<!q[qx]\s*(+ end=+)+ contains=@perlInterpDQ,perlParensDQ keepend extend
|
||||||
|
syn region perlQQ matchgroup=perlStringStartEnd start=+\<\%(::\|'\|->\)\@<!q[qx]\s*\[+ end=+\]+ contains=@perlInterpDQ,perlBracketsDQ keepend extend
|
||||||
|
syn region perlQQ matchgroup=perlStringStartEnd start=+\<\%(::\|'\|->\)\@<!q[qx]\s*{+ end=+}+ contains=@perlInterpDQ,perlBracesDQ keepend extend
|
||||||
|
syn region perlQQ matchgroup=perlStringStartEnd start=+\<\%(::\|'\|->\)\@<!q[qx]\s*<+ end=+>+ contains=@perlInterpDQ,perlAnglesDQ keepend extend
|
||||||
|
|
||||||
|
syn region perlQQ matchgroup=perlStringStartEnd start=+\<\%(::\|'\|->\)\@<!qw\s*\z([^[:space:]#([{<]\)+ end=+\z1+ contains=@perlInterpSQ keepend extend
|
||||||
|
syn region perlQQ matchgroup=perlStringStartEnd start=+\<\%(::\|'\|->\)\@<!qw#+ end=+#+ contains=@perlInterpSQ keepend extend
|
||||||
|
syn region perlQQ matchgroup=perlStringStartEnd start=+\<\%(::\|'\|->\)\@<!qw\s*(+ end=+)+ contains=@perlInterpSQ,perlParensSQ keepend extend
|
||||||
|
syn region perlQQ matchgroup=perlStringStartEnd start=+\<\%(::\|'\|->\)\@<!qw\s*\[+ end=+\]+ contains=@perlInterpSQ,perlBracketsSQ keepend extend
|
||||||
|
syn region perlQQ matchgroup=perlStringStartEnd start=+\<\%(::\|'\|->\)\@<!qw\s*{+ end=+}+ contains=@perlInterpSQ,perlBracesSQ keepend extend
|
||||||
|
syn region perlQQ matchgroup=perlStringStartEnd start=+\<\%(::\|'\|->\)\@<!qw\s*<+ end=+>+ contains=@perlInterpSQ,perlAnglesSQ keepend extend
|
||||||
|
|
||||||
|
syn region perlQQ matchgroup=perlStringStartEnd start=+\<\%(::\|'\|->\)\@<!qr\>\s*\z([^[:space:]#([{<'/]\)+ end=+\z1[imosx]*+ contains=@perlInterpMatch keepend extend
|
||||||
|
syn region perlQQ matchgroup=perlStringStartEnd start=+\<\%(::\|'\|->\)\@<!qr\s*/+ end=+/[imosx]*+ contains=@perlInterpSlash keepend extend
|
||||||
|
syn region perlQQ matchgroup=perlStringStartEnd start=+\<\%(::\|'\|->\)\@<!qr#+ end=+#[imosx]*+ contains=@perlInterpMatch keepend extend
|
||||||
|
syn region perlQQ matchgroup=perlStringStartEnd start=+\<\%(::\|'\|->\)\@<!qr\s*'+ end=+'[imosx]*+ contains=@perlInterpSQ keepend extend
|
||||||
|
syn region perlQQ matchgroup=perlStringStartEnd start=+\<\%(::\|'\|->\)\@<!qr\s*(+ end=+)[imosx]*+ contains=@perlInterpMatch,perlParensDQ keepend extend
|
||||||
|
|
||||||
|
" A special case for qr{}, qr<> and qr[] which allows for comments and extra whitespace in the pattern
|
||||||
|
syn region perlQQ matchgroup=perlStringStartEnd start=+\<\%(::\|'\|->\)\@<!qr\s*{+ end=+}[imosx]*+ contains=@perlInterpMatch,perlBracesDQ,perlComment keepend extend
|
||||||
|
syn region perlQQ matchgroup=perlStringStartEnd start=+\<\%(::\|'\|->\)\@<!qr\s*<+ end=+>[imosx]*+ contains=@perlInterpMatch,perlAnglesDQ,perlComment keepend extend
|
||||||
|
syn region perlQQ matchgroup=perlStringStartEnd start=+\<\%(::\|'\|->\)\@<!qr\s*\[+ end=+\][imosx]*+ contains=@perlInterpMatch,perlBracketsDQ,perlComment keepend extend
|
||||||
|
|
||||||
|
" Constructs such as print <<EOF [...] EOF, 'here' documents
|
||||||
|
"
|
||||||
|
" XXX Any statements after the identifier are in perlString colour (i.e.
|
||||||
|
" 'if $a' in 'print <<EOF if $a'). This is almost impossible to get right it
|
||||||
|
" seems due to the 'auto-extending nature' of regions.
|
||||||
|
if exists("perl_fold")
|
||||||
|
syn region perlHereDoc matchgroup=perlStringStartEnd start=+<<\z(\I\i*\).*+ end=+^\z1$+ contains=@perlInterpDQ fold extend
|
||||||
|
syn region perlHereDoc matchgroup=perlStringStartEnd start=+<<\s*"\z([^\\"]*\%(\\.[^\\"]*\)*\)"+ end=+^\z1$+ contains=@perlInterpDQ fold extend
|
||||||
|
syn region perlHereDoc matchgroup=perlStringStartEnd start=+<<\s*'\z([^\\']*\%(\\.[^\\']*\)*\)'+ end=+^\z1$+ contains=@perlInterpSQ fold extend
|
||||||
|
syn region perlHereDoc matchgroup=perlStringStartEnd start=+<<\s*""+ end=+^$+ contains=@perlInterpDQ,perlNotEmptyLine fold extend
|
||||||
|
syn region perlHereDoc matchgroup=perlStringStartEnd start=+<<\s*''+ end=+^$+ contains=@perlInterpSQ,perlNotEmptyLine fold extend
|
||||||
|
syn region perlAutoload matchgroup=perlStringStartEnd start=+<<\s*\(['"]\=\)\z(END_\%(SUB\|OF_FUNC\|OF_AUTOLOAD\)\)\1+ end=+^\z1$+ contains=ALL fold extend
|
||||||
|
else
|
||||||
|
syn region perlHereDoc matchgroup=perlStringStartEnd start=+<<\z(\I\i*\).*+ end=+^\z1$+ contains=@perlInterpDQ
|
||||||
|
syn region perlHereDoc matchgroup=perlStringStartEnd start=+<<\s*"\z([^\\"]*\%(\\.[^\\"]*\)*\)"+ end=+^\z1$+ contains=@perlInterpDQ
|
||||||
|
syn region perlHereDoc matchgroup=perlStringStartEnd start=+<<\s*'\z([^\\']*\%(\\.[^\\']*\)*\)'+ end=+^\z1$+ contains=@perlInterpSQ
|
||||||
|
syn region perlHereDoc matchgroup=perlStringStartEnd start=+<<\s*""+ end=+^$+ contains=@perlInterpDQ,perlNotEmptyLine
|
||||||
|
syn region perlHereDoc matchgroup=perlStringStartEnd start=+<<\s*''+ end=+^$+ contains=@perlInterpSQ,perlNotEmptyLine
|
||||||
|
syn region perlAutoload matchgroup=perlStringStartEnd start=+<<\s*\(['"]\=\)\z(END_\%(SUB\|OF_FUNC\|OF_AUTOLOAD\)\)\1+ end=+^\z1$+ contains=ALL
|
||||||
|
endif
|
||||||
|
|
||||||
|
|
||||||
|
" Class declarations
|
||||||
|
"
|
||||||
|
syn match perlPackageDecl "\<package\s\+\%(\h\|::\)\%(\w\|::\)*" contains=perlStatementPackage
|
||||||
|
syn keyword perlStatementPackage package contained
|
||||||
|
|
||||||
|
" Functions
|
||||||
|
" sub [name] [(prototype)] {
|
||||||
|
"
|
||||||
|
syn match perlSubError "[^[:space:];{#]" contained
|
||||||
|
if v:version == 701 && !has('patch221') " XXX I hope that's the right one
|
||||||
|
syn match perlSubAttributes ":" contained
|
||||||
|
else
|
||||||
|
syn match perlSubAttributesCont "\h\w*\_s*\%(:\_s*\)\=" nextgroup=@perlSubAttrMaybe contained
|
||||||
|
syn region perlSubAttributesCont matchgroup=perlSubAttributesCont start="\h\w*(" end=")\_s*\%(:\_s*\)\=" nextgroup=@perlSubAttrMaybe contained contains=@perlInterpSQ,perlParensSQ
|
||||||
|
syn cluster perlSubAttrMaybe contains=perlSubAttributesCont,perlSubError,perlFakeGroup
|
||||||
|
syn match perlSubAttributes "" contained nextgroup=perlSubError
|
||||||
|
syn match perlSubAttributes ":\_s*" contained nextgroup=@perlSubAttrMaybe
|
||||||
|
endif
|
||||||
|
syn match perlSubPrototypeError "(\%(\_s*\%(\%(\\\%([$@%&*]\|\[[$@%&*]\+\]\)\|[$&*]\|[@%]\%(\_s*)\)\@=\|;\%(\_s*[)$@%&*\\]\)\@=\|_\%(\_s*[);]\)\@=\)\_s*\)*\)\@>\zs\_[^)]\+" contained
|
||||||
|
syn match perlSubPrototype +(\_[^)]*)\_s*\|+ nextgroup=perlSubAttributes,perlComment contained contains=perlSubPrototypeError
|
||||||
|
syn match perlSubName +\%(\h\|::\|'\w\)\%(\w\|::\|'\w\)*\_s*\|+ contained nextgroup=perlSubPrototype,perlComment
|
||||||
|
|
||||||
|
syn match perlFunction +\<sub\>\_s*+ nextgroup=perlSubName
|
||||||
|
|
||||||
|
if !exists("perl_no_scope_in_variables")
|
||||||
|
syn match perlFunctionPRef "\h\w*::" contained
|
||||||
|
syn match perlFunctionName "\h\w*[^:]" contained
|
||||||
|
else
|
||||||
|
syn match perlFunctionName "\h[[:alnum:]_:]*" contained
|
||||||
|
endif
|
||||||
|
|
||||||
|
" The => operator forces a bareword to the left of it to be interpreted as
|
||||||
|
" a string
|
||||||
|
syn match perlString "\I\@<!-\?\I\i*\%(\s*=>\)\@="
|
||||||
|
|
||||||
|
" All other # are comments, except ^#!
|
||||||
|
syn match perlComment "#.*" contains=perlTodo,@Spell extend
|
||||||
|
syn match perlSharpBang "^#!.*"
|
||||||
|
|
||||||
|
" Formats
|
||||||
|
syn region perlFormat matchgroup=perlStatementIOFunc start="^\s*\<format\s\+\k\+\s*=\s*$"rs=s+6 end="^\s*\.\s*$" contains=perlFormatName,perlFormatField,perlVarPlain,perlVarPlain2
|
||||||
|
syn match perlFormatName "format\s\+\k\+\s*="lc=7,me=e-1 contained
|
||||||
|
syn match perlFormatField "[@^][|<>~]\+\%(\.\.\.\)\=" contained
|
||||||
|
syn match perlFormatField "[@^]#[#.]*" contained
|
||||||
|
syn match perlFormatField "@\*" contained
|
||||||
|
syn match perlFormatField "@[^A-Za-z_|<>~#*]"me=e-1 contained
|
||||||
|
syn match perlFormatField "@$" contained
|
||||||
|
|
||||||
|
" __END__ and __DATA__ clauses
|
||||||
|
if exists("perl_fold")
|
||||||
|
syntax region perlDATA start="^__DATA__$" skip="." end="." fold
|
||||||
|
syntax region perlDATA start="^__END__$" skip="." end="." contains=perlPOD,@perlDATA fold
|
||||||
|
else
|
||||||
|
syntax region perlDATA start="^__DATA__$" skip="." end="."
|
||||||
|
syntax region perlDATA start="^__END__$" skip="." end="." contains=perlPOD,@perlDATA
|
||||||
|
endif
|
||||||
|
|
||||||
|
"
|
||||||
|
" Folding
|
||||||
|
|
||||||
|
if exists("perl_fold")
|
||||||
|
" Note: this bit must come before the actual highlighting of the "package"
|
||||||
|
" keyword, otherwise this will screw up Pod lines that match /^package/
|
||||||
|
if !exists("perl_nofold_packages")
|
||||||
|
syn region perlPackageFold start="^package \S\+;\s*\%(#.*\)\=$" end="^1;\=\s*\%(#.*\)\=$" end="\n\+package"me=s-1 transparent fold keepend
|
||||||
|
endif
|
||||||
|
if !exists("perl_nofold_subs")
|
||||||
|
if exists("perl_fold_anonymous_subs") && perl_fold_anonymous_subs
|
||||||
|
syn region perlSubFold start="\<sub\>[^\n;]*{" end="}" transparent fold keepend extend
|
||||||
|
syn region perlSubFold start="\<\%(BEGIN\|END\|CHECK\|INIT\)\>\s*{" end="}" transparent fold keepend
|
||||||
|
else
|
||||||
|
syn region perlSubFold start="^\z(\s*\)\<sub\>.*[^};]$" end="^\z1}\s*\%(#.*\)\=$" transparent fold keepend
|
||||||
|
syn region perlSubFold start="^\z(\s*\)\<\%(BEGIN\|END\|CHECK\|INIT\|UNITCHECK\)\>.*[^};]$" end="^\z1}\s*$" transparent fold keepend
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
|
||||||
|
if exists("perl_fold_blocks")
|
||||||
|
syn region perlBlockFold start="^\z(\s*\)\%(if\|elsif\|unless\|for\|while\|until\|given\)\s*(.*)\%(\s*{\)\=\s*\%(#.*\)\=$" start="^\z(\s*\)foreach\s*\%(\%(my\|our\)\=\s*\S\+\s*\)\=(.*)\%(\s*{\)\=\s*\%(#.*\)\=$" end="^\z1}\s*;\=\%(#.*\)\=$" transparent fold keepend
|
||||||
|
syn region perlBlockFold start="^\z(\s*\)\%(do\|else\)\%(\s*{\)\=\s*\%(#.*\)\=$" end="^\z1}\s*while" end="^\z1}\s*;\=\%(#.*\)\=$" transparent fold keepend
|
||||||
|
endif
|
||||||
|
|
||||||
|
setlocal foldmethod=syntax
|
||||||
|
syn sync fromstart
|
||||||
|
else
|
||||||
|
" fromstart above seems to set minlines even if perl_fold is not set.
|
||||||
|
syn sync minlines=0
|
||||||
|
endif
|
||||||
|
|
||||||
|
command -nargs=+ HiLink hi def link <args>
|
||||||
|
|
||||||
|
" NOTE: If you're linking new highlight groups to perlString, please also put
|
||||||
|
" them into b:match_skip in ftplugin/perl.vim.
|
||||||
|
|
||||||
|
" The default highlighting.
|
||||||
|
HiLink perlSharpBang PreProc
|
||||||
|
HiLink perlControl PreProc
|
||||||
|
HiLink perlInclude Include
|
||||||
|
HiLink perlSpecial Special
|
||||||
|
HiLink perlString String
|
||||||
|
HiLink perlCharacter Character
|
||||||
|
HiLink perlNumber Number
|
||||||
|
HiLink perlFloat Float
|
||||||
|
HiLink perlType Type
|
||||||
|
HiLink perlIdentifier Identifier
|
||||||
|
HiLink perlLabel Label
|
||||||
|
HiLink perlStatement Statement
|
||||||
|
HiLink perlConditional Conditional
|
||||||
|
HiLink perlRepeat Repeat
|
||||||
|
HiLink perlOperator Operator
|
||||||
|
HiLink perlFunction Keyword
|
||||||
|
HiLink perlSubName Function
|
||||||
|
HiLink perlSubPrototype Type
|
||||||
|
HiLink perlSubAttributes PreProc
|
||||||
|
HiLink perlSubAttributesCont perlSubAttributes
|
||||||
|
HiLink perlComment Comment
|
||||||
|
HiLink perlTodo Todo
|
||||||
|
if exists("perl_string_as_statement")
|
||||||
|
HiLink perlStringStartEnd perlStatement
|
||||||
|
else
|
||||||
|
HiLink perlStringStartEnd perlString
|
||||||
|
endif
|
||||||
|
HiLink perlVStringV perlStringStartEnd
|
||||||
|
HiLink perlList perlStatement
|
||||||
|
HiLink perlMisc perlStatement
|
||||||
|
HiLink perlVarPlain perlIdentifier
|
||||||
|
HiLink perlVarPlain2 perlIdentifier
|
||||||
|
HiLink perlArrow perlIdentifier
|
||||||
|
HiLink perlFiledescRead perlIdentifier
|
||||||
|
HiLink perlFiledescStatement perlIdentifier
|
||||||
|
HiLink perlVarSimpleMember perlIdentifier
|
||||||
|
HiLink perlVarSimpleMemberName perlString
|
||||||
|
HiLink perlVarNotInMatches perlIdentifier
|
||||||
|
HiLink perlVarSlash perlIdentifier
|
||||||
|
HiLink perlQQ perlString
|
||||||
|
HiLink perlHereDoc perlString
|
||||||
|
HiLink perlStringUnexpanded perlString
|
||||||
|
HiLink perlSubstitutionSQ perlString
|
||||||
|
HiLink perlSubstitutionGQQ perlString
|
||||||
|
HiLink perlTranslationGQ perlString
|
||||||
|
HiLink perlMatch perlString
|
||||||
|
HiLink perlMatchStartEnd perlStatement
|
||||||
|
HiLink perlFormatName perlIdentifier
|
||||||
|
HiLink perlFormatField perlString
|
||||||
|
HiLink perlPackageDecl perlType
|
||||||
|
HiLink perlStorageClass perlType
|
||||||
|
HiLink perlPackageRef perlType
|
||||||
|
HiLink perlStatementPackage perlStatement
|
||||||
|
HiLink perlStatementStorage perlStatement
|
||||||
|
HiLink perlStatementControl perlStatement
|
||||||
|
HiLink perlStatementScalar perlStatement
|
||||||
|
HiLink perlStatementRegexp perlStatement
|
||||||
|
HiLink perlStatementNumeric perlStatement
|
||||||
|
HiLink perlStatementList perlStatement
|
||||||
|
HiLink perlStatementHash perlStatement
|
||||||
|
HiLink perlStatementIOfunc perlStatement
|
||||||
|
HiLink perlStatementFiledesc perlStatement
|
||||||
|
HiLink perlStatementVector perlStatement
|
||||||
|
HiLink perlStatementFiles perlStatement
|
||||||
|
HiLink perlStatementFlow perlStatement
|
||||||
|
HiLink perlStatementInclude perlStatement
|
||||||
|
HiLink perlStatementProc perlStatement
|
||||||
|
HiLink perlStatementSocket perlStatement
|
||||||
|
HiLink perlStatementIPC perlStatement
|
||||||
|
HiLink perlStatementNetwork perlStatement
|
||||||
|
HiLink perlStatementPword perlStatement
|
||||||
|
HiLink perlStatementTime perlStatement
|
||||||
|
HiLink perlStatementMisc perlStatement
|
||||||
|
HiLink perlStatementIndirObj perlStatement
|
||||||
|
HiLink perlFunctionName perlIdentifier
|
||||||
|
HiLink perlMethod perlIdentifier
|
||||||
|
HiLink perlFunctionPRef perlType
|
||||||
|
HiLink perlPOD perlComment
|
||||||
|
HiLink perlShellCommand perlString
|
||||||
|
HiLink perlSpecialAscii perlSpecial
|
||||||
|
HiLink perlSpecialDollar perlSpecial
|
||||||
|
HiLink perlSpecialString perlSpecial
|
||||||
|
HiLink perlSpecialStringU perlSpecial
|
||||||
|
HiLink perlSpecialMatch perlSpecial
|
||||||
|
HiLink perlDATA perlComment
|
||||||
|
|
||||||
|
" NOTE: Due to a bug in Vim (or more likely, a misunderstanding on my part),
|
||||||
|
" I had to remove the transparent property from the following regions
|
||||||
|
" in order to get them to highlight correctly. Feel free to remove
|
||||||
|
" these and reinstate the transparent property if you know how.
|
||||||
|
HiLink perlParensSQ perlString
|
||||||
|
HiLink perlBracketsSQ perlString
|
||||||
|
HiLink perlBracesSQ perlString
|
||||||
|
HiLink perlAnglesSQ perlString
|
||||||
|
|
||||||
|
HiLink perlParensDQ perlString
|
||||||
|
HiLink perlBracketsDQ perlString
|
||||||
|
HiLink perlBracesDQ perlString
|
||||||
|
HiLink perlAnglesDQ perlString
|
||||||
|
|
||||||
|
HiLink perlSpecialStringU2 perlString
|
||||||
|
|
||||||
|
" Possible errors
|
||||||
|
HiLink perlNotEmptyLine Error
|
||||||
|
HiLink perlElseIfError Error
|
||||||
|
HiLink perlSubPrototypeError Error
|
||||||
|
HiLink perlSubError Error
|
||||||
|
|
||||||
|
delcommand HiLink
|
||||||
|
|
||||||
|
" Syncing to speed up processing
|
||||||
|
"
|
||||||
|
if !exists("perl_no_sync_on_sub")
|
||||||
|
syn sync match perlSync grouphere NONE "^\s*\<package\s"
|
||||||
|
syn sync match perlSync grouphere NONE "^\s*\<sub\>"
|
||||||
|
syn sync match perlSync grouphere NONE "^}"
|
||||||
|
endif
|
||||||
|
|
||||||
|
if !exists("perl_no_sync_on_global_var")
|
||||||
|
syn sync match perlSync grouphere NONE "^$\I[[:alnum:]_:]+\s*=\s*{"
|
||||||
|
syn sync match perlSync grouphere NONE "^[@%]\I[[:alnum:]_:]+\s*=\s*("
|
||||||
|
endif
|
||||||
|
|
||||||
|
if exists("perl_sync_dist")
|
||||||
|
execute "syn sync maxlines=" . perl_sync_dist
|
||||||
|
else
|
||||||
|
syn sync maxlines=100
|
||||||
|
endif
|
||||||
|
|
||||||
|
syn sync match perlSyncPOD grouphere perlPOD "^=pod"
|
||||||
|
syn sync match perlSyncPOD grouphere perlPOD "^=head"
|
||||||
|
syn sync match perlSyncPOD grouphere perlPOD "^=item"
|
||||||
|
syn sync match perlSyncPOD grouphere NONE "^=cut"
|
||||||
|
|
||||||
|
let b:current_syntax = "perl"
|
||||||
|
|
||||||
|
if exists('®expengine')
|
||||||
|
let ®expengine=s:regexpengine
|
||||||
|
unlet s:regexpengine
|
||||||
|
endif
|
||||||
|
|
||||||
|
let &cpo = s:cpo_save
|
||||||
|
unlet s:cpo_save
|
||||||
|
|
||||||
|
" XXX Change to sts=4:sw=4
|
||||||
|
" vim:ts=8:sts=2:sw=2:expandtab:ft=vim
|
2255
syntax/perl6.vim
Normal file
2255
syntax/perl6.vim
Normal file
File diff suppressed because it is too large
Load Diff
189
syntax/pod.vim
Normal file
189
syntax/pod.vim
Normal file
@ -0,0 +1,189 @@
|
|||||||
|
" Vim syntax file
|
||||||
|
" Language: Perl POD format
|
||||||
|
" Maintainer: vim-perl <vim-perl@googlegroups.com>
|
||||||
|
" Previously: Scott Bigham <dsb@killerbunnies.org>
|
||||||
|
" Homepage: http://github.com/vim-perl/vim-perl
|
||||||
|
" Bugs/requests: http://github.com/vim-perl/vim-perl/issues
|
||||||
|
" Last Change: {{LAST_CHANGE}}
|
||||||
|
|
||||||
|
" To add embedded POD documentation highlighting to your syntax file, add
|
||||||
|
" the commands:
|
||||||
|
"
|
||||||
|
" syn include @Pod <sfile>:p:h/pod.vim
|
||||||
|
" syn region myPOD start="^=pod" start="^=head" end="^=cut" keepend contained contains=@Pod
|
||||||
|
"
|
||||||
|
" and add myPod to the contains= list of some existing region, probably a
|
||||||
|
" comment. The "keepend" flag is needed because "=cut" is matched as a
|
||||||
|
" pattern in its own right.
|
||||||
|
|
||||||
|
|
||||||
|
" Remove any old syntax stuff hanging around (this is suppressed
|
||||||
|
" automatically by ":syn include" if necessary).
|
||||||
|
" For version 5.x: Clear all syntax items
|
||||||
|
" For version 6.x: Quit when a syntax file was already loaded
|
||||||
|
if version < 600
|
||||||
|
syntax clear
|
||||||
|
elseif exists("b:current_syntax")
|
||||||
|
finish
|
||||||
|
endif
|
||||||
|
|
||||||
|
let s:cpo_save = &cpo
|
||||||
|
set cpo&vim
|
||||||
|
|
||||||
|
" POD commands
|
||||||
|
syn match podCommand "^=encoding" nextgroup=podCmdText contains=@NoSpell
|
||||||
|
syn match podCommand "^=head[1234]" nextgroup=podCmdText contains=@NoSpell
|
||||||
|
syn match podCommand "^=item" nextgroup=podCmdText contains=@NoSpell
|
||||||
|
syn match podCommand "^=over" nextgroup=podOverIndent skipwhite contains=@NoSpell
|
||||||
|
syn match podCommand "^=back" contains=@NoSpell
|
||||||
|
syn match podCommand "^=cut" contains=@NoSpell
|
||||||
|
syn match podCommand "^=pod" contains=@NoSpell
|
||||||
|
syn match podCommand "^=for" nextgroup=podForKeywd skipwhite contains=@NoSpell
|
||||||
|
syn match podCommand "^=begin" nextgroup=podForKeywd skipwhite contains=@NoSpell
|
||||||
|
syn match podCommand "^=end" nextgroup=podForKeywd skipwhite contains=@NoSpell
|
||||||
|
|
||||||
|
" Text of a =head1, =head2 or =item command
|
||||||
|
syn match podCmdText ".*$" contained contains=podFormat,@NoSpell
|
||||||
|
|
||||||
|
" Indent amount of =over command
|
||||||
|
syn match podOverIndent "\d\+" contained contains=@NoSpell
|
||||||
|
|
||||||
|
" Formatter identifier keyword for =for, =begin and =end commands
|
||||||
|
syn match podForKeywd "\S\+" contained contains=@NoSpell
|
||||||
|
|
||||||
|
" An indented line, to be displayed verbatim
|
||||||
|
syn match podVerbatimLine "^\s.*$" contains=@NoSpell
|
||||||
|
|
||||||
|
" Inline textual items handled specially by POD
|
||||||
|
syn match podSpecial "\(\<\|&\)\I\i*\(::\I\i*\)*([^)]*)" contains=@NoSpell
|
||||||
|
syn match podSpecial "[$@%]\I\i*\(::\I\i*\)*\>" contains=@NoSpell
|
||||||
|
|
||||||
|
" Special formatting sequences
|
||||||
|
syn region podFormat start="[IBSCLFX]<[^<]"me=e-1 end=">" oneline contains=podFormat,@NoSpell
|
||||||
|
syn region podFormat start="[IBSCLFX]<<\s" end="\s>>" oneline contains=podFormat,@NoSpell
|
||||||
|
syn match podFormat "Z<>"
|
||||||
|
syn match podFormat "E<\(\d\+\|\I\i*\)>" contains=podEscape,podEscape2,@NoSpell
|
||||||
|
syn match podEscape "\I\i*>"me=e-1 contained contains=@NoSpell
|
||||||
|
syn match podEscape2 "\d\+>"me=e-1 contained contains=@NoSpell
|
||||||
|
|
||||||
|
" Define the default highlighting.
|
||||||
|
" For version 5.7 and earlier: only when not done already
|
||||||
|
" For version 5.8 and later: only when an item doesn't have highlighting yet
|
||||||
|
if version >= 508 || !exists("did_pod_syntax_inits")
|
||||||
|
if version < 508
|
||||||
|
let did_pod_syntax_inits = 1
|
||||||
|
command -nargs=+ HiLink hi link <args>
|
||||||
|
else
|
||||||
|
command -nargs=+ HiLink hi def link <args>
|
||||||
|
endif
|
||||||
|
|
||||||
|
HiLink podCommand Statement
|
||||||
|
HiLink podCmdText String
|
||||||
|
HiLink podOverIndent Number
|
||||||
|
HiLink podForKeywd Identifier
|
||||||
|
HiLink podFormat Identifier
|
||||||
|
HiLink podVerbatimLine PreProc
|
||||||
|
HiLink podSpecial Identifier
|
||||||
|
HiLink podEscape String
|
||||||
|
HiLink podEscape2 Number
|
||||||
|
|
||||||
|
delcommand HiLink
|
||||||
|
endif
|
||||||
|
|
||||||
|
if exists("perl_pod_spellcheck_headings")
|
||||||
|
" Spell-check headings
|
||||||
|
syn clear podCmdText
|
||||||
|
syn match podCmdText ".*$" contained contains=podFormat
|
||||||
|
endif
|
||||||
|
|
||||||
|
if exists("perl_pod_formatting")
|
||||||
|
" By default, escapes like C<> are not checked for spelling. Remove B<>
|
||||||
|
" and I<> from the list of escapes.
|
||||||
|
syn clear podFormat
|
||||||
|
syn region podFormat start="[CLF]<[^<]"me=e-1 end=">" oneline contains=podFormat,@NoSpell
|
||||||
|
syn region podFormat start="[CLF]<<\s" end="\s>>" oneline contains=podFormat,@NoSpell
|
||||||
|
|
||||||
|
" Don't spell-check inside E<>, but ensure that the E< itself isn't
|
||||||
|
" marked as a spelling mistake.
|
||||||
|
syn match podFormat "E<\(\d\+\|\I\i*\)>" contains=podEscape,podEscape2,@NoSpell
|
||||||
|
|
||||||
|
" Z<> is a mock formatting code. Ensure Z<> on its own isn't marked as a
|
||||||
|
" spelling mistake.
|
||||||
|
syn match podFormat "Z<>" contains=podEscape,podEscape2,@NoSpell
|
||||||
|
|
||||||
|
" These are required so that whatever is *within* B<...>, I<...>, etc. is
|
||||||
|
" spell-checked, but not the B, I, ... itself.
|
||||||
|
syn match podBoldOpen "B<" contains=@NoSpell
|
||||||
|
syn match podItalicOpen "I<" contains=@NoSpell
|
||||||
|
syn match podNoSpaceOpen "S<" contains=@NoSpell
|
||||||
|
syn match podIndexOpen "X<" contains=@NoSpell
|
||||||
|
|
||||||
|
" Same as above but for the << >> syntax.
|
||||||
|
syn match podBoldAlternativeDelimOpen "B<< " contains=@NoSpell
|
||||||
|
syn match podItalicAlternativeDelimOpen "I<< " contains=@NoSpell
|
||||||
|
syn match podNoSpaceAlternativeDelimOpen "S<< " contains=@NoSpell
|
||||||
|
syn match podIndexAlternativeDelimOpen "X<< " contains=@NoSpell
|
||||||
|
|
||||||
|
" Add support for spell checking text inside B<>, I<>, S<> and X<>.
|
||||||
|
syn region podBold start="B<[^<]"me=e end=">" oneline contains=podBoldItalic,podBoldOpen
|
||||||
|
syn region podBoldAlternativeDelim start="B<<\s" end="\s>>" oneline contains=podBoldAlternativeDelimOpen
|
||||||
|
|
||||||
|
syn region podItalic start="I<[^<]"me=e end=">" oneline contains=podItalicBold,podItalicOpen
|
||||||
|
syn region podItalicAlternativeDelim start="I<<\s" end="\s>>" oneline contains=podItalicAlternativeDelimOpen
|
||||||
|
|
||||||
|
" Nested bold/italic and vice-versa
|
||||||
|
syn region podBoldItalic contained start="I<[^<]"me=e end=">" oneline
|
||||||
|
syn region podItalicBold contained start="B<[^<]"me=e end=">" oneline
|
||||||
|
|
||||||
|
syn region podNoSpace start="S<[^<]"ms=s-2 end=">"me=e oneline contains=podNoSpaceOpen
|
||||||
|
syn region podNoSpaceAlternativeDelim start="S<<\s"ms=s-2 end="\s>>"me=e oneline contains=podNoSpaceAlternativeDelimOpen
|
||||||
|
|
||||||
|
syn region podIndex start="X<[^<]"ms=s-2 end=">"me=e oneline contains=podIndexOpen
|
||||||
|
syn region podIndexAlternativeDelim start="X<<\s"ms=s-2 end="\s>>"me=e oneline contains=podIndexAlternativeDelimOpen
|
||||||
|
|
||||||
|
" Restore this (otherwise B<> is shown as bold inside verbatim)
|
||||||
|
syn match podVerbatimLine "^\s.*$" contains=@NoSpell
|
||||||
|
|
||||||
|
" Ensure formatted text can be displayed in headings and items
|
||||||
|
syn clear podCmdText
|
||||||
|
|
||||||
|
if exists("perl_pod_spellcheck_headings")
|
||||||
|
syn match podCmdText ".*$" contained contains=podFormat,podBold,
|
||||||
|
\podBoldAlternativeDelim,podItalic,podItalicAlternativeDelim,
|
||||||
|
\podBoldOpen,podItalicOpen,podBoldAlternativeDelimOpen,
|
||||||
|
\podItalicAlternativeDelimOpen,podNoSpaceOpen
|
||||||
|
else
|
||||||
|
syn match podCmdText ".*$" contained contains=podFormat,podBold,
|
||||||
|
\podBoldAlternativeDelim,podItalic,podItalicAlternativeDelim,
|
||||||
|
\@NoSpell
|
||||||
|
endif
|
||||||
|
|
||||||
|
" Specify how to display these
|
||||||
|
hi def podBold term=bold cterm=bold gui=bold
|
||||||
|
|
||||||
|
hi link podBoldAlternativeDelim podBold
|
||||||
|
hi link podBoldAlternativeDelimOpen podBold
|
||||||
|
hi link podBoldOpen podBold
|
||||||
|
|
||||||
|
hi link podNoSpace Identifier
|
||||||
|
hi link podNoSpaceAlternativeDelim Identifier
|
||||||
|
|
||||||
|
hi link podIndex Identifier
|
||||||
|
hi link podIndexAlternativeDelim Identifier
|
||||||
|
|
||||||
|
hi def podItalic term=italic cterm=italic gui=italic
|
||||||
|
|
||||||
|
hi link podItalicAlternativeDelim podItalic
|
||||||
|
hi link podItalicAlternativeDelimOpen podItalic
|
||||||
|
hi link podItalicOpen podItalic
|
||||||
|
|
||||||
|
hi def podBoldItalic term=italic,bold cterm=italic,bold gui=italic,bold
|
||||||
|
hi def podItalicBold term=italic,bold cterm=italic,bold gui=italic,bold
|
||||||
|
endif
|
||||||
|
|
||||||
|
let b:current_syntax = "pod"
|
||||||
|
|
||||||
|
let &cpo = s:cpo_save
|
||||||
|
unlet s:cpo_save
|
||||||
|
|
||||||
|
" vim: ts=8
|
210
syntax/tt2.vim
Normal file
210
syntax/tt2.vim
Normal file
@ -0,0 +1,210 @@
|
|||||||
|
" Language: TT2 (Perl Template Toolkit)
|
||||||
|
" Maintainer: vim-perl <vim-perl@googlegroups.com>
|
||||||
|
" Author: Moriki, Atsushi <4woods+vim@gmail.com>
|
||||||
|
" Homepage: http://github.com/vim-perl/vim-perl
|
||||||
|
" Bugs/requests: http://github.com/vim-perl/vim-perl/issues
|
||||||
|
" Last Change: {{LAST_CHANGE}}
|
||||||
|
"
|
||||||
|
" Instration:
|
||||||
|
" put tt2.vim and tt2html.vim in to your syntax diretory.
|
||||||
|
"
|
||||||
|
" add below in your filetype.vim.
|
||||||
|
" au BufNewFile,BufRead *.tt2 setf tt2
|
||||||
|
" or
|
||||||
|
" au BufNewFile,BufRead *.tt2
|
||||||
|
" \ if ( getline(1) . getline(2) . getline(3) =~ '<\chtml' |
|
||||||
|
" \ && getline(1) . getline(2) . getline(3) !~ '<[%?]' ) |
|
||||||
|
" \ || getline(1) =~ '<!DOCTYPE HTML' |
|
||||||
|
" \ setf tt2html |
|
||||||
|
" \ else |
|
||||||
|
" \ setf tt2 |
|
||||||
|
" \ endif
|
||||||
|
"
|
||||||
|
" define START_TAG, END_TAG
|
||||||
|
" "ASP"
|
||||||
|
" :let b:tt2_syn_tags = '<% %>'
|
||||||
|
" "PHP"
|
||||||
|
" :let b:tt2_syn_tags = '<? ?>'
|
||||||
|
" "TT2 and HTML"
|
||||||
|
" :let b:tt2_syn_tags = '\[% %] <!-- -->'
|
||||||
|
"
|
||||||
|
" Changes:
|
||||||
|
" 0.1.3
|
||||||
|
" Changed fileformat from 'dos' to 'unix'
|
||||||
|
" Deleted 'echo' that print obstructive message
|
||||||
|
" 0.1.2
|
||||||
|
" Added block comment syntax
|
||||||
|
" e.g. [%# COMMENT
|
||||||
|
" COMMENT TOO %]
|
||||||
|
" [%# IT'S SAFE %] HERE IS OUTSIDE OF TT2 DIRECTIVE
|
||||||
|
" [% # WRONG!! %] HERE STILL BE COMMENT
|
||||||
|
" 0.1.1
|
||||||
|
" Release
|
||||||
|
" 0.1.0
|
||||||
|
" Internal
|
||||||
|
"
|
||||||
|
" License: follow Vim :help uganda
|
||||||
|
"
|
||||||
|
|
||||||
|
if !exists("b:tt2_syn_tags")
|
||||||
|
let b:tt2_syn_tags = '\[% %]'
|
||||||
|
"let b:tt2_syn_tags = '\[% %] \[\* \*]'
|
||||||
|
endif
|
||||||
|
|
||||||
|
if !exists("b:tt2_syn_inc_perl")
|
||||||
|
let b:tt2_syn_inc_perl = 1
|
||||||
|
endif
|
||||||
|
|
||||||
|
if exists("b:current_syntax")
|
||||||
|
finish
|
||||||
|
endif
|
||||||
|
|
||||||
|
let s:cpo_save = &cpo
|
||||||
|
set cpo&vim
|
||||||
|
|
||||||
|
syn case match
|
||||||
|
|
||||||
|
syn cluster tt2_top_cluster contains=tt2_perlcode,tt2_tag_region
|
||||||
|
|
||||||
|
" TT2 TAG Region
|
||||||
|
if exists("b:tt2_syn_tags")
|
||||||
|
|
||||||
|
let s:str = b:tt2_syn_tags . ' '
|
||||||
|
let s:str = substitute(s:str,'^ \+','','g')
|
||||||
|
let s:str = substitute(s:str,' \+',' ','g')
|
||||||
|
|
||||||
|
while stridx(s:str,' ') > 0
|
||||||
|
|
||||||
|
let s:st = strpart(s:str,0,stridx(s:str,' '))
|
||||||
|
let s:str = substitute(s:str,'[^ ]* ','',"")
|
||||||
|
|
||||||
|
let s:ed = strpart(s:str,0,stridx(s:str,' '))
|
||||||
|
let s:str = substitute(s:str,'[^ ]* ','',"")
|
||||||
|
|
||||||
|
exec 'syn region tt2_tag_region '.
|
||||||
|
\ 'matchgroup=tt2_tag '.
|
||||||
|
\ 'start=+\(' . s:st .'\)[-]\=+ '.
|
||||||
|
\ 'end=+[-]\=\(' . s:ed . '\)+ '.
|
||||||
|
\ 'contains=@tt2_statement_cluster keepend extend'
|
||||||
|
|
||||||
|
exec 'syn region tt2_commentblock_region '.
|
||||||
|
\ 'matchgroup=tt2_tag '.
|
||||||
|
\ 'start=+\(' . s:st .'\)[-]\=\(#\)\@=+ '.
|
||||||
|
\ 'end=+[-]\=\(' . s:ed . '\)+ '.
|
||||||
|
\ 'keepend extend'
|
||||||
|
|
||||||
|
"Include Perl syntax when 'PERL' 'RAWPERL' block
|
||||||
|
if b:tt2_syn_inc_perl
|
||||||
|
syn include @Perl $VIMRUNTIME/syntax/perl.vim
|
||||||
|
exec 'syn region tt2_perlcode '.
|
||||||
|
\ 'start=+\(\(RAW\)\=PERL\s*[-]\=' . s:ed . '\(\n\)\=\)\@<=+ ' .
|
||||||
|
\ 'end=+' . s:st . '[-]\=\s*END+me=s-1 contains=@Perl keepend'
|
||||||
|
endif
|
||||||
|
|
||||||
|
"echo 'TAGS ' . s:st . ' ' . s:ed
|
||||||
|
unlet s:st
|
||||||
|
unlet s:ed
|
||||||
|
endwhile
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
|
syn region tt2_tag_region
|
||||||
|
\ matchgroup=tt2_tag
|
||||||
|
\ start=+\(\[%\)[-]\=+
|
||||||
|
\ end=+[-]\=%\]+
|
||||||
|
\ contains=@tt2_statement_cluster keepend extend
|
||||||
|
|
||||||
|
syn region tt2_commentblock_region
|
||||||
|
\ matchgroup=tt2_tag
|
||||||
|
\ start=+\(\[%\)[-]\=#+
|
||||||
|
\ end=+[-]\=%\]+
|
||||||
|
\ keepend extend
|
||||||
|
|
||||||
|
"Include Perl syntax when 'PERL' 'RAWPERL' block
|
||||||
|
if b:tt2_syn_inc_perl
|
||||||
|
syn include @Perl $VIMRUNTIME/syntax/perl.vim
|
||||||
|
syn region tt2_perlcode
|
||||||
|
\ start=+\(\(RAW\)\=PERL\s*[-]\=%]\(\n\)\=\)\@<=+
|
||||||
|
\ end=+\[%[-]\=\s*END+me=s-1
|
||||||
|
\ contains=@Perl keepend
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
|
||||||
|
" Directive
|
||||||
|
syn keyword tt2_directive contained
|
||||||
|
\ GET CALL SET DEFAULT DEBUG
|
||||||
|
\ LAST NEXT BREAK STOP BLOCK
|
||||||
|
\ IF IN UNLESS ELSIF FOR FOREACH WHILE SWITCH CASE
|
||||||
|
\ USE PLUGIN MACRO META
|
||||||
|
\ TRY FINAL RETURN LAST
|
||||||
|
\ CLEAR TO STEP AND OR NOT MOD DIV
|
||||||
|
\ ELSE PERL RAWPERL END
|
||||||
|
syn match tt2_directive +|+ contained
|
||||||
|
syn keyword tt2_directive contained nextgroup=tt2_string_q,tt2_string_qq,tt2_blockname skipwhite skipempty
|
||||||
|
\ INSERT INCLUDE PROCESS WRAPPER FILTER
|
||||||
|
\ THROW CATCH
|
||||||
|
syn keyword tt2_directive contained nextgroup=tt2_def_tag skipwhite skipempty
|
||||||
|
\ TAGS
|
||||||
|
|
||||||
|
syn match tt2_def_tag "\S\+\s\+\S\+\|\<\w\+\>" contained
|
||||||
|
|
||||||
|
syn match tt2_variable +\I\w*+ contained
|
||||||
|
syn match tt2_operator "[+*/%:?-]" contained
|
||||||
|
syn match tt2_operator "\<\(mod\|div\|or\|and\|not\)\>" contained
|
||||||
|
syn match tt2_operator "[!=<>]=\=\|&&\|||" contained
|
||||||
|
syn match tt2_operator "\(\s\)\@<=_\(\s\)\@=" contained
|
||||||
|
syn match tt2_operator "=>\|," contained
|
||||||
|
syn match tt2_deref "\([[:alnum:]_)\]}]\s*\)\@<=\." contained
|
||||||
|
syn match tt2_comment +#.*$+ contained extend
|
||||||
|
syn match tt2_func +\<\I\w*\(\s*(\)\@=+ contained nextgroup=tt2_bracket_r skipempty skipwhite
|
||||||
|
"
|
||||||
|
syn region tt2_bracket_r start=+(+ end=+)+ contained contains=@tt2_statement_cluster keepend extend
|
||||||
|
syn region tt2_bracket_b start=+\[+ end=+]+ contained contains=@tt2_statement_cluster keepend extend
|
||||||
|
syn region tt2_bracket_b start=+{+ end=+}+ contained contains=@tt2_statement_cluster keepend extend
|
||||||
|
|
||||||
|
syn region tt2_string_qq start=+"+ end=+"+ skip=+\\"+ contained contains=tt2_ivariable keepend extend
|
||||||
|
syn region tt2_string_q start=+'+ end=+'+ skip=+\\'+ contained keepend extend
|
||||||
|
|
||||||
|
syn match tt2_ivariable +\$\I\w*\>\(\.\I\w*\>\)*+ contained
|
||||||
|
syn match tt2_ivariable +\${\I\w*\>\(\.\I\w*\>\)*}+ contained
|
||||||
|
|
||||||
|
syn match tt2_number "\d\+" contained
|
||||||
|
syn match tt2_number "\d\+\.\d\+" contained
|
||||||
|
syn match tt2_number "0x\x\+" contained
|
||||||
|
syn match tt2_number "0\o\+" contained
|
||||||
|
|
||||||
|
syn match tt2_blockname "\f\+" contained nextgroup=tt2_blockname_joint skipwhite skipempty
|
||||||
|
syn match tt2_blockname "$\w\+" contained contains=tt2_ivariable nextgroup=tt2_blockname_joint skipwhite skipempty
|
||||||
|
syn region tt2_blockname start=+"+ end=+"+ skip=+\\"+ contained contains=tt2_ivariable nextgroup=tt2_blockname_joint keepend skipwhite skipempty
|
||||||
|
syn region tt2_blockname start=+'+ end=+'+ skip=+\\'+ contained nextgroup=tt2_blockname_joint keepend skipwhite skipempty
|
||||||
|
syn match tt2_blockname_joint "+" contained nextgroup=tt2_blockname skipwhite skipempty
|
||||||
|
|
||||||
|
syn cluster tt2_statement_cluster contains=tt2_directive,tt2_variable,tt2_operator,tt2_string_q,tt2_string_qq,tt2_deref,tt2_comment,tt2_func,tt2_bracket_b,tt2_bracket_r,tt2_number
|
||||||
|
|
||||||
|
" Synchronizing
|
||||||
|
syn sync minlines=50
|
||||||
|
|
||||||
|
hi def link tt2_tag Type
|
||||||
|
hi def link tt2_tag_region Type
|
||||||
|
hi def link tt2_commentblock_region Comment
|
||||||
|
hi def link tt2_directive Statement
|
||||||
|
hi def link tt2_variable Identifier
|
||||||
|
hi def link tt2_ivariable Identifier
|
||||||
|
hi def link tt2_operator Statement
|
||||||
|
hi def link tt2_string_qq String
|
||||||
|
hi def link tt2_string_q String
|
||||||
|
hi def link tt2_blockname String
|
||||||
|
hi def link tt2_comment Comment
|
||||||
|
hi def link tt2_func Function
|
||||||
|
hi def link tt2_number Number
|
||||||
|
|
||||||
|
if exists("b:tt2_syn_tags")
|
||||||
|
unlet b:tt2_syn_tags
|
||||||
|
endif
|
||||||
|
|
||||||
|
let b:current_syntax = "tt2"
|
||||||
|
|
||||||
|
let &cpo = s:cpo_save
|
||||||
|
unlet s:cpo_save
|
||||||
|
|
||||||
|
" vim:ts=4:sw=4
|
20
syntax/tt2html.vim
Normal file
20
syntax/tt2html.vim
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
" Language: TT2 embedded with HTML
|
||||||
|
" Maintainer: vim-perl <vim-perl@googlegroups.com>
|
||||||
|
" Author: Moriki, Atsushi <4woods+vim@gmail.com>
|
||||||
|
" Homepage: http://github.com/vim-perl/vim-perl
|
||||||
|
" Bugs/requests: http://github.com/vim-perl/vim-perl/issues
|
||||||
|
" Last Change: {{LAST_CHANGE}}
|
||||||
|
|
||||||
|
if exists("b:current_syntax")
|
||||||
|
finish
|
||||||
|
endif
|
||||||
|
|
||||||
|
runtime! syntax/html.vim
|
||||||
|
unlet b:current_syntax
|
||||||
|
|
||||||
|
runtime! syntax/tt2.vim
|
||||||
|
unlet b:current_syntax
|
||||||
|
|
||||||
|
syn cluster htmlPreProc add=@tt2_top_cluster
|
||||||
|
|
||||||
|
let b:current_syntax = "tt2html"
|
20
syntax/tt2js.vim
Normal file
20
syntax/tt2js.vim
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
" Language: TT2 embedded with Javascript
|
||||||
|
" Maintainer: Andy Lester <andy@petdance.com>
|
||||||
|
" Author: Yates, Peter <pd.yates@gmail.com>
|
||||||
|
" Homepage: http://github.com/vim-perl/vim-perl
|
||||||
|
" Bugs/requests: http://github.com/vim-perl/vim-perl/issues
|
||||||
|
" Last Change: {{LAST_CHANGE}}
|
||||||
|
|
||||||
|
if exists("b:current_syntax")
|
||||||
|
finish
|
||||||
|
endif
|
||||||
|
|
||||||
|
runtime! syntax/javascript.vim
|
||||||
|
unlet b:current_syntax
|
||||||
|
|
||||||
|
runtime! syntax/tt2.vim
|
||||||
|
unlet b:current_syntax
|
||||||
|
|
||||||
|
syn cluster javascriptPreProc add=@tt2_top_cluster
|
||||||
|
|
||||||
|
let b:current_syntax = "tt2js"
|
3278
syntax/xs.vim
Normal file
3278
syntax/xs.vim
Normal file
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user