3 " Maintainer: vim-perl <vim-perl@googlegroups.com>
4 " Homepage: http://github.com/vim-perl/vim-perl
5 " Bugs/requests: http://github.com/vim-perl/vim-perl/issues
6 " Last Change: 2013-07-21
7 " Contributors: Andy Lester <andy@petdance.com>
8 " Hinrik Örn Sigurðsson <hinrik.sig@gmail.com>
10 " Adapted from indent/perl.vim by Rafael Garcia-Suarez <rgarciasuarez@free.fr>
12 " Suggestions and improvements by :
13 " Aaron J. Sherman (use syntax for hints)
14 " Artem Chuprina (play nice with folding)
16 " This file still relies on stuff from the Perl 5 syntax file, which Perl 6
19 " Things that are not or not properly indented (yet) :
20 " - Continued statements
25 " - Multiline regular expressions (m//x)
26 " (The following probably needs modifying the perl syntax file)
28 " - Heredocs with terminators that don't match \I\i*
30 " Only load this indent file when no other was loaded.
31 if exists("b:did_indent")
36 " Is syntax highlighting active ?
37 let b:indent_use_syntax = has("syntax")
39 setlocal indentexpr=GetPerl6Indent()
41 " we reset it first because the Perl 5 indent file might have been loaded due
42 " to a .pl/pm file extension, and indent files don't clean up afterwards
45 setlocal indentkeys+=0=,0),0],0>,0»,0=or,0=and
46 if !b:indent_use_syntax
47 setlocal indentkeys+=0=EO
53 function! GetPerl6Indent()
55 " Get the line to be indented
56 let cline = getline(v:lnum)
58 " Indent POD markers to column 0
59 if cline =~ '^\s*=\L\@!'
63 " Don't reindent coments on first column
68 " Get current syntax item at the line's first char
70 if b:indent_use_syntax
71 let csynid = synIDattr(synID(v:lnum,1,0),"name")
74 " Don't reindent POD and heredocs
80 " Now get the indent of the previous perl line.
82 " Find a non-blank line above the current line.
83 let lnum = prevnonblank(v:lnum - 1)
84 " Hit the start of the file, use zero indent.
88 let line = getline(lnum)
89 let ind = indent(lnum)
90 " Skip heredocs, POD, and comments on 1st column
91 if b:indent_use_syntax
94 let synid = synIDattr(synID(lnum,1,0),"name")
95 if (synid =~ "^p6Pod" || synid =~ "p6Comment")
96 let lnum = prevnonblank(lnum - 1)
100 let line = getline(lnum)
101 let ind = indent(lnum)
109 if line =~ '[<«\[{(]\s*\(#[^)}\]»>]*\)\=$'
112 if cline =~ '^\s*[)}\]»>]'
116 " Indent lines that begin with 'or' or 'and'
117 if cline =~ '^\s*\(or\|and\)\>'
118 if line !~ '^\s*\(or\|and\)\>'
121 elseif line =~ '^\s*\(or\|and\)\>'
129 let &cpo = s:cpo_save
132 " vim:ts=8:sts=4:sw=4:expandtab:ft=vim