aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2018-07-07 11:30:53 +1200
committerTom Ryder <tom@sanctum.geek.nz>2018-07-07 11:30:53 +1200
commite726e79727de2af472d52f1d60f22be8d8387343 (patch)
tree70b6ed615d334e8cf11b80789a27fcdeb206963e
parent94c3ce9ad589a29e4023e76c0f342098c39d2c0c (diff)
downloaddotfiles-e726e79727de2af472d52f1d60f22be8d8387343.tar.gz
dotfiles-e726e79727de2af472d52f1d60f22be8d8387343.zip
Committing final state of Vim Perl indent
I'm not sure I actually want to use this anymore; will remove it for now in the next commit.
-rw-r--r--vim/indent/perl.vim28
1 files changed, 16 insertions, 12 deletions
diff --git a/vim/indent/perl.vim b/vim/indent/perl.vim
index 71e2c440..01c1259b 100644
--- a/vim/indent/perl.vim
+++ b/vim/indent/perl.vim
@@ -79,27 +79,31 @@ function! GetPerlIndent()
\ ? shiftwidth()
\ : &shiftwidth
+ " Base indent with any fractional indent removed
+ let l:pb = l:pi - l:pi % l:sw
+
" Just follow comment indent
if l:pl =~# '^\s*#'
return l:pi
- " Entering closing brace
+ " Move out with closing brace
elseif l:cl =~# '^\s*[])}]'
- return l:pi >= l:sw
- \ ? l:pi - l:sw - l:pi % l:sw
- \ : 0
+ return l:pb >= l:sw ? l:pb - l:sw : 0
- " After opening brace
+ " Move in after opening brace
elseif l:pl =~# '[{([]\s*$'
- return l:pi + l:sw
+ 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+$'
+ return l:pb
- " After a semicolon, comma, or closing brace
- elseif l:pl =~# '[;,}]\s*$'
- return l:pi - l:pi % l:sw
+ " Line-continuation: indent half a 'shiftwidth'
+ else
+ return l:pb + l:sw / 2
- " Continued line; add half 'shiftwidth'
- elseif l:sw >= 2
- return l:pi - l:pi % l:sw + l:sw / 2
endif
endfunction