diff options
author | Adam Stankiewicz <sheerun@sher.pl> | 2014-08-12 23:45:36 +0200 |
---|---|---|
committer | Adam Stankiewicz <sheerun@sher.pl> | 2014-08-12 23:45:36 +0200 |
commit | 90b24287deb9da69a8079599b8525e2be412f7f2 (patch) | |
tree | 78225d68b68f45ffa55d9fc84b10e64941abf96a /after/ftplugin | |
parent | 5f1223fbc5285689db812236c9100329740a805b (diff) | |
download | vim-polyglot-90b24287deb9da69a8079599b8525e2be412f7f2.tar.gz vim-polyglot-90b24287deb9da69a8079599b8525e2be412f7f2.zip |
Update
Diffstat (limited to 'after/ftplugin')
-rw-r--r-- | after/ftplugin/puppet.vim | 23 |
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 |