aboutsummaryrefslogtreecommitdiff
path: root/vim/indent
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2018-07-07 13:22:52 +1200
committerTom Ryder <tom@sanctum.geek.nz>2018-07-07 13:22:52 +1200
commit081a9a90846c41c93f4a2a374d94dbd05921f1b5 (patch)
tree0629639c41b6a4414f98242272ce5fa3419a623c /vim/indent
parent702fa2dbcc3fd3817cfa85d060ff4d3b5bb49731 (diff)
downloaddotfiles-081a9a90846c41c93f4a2a374d94dbd05921f1b5.tar.gz
dotfiles-081a9a90846c41c93f4a2a374d94dbd05921f1b5.zip
Further extension of Perl Vim line cont rules
Diffstat (limited to 'vim/indent')
-rw-r--r--vim/indent/perl.vim23
1 files changed, 15 insertions, 8 deletions
diff --git a/vim/indent/perl.vim b/vim/indent/perl.vim
index 9a8f30e1..c9cfe829 100644
--- a/vim/indent/perl.vim
+++ b/vim/indent/perl.vim
@@ -7,8 +7,8 @@ endif
let b:did_indent = 1
" Indent settings
-setlocal indentexpr=GetPerlIndent()
-setlocal indentkeys=o,O,0},0),0]
+setlocal indentexpr=GetPerlIndent(v:lnum)
+setlocal indentkeys=o,O,0=,0=},0=),0=],&,<Bar>,<Space>
" Build patterns for heredoc indenting; note that we detect indented heredocs
" with tildes like <<~EOF, but we don't treat them any differently; note also
@@ -94,16 +94,23 @@ function! GetPerlIndent()
elseif l:pl =~# '[{([]\s*$'
return l:pb + l:sw
- " Preserve base indent after a semicolon or a hash element assignment
- elseif l:pl =~# '[;,]\s*$'
- \ || l:pl =~# '^\s=>.*,\s*$'
- \ || l:pl =~# '^\s*sub\>.*{.*}\s+$'
+ " Never continue after a semicolon or a double-underscore
+ elseif l:pl =~# '\;\s*$'
+ \ || l:pl =~# '__DATA__'
+ \ || l:pl =~# '__END__'
return l:pb
- " Line-continuation: indent half a 'shiftwidth'
- else
+ " Line continuation hints
+ elseif l:pl =~# '[^])},]\s*$'
+ \ || l:cl =~# '^\s*\(and\|or\)\>'
+ \ || l:cl =~# '^\s*\(&&\|||\)'
+ \ || l:cl =~# '^\s*='
return l:pb + l:sw / 2
+ " Default to indent of previous line
+ else
+ return l:pb
+
endif
endfunction