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 ++++++++++++++--------- after/syntax/c.vim | 24 ++++++++++++++++++++++++ 2 files changed, 38 insertions(+), 9 deletions(-) (limited to 'after') 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 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,3 +1,27 @@ +" Vim syntax file +" Language: C Additions +" Maintainer: Jon Haggblad +" 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 -- cgit v1.2.3