diff options
Diffstat (limited to 'after')
-rw-r--r-- | after/ftplugin/puppet.vim | 23 | ||||
-rw-r--r-- | after/syntax/c.vim | 24 |
2 files changed, 38 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 diff --git a/after/syntax/c.vim b/after/syntax/c.vim index 42c9b9db..be34d256 100644 --- a/after/syntax/c.vim +++ b/after/syntax/c.vim @@ -1,4 +1,28 @@ " Vim syntax file +" Language: C Additions +" Maintainer: Jon Haggblad <jon@haeggblad.com> +" URL: http://www.haeggblad.com +" Last Change: 9 Aug 2014 +" Version: 0.1 +" Changelog: +" 0.1 - initial version. +" +" Syntax highlighting for functions in C. +" +" Based on: +" http://stackoverflow.com/questions/736701/class-function-names-highlighting-in-vim + +" ----------------------------------------------------------------------------- +" Highlight Class and Function names. +" ----------------------------------------------------------------------------- +syn match cCustomParen "(" contains=cParen contains=cCppParen +syn match cCustomFunc "\w\+\s*(\@=" contains=cCustomParen +syn match cCustomScope "::" +syn match cCustomClass "\w\+\s*::" contains=cCustomScope + +hi def link cCustomFunc Function + +" Vim syntax file " Language: C Additions " Maintainer: Mikhail Wolfson <mywolfson@gmail.com> " URL: http://web.mit.edu/wolfsonm |