-setlocal foldmethod=syntax
-
setlocal textwidth=100
" indent 4 spaces
au BufEnter *.h let b:fswitchdst = 'cpp,c'
au BufEnter *.h let b:fswitchlocs = 'reg:/include/source/'
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()