X-Git-Url: http://git.madism.org/?p=~madcoder%2Fdotfiles.git;a=blobdiff_plain;f=vim%2Fftplugin%2Fc.vim;fp=vim%2Fftplugin%2Fc.vim;h=a58c2a9948facac7f681fb45243b98137bb71819;hp=0000000000000000000000000000000000000000;hb=b432593cd0e91f2b0eb9bba5d106b563cd98e916;hpb=d55a1c24af98dc51263bc04f9d08ce2bcfd5722b diff --git a/vim/ftplugin/c.vim b/vim/ftplugin/c.vim new file mode 100644 index 0000000..a58c2a9 --- /dev/null +++ b/vim/ftplugin/c.vim @@ -0,0 +1,31 @@ +if exists("b:did_ftplugin") + finish +endif +let b:did_ftplugin = 1 + +if findfile("Makefile", ".;/") != '' + let &l:makeprg="make -f ".findfile("Makefile", ".;/") +endif + +function! XCodeFold(lnum) + let line = getline(a:lnum) + if line =~ '^.pragma mark -' + return '<1' + endif + if line =~ '^.pragma mark' + return '>1' + endif + return '=' +endfunction + +function! XCodeFoldText() + let text = v:folddashes . " [ " + let text .= substitute(getline(v:foldstart), '#pragma mark ', '', 'g') + let text .= " ] " . string(v:foldend - v:foldstart + 1) . " lines " + return text +endfunction + +setl foldexpr=XCodeFold(v:lnum) +setl foldtext=XCodeFoldText() +setl foldmethod=expr +