Currently this script doesn't set the indentation style for the standard library
headers under libstdc++/ because they lack a file extension.  But they do
have a modeline, so the file type is still set appropriately by Vim.  So by
inspecting &filetype, we can also detect these standard library headers as
C-like files.

contrib/ChangeLog:

        * vimrc (SetStyle): Also look at &filetype to determine whether to
        a file is C-like.
---
 contrib/vimrc | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/contrib/vimrc b/contrib/vimrc
index bbbe1dd449b..e2ccbe0fd10 100644
--- a/contrib/vimrc
+++ b/contrib/vimrc
@@ -39,7 +39,7 @@ function! SetStyle()
   setlocal formatoptions-=ro formatoptions+=cqlt
   let l:ext = fnamemodify(l:fname, ":e")
   let l:c_exts = ['c', 'h', 'cpp', 'cc', 'C', 'H', 'def', 'java']
-  if index(l:c_exts, l:ext) != -1
+  if index(l:c_exts, l:ext) != -1 || &filetype == "cpp" || &filetype == "c"
     setlocal cindent
     setlocal cinoptions=>4,n-2,{2,^-2,:2,=2,g0,f0,h2,p4,t0,+2,(0,u0,w1,m0
   endif
-- 
2.25.0.114.g5b0ca878e0

Reply via email to