3 " Maintainer: Andy Lester <andy@petdance.com>
4 " URL: http://github.com/petdance/vim-perl/tree/master
5 " Last Change: 2009-07-04
6 " Contributors: Andy Lester <andy@petdance.com>
7 " Hinrik Örn Sigurðsson <hinrik.sig@gmail.com>
9 " Adapted from Perl indent file by Rafael Garcia-Suarez <rgarciasuarez@free.fr>
11 " Suggestions and improvements by :
12 " Aaron J. Sherman (use syntax for hints)
13 " Artem Chuprina (play nice with folding)
15 " This file still relies on stuff from the Perl 5 syntax file, which Perl 6
18 " Things that are not or not properly indented (yet) :
19 " - Continued statements
24 " - Multiline regular expressions (m//x)
25 " (The following probably needs modifying the perl syntax file)
27 " - Heredocs with terminators that don't match \I\i*
29 " Only load this indent file when no other was loaded.
30 if exists("b:did_indent")
35 " Is syntax highlighting active ?
36 let b:indent_use_syntax = has("syntax")
38 setlocal indentexpr=GetPerl6Indent()
40 " we reset it first because the Perl 5 indent file might have been loaded due
41 " to a .pl/pm file extension, and indent files don't clean up afterwards
44 setlocal indentkeys+=0=,0),0],0>,0»,0=or,0=and
45 if !b:indent_use_syntax
46 setlocal indentkeys+=0=EO
49 " Only define the function once.
50 if exists("*GetPerl6Indent")
57 function GetPerl6Indent()
59 " Get the line to be indented
60 let cline = getline(v:lnum)
62 " Indent POD markers to column 0
63 if cline =~ '^\s*=\L\@!'
67 " Don't reindent coments on first column
72 " Get current syntax item at the line's first char
74 if b:indent_use_syntax
75 let csynid = synIDattr(synID(v:lnum,1,0),"name")
78 " Don't reindent POD and heredocs
84 " Now get the indent of the previous perl line.
86 " Find a non-blank line above the current line.
87 let lnum = prevnonblank(v:lnum - 1)
88 " Hit the start of the file, use zero indent.
92 let line = getline(lnum)
93 let ind = indent(lnum)
94 " Skip heredocs, POD, and comments on 1st column
95 if b:indent_use_syntax
98 let synid = synIDattr(synID(lnum,1,0),"name")
99 if (synid =~ "^p6Pod" || synid =~ "p6Comment")
100 let lnum = prevnonblank(lnum - 1)
104 let line = getline(lnum)
105 let ind = indent(lnum)
113 if line =~ '[<«\[{(]\s*\(#[^)}\]»>]*\)\=$'
116 if cline =~ '^\s*[)}\]»>]'
120 " Indent lines that begin with 'or' or 'and'
121 if cline =~ '^\s*\(or\|and\)\>'
122 if line !~ '^\s*\(or\|and\)\>'
125 elseif line =~ '^\s*\(or\|and\)\>'
133 let &cpo = s:cpo_save
136 " vim:ts=8:sts=4:sw=4:expandtab:ft=vim