summaryrefslogtreecommitdiffstats
path: root/after/ftplugin/puppet.vim
diff options
context:
space:
mode:
Diffstat (limited to 'after/ftplugin/puppet.vim')
-rw-r--r--after/ftplugin/puppet.vim23
1 files changed, 14 insertions, 9 deletions
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 <buffer> <silent> > ><Esc>:call <SID>puppetalign()<CR>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 <buffer> <silent> > ><Esc>:call <SID>puppetalign()<CR>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