diff options
author | Bram Moolenaar <Bram@vim.org> | 2004-10-07 21:02:47 +0000 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2004-10-07 21:02:47 +0000 |
commit | 3fdfa4a9a52ab3d1a790262ee872a49853ad4626 (patch) | |
tree | 76f57a06a5f3b9e0abc15446b38722658fde7e1e /runtime/filetype.vim | |
parent | e5f258eb4c4b87ea1d6f61c1a0a9deecbb5d9726 (diff) |
updated for version 7.0017v7.0017
Diffstat (limited to 'runtime/filetype.vim')
-rw-r--r-- | runtime/filetype.vim | 31 |
1 files changed, 25 insertions, 6 deletions
diff --git a/runtime/filetype.vim b/runtime/filetype.vim index 5fd12aa9fc..26c222f0bb 100644 --- a/runtime/filetype.vim +++ b/runtime/filetype.vim @@ -1,7 +1,7 @@ " Vim support file to detect file types " " Maintainer: Bram Moolenaar <Bram@vim.org> -" Last Change: 2004 Sep 11 +" Last Change: 2004 Oct 02 " Listen very carefully, I will say this only once if exists("did_load_filetypes") @@ -1339,22 +1339,41 @@ fun! SetFileTypeSH(name) unlet b:is_bash endif endif - setf sh + call SetFileTypeShell("sh") +endfun + +" For shell-like file types, check for an "exec" command hidden in a comment, +" as used for Tcl. +fun! SetFileTypeShell(name) + let l = 2 + while l < 20 && l < line("$") && getline(l) =~ '^\s*\(#\|$\)' + " Skip empty and comment lines. + let l = l + 1 + endwhile + if l < line("$") && getline(l) =~ '\s*exec\s' && getline(l - 1) =~ '^\s*#.*\\$' + " Found an "exec" line after a comment with continuation + let n = substitute(getline(l),'\s*exec\s\+\([^ ]*/\)\=', '', '') + if n =~ '\<tclsh\|\<wish' + setf tcl + return + endif + endif + exe "setf " . a:name endfun " tcsh scripts -au BufNewFile,BufRead .tcshrc*,*.tcsh,tcsh.tcshrc,tcsh.login setf tcsh +au BufNewFile,BufRead .tcshrc*,*.tcsh,tcsh.tcshrc,tcsh.login call SetFileTypeShell("tcsh") " csh scripts, but might also be tcsh scripts (on some systems csh is tcsh) au BufNewFile,BufRead .login*,.cshrc*,csh.cshrc,csh.login,csh.logout,*.csh,.alias call SetFileTypeCSH() fun! SetFileTypeCSH() if exists("g:filetype_csh") - exe "setf " . g:filetype_csh + call SetFileTypeShell(g:filetype_csh) elseif &shell =~ "tcsh" - setf tcsh + call SetFileTypeShell("tcsh") else - setf csh + call SetFileTypeShell("csh") endif endfun |