Migrate to a "cplusplus" filetype for C++ in vim.
This "cplusplus" filetype permits the sourcing of `cpp.vim` and `doxygen.vim` as lower-level files from itself. This should permit `doxygen.vim` to source from `cpp.vim` and avoid endless recursion, when handling code-in-comments formatting.
This commit is contained in:
35
vim/filetype.vim
Normal file
35
vim/filetype.vim
Normal file
@ -0,0 +1,35 @@
|
||||
" Cynlib
|
||||
" .cc and .cpp files can be C++ or Cynlib.
|
||||
au BufNewFile,BufRead *.cc
|
||||
\ if exists("cynlib_syntax_for_cc")|setf cynlib|else|setf cplusplus|endif
|
||||
au BufNewFile,BufRead *.cpp
|
||||
\ if exists("cynlib_syntax_for_cpp")|setf cynlib|else|setf cplusplus|endif
|
||||
|
||||
" C++
|
||||
au BufNewFile,BufRead *.cxx,*.c++,*.hh,*.hxx,*.hpp,*.ipp,*.moc,*.tcc,*.inl setf cplusplus
|
||||
if has("fname_case")
|
||||
au BufNewFile,BufRead *.C,*.H setf cplusplus
|
||||
endif
|
||||
|
||||
function! CheckForADAM()
|
||||
if match(getline(1, min([line("$"), 200])), '^@\(interface\|end\|class\)') > -1
|
||||
if exists("g:c_syntax_for_h")
|
||||
setf objc
|
||||
else
|
||||
setf objcpp
|
||||
endif
|
||||
elseif exists("g:c_syntax_for_h")
|
||||
setf c
|
||||
elseif exists("g:ch_syntax_for_h")
|
||||
setf ch
|
||||
else
|
||||
setf cplusplus
|
||||
endif
|
||||
endfunction
|
||||
|
||||
" .h files can be C, Ch C++, ObjC or ObjC++.
|
||||
" Set c_syntax_for_h if you want C, ch_syntax_for_h if you want Ch. ObjC is
|
||||
" detected automatically.
|
||||
au BufNewFile,BufRead *.h setf cplusplus "call CheckForADAM()
|
||||
au BufNewFile,BufRead *.cxx,*.cpp,*.hpp,*.cc,*.h setf cplusplus
|
||||
|
||||
Reference in New Issue
Block a user