-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathperl.vim
35 lines (31 loc) · 900 Bytes
/
perl.vim
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
if ! exists("g:did_perl_statusline")
setlocal statusline+=%(\ %{StatusLineIndexLine()}%)
setlocal statusline+=%=
setlocal statusline+=%f\
setlocal statusline+=%P
let g:did_perl_statusline = 1
endif
if has( 'perl' )
perl << EOP
use strict;
sub current_sub {
my $curwin = $main::curwin;
my $curbuf = $main::curbuf;
my @document = map { $curbuf->Get($_) } 0 .. $curbuf->Count;
my ( $line_number, $column ) = $curwin->Cursor;
my $sub_name = '(not in sub)';
for my $i ( reverse ( 1 .. $line_number -1 ) ) {
my $line = $document[$i];
if ( $line =~ /^\s*sub\s+(\w+)\b/ ) {
$sub_name = $1;
last;
}
}
VIM::DoCommand "let subName='$sub_name '";
}
EOP
function! StatusLineIndexLine()
perl current_sub()
return subName
endfunction
endif