From 90b24287deb9da69a8079599b8525e2be412f7f2 Mon Sep 17 00:00:00 2001 From: Adam Stankiewicz Date: Tue, 12 Aug 2014 23:45:36 +0200 Subject: Update --- after/ftplugin/puppet.vim | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) (limited to 'after/ftplugin/puppet.vim') diff --git a/after/ftplugin/puppet.vim b/after/ftplugin/puppet.vim index 2bac2dc8..f976a457 100644 --- a/after/ftplugin/puppet.vim +++ b/after/ftplugin/puppet.vim @@ -1,11 +1,16 @@ -inoremap > >:call puppetalign()A -function! s:puppetalign() - let p = '^\s*\w+\s*[=+]>.*$' - let lineContainsHashrocket = getline('.') =~# '^\s*\w+\s*[=+]>' - let hashrocketOnPrevLine = getline(line('.') - 1) =~# p - let hashrocketOnNextLine = getline(line('.') + 1) =~# p - if exists(':Tabularize') " && lineContainsHashrocket && (hashrocketOnPrevLine || hashrocketOnNextLine) +if !exists('g:puppet_align_hashes') + let g:puppet_align_hashes = 1 +endif + +if g:puppet_align_hashes && exists(':Tabularize') + inoremap > >:call puppetalign()a + function! s:puppetalign() + let p = '^\s*\w+\s*[=+]>.*$' + let column = strlen(substitute(getline('.')[0:col('.')],'\([^=]\|=[^>]\)','','g')) + let position = strlen(matchstr(getline('.')[0:col('.')],'.*=>\s*\zs.*')) Tabularize /=>/l1 normal! 0 - endif -endfunction + echo repeat('\([^=]\|=[^>]\)*=>',column).'\s\{-\}'.repeat('.',position) + call search(repeat('\([^=]\|=[^>]\)*=>',column).'\s\{-\}'.repeat('.',position),'ce',line('.')) + endfunction +endif -- cgit v1.2.3