X-Git-Url: https://git.rmz.io/dotfiles.git/blobdiff_plain/7766518825040eacb1c168c3bb004d22d2d73f30..d4b51f09d83f75a663c5711af77e0e6da40764a9:/vim/ftplugin/cpp.vim diff --git a/vim/ftplugin/cpp.vim b/vim/ftplugin/cpp.vim index cb3d9bd..7dd40e6 100644 --- a/vim/ftplugin/cpp.vim +++ b/vim/ftplugin/cpp.vim @@ -1,5 +1,3 @@ -setlocal foldmethod=syntax - setlocal textwidth=100 " indent 4 spaces @@ -14,9 +12,23 @@ setlocal cinkeys-=0# " don't reindent PP directives setlocal cinoptions+=:0 " don't indent case labels " Load the doxygen syntax -let g:load_doxygen_syntax=1 +let b:load_doxygen_syntax = 1 augroup fswitch - au BufEnter *.h let b:fswitchdst = 'cpp,c' - au BufEnter *.h let b:fswitchlocs = 'reg:/include/source/' + au BufEnter *.h let b:fswitchdst = 'cpp,c' + au BufEnter *.h let b:fswitchlocs = 'reg:/include/source/' + au BufEnter *.cpp let b:fswitchdst = 'h' + au BufEnter *.cpp let b:fswitchlocs = 'reg:/\Csource/include/' augroup END + +setlocal foldmethod=syntax +" set foldlevel according to number of matches of 'namespace' and 'class' not +" containing ';' +function! InitialFoldLevel() + let v:errmsg = "" + keepjumps keeppatterns silent! 1,/}/s/^\(namespace\|class\) \+[^;]*$//n + if v:errmsg == "" + let &foldlevel=str2nr(split(v:statusmsg)[0]) + endif +endf +call InitialFoldLevel()