comparison runtime/filetype.vim @ 26:404aac550f35 v7.0017

updated for version 7.0017
author vimboss
date Thu, 07 Oct 2004 21:02:47 +0000
parents 8ff7fd162d3c
children f6033dcbaf31
comparison
equal deleted inserted replaced
25:8cde1a064c7c 26:404aac550f35
1 " Vim support file to detect file types 1 " Vim support file to detect file types
2 " 2 "
3 " Maintainer: Bram Moolenaar <Bram@vim.org> 3 " Maintainer: Bram Moolenaar <Bram@vim.org>
4 " Last Change: 2004 Sep 11 4 " Last Change: 2004 Oct 02
5 5
6 " Listen very carefully, I will say this only once 6 " Listen very carefully, I will say this only once
7 if exists("did_load_filetypes") 7 if exists("did_load_filetypes")
8 finish 8 finish
9 endif 9 endif
1337 endif 1337 endif
1338 if exists("b:is_bash") 1338 if exists("b:is_bash")
1339 unlet b:is_bash 1339 unlet b:is_bash
1340 endif 1340 endif
1341 endif 1341 endif
1342 setf sh 1342 call SetFileTypeShell("sh")
1343 endfun
1344
1345 " For shell-like file types, check for an "exec" command hidden in a comment,
1346 " as used for Tcl.
1347 fun! SetFileTypeShell(name)
1348 let l = 2
1349 while l < 20 && l < line("$") && getline(l) =~ '^\s*\(#\|$\)'
1350 " Skip empty and comment lines.
1351 let l = l + 1
1352 endwhile
1353 if l < line("$") && getline(l) =~ '\s*exec\s' && getline(l - 1) =~ '^\s*#.*\\$'
1354 " Found an "exec" line after a comment with continuation
1355 let n = substitute(getline(l),'\s*exec\s\+\([^ ]*/\)\=', '', '')
1356 if n =~ '\<tclsh\|\<wish'
1357 setf tcl
1358 return
1359 endif
1360 endif
1361 exe "setf " . a:name
1343 endfun 1362 endfun
1344 1363
1345 " tcsh scripts 1364 " tcsh scripts
1346 au BufNewFile,BufRead .tcshrc*,*.tcsh,tcsh.tcshrc,tcsh.login setf tcsh 1365 au BufNewFile,BufRead .tcshrc*,*.tcsh,tcsh.tcshrc,tcsh.login call SetFileTypeShell("tcsh")
1347 1366
1348 " csh scripts, but might also be tcsh scripts (on some systems csh is tcsh) 1367 " csh scripts, but might also be tcsh scripts (on some systems csh is tcsh)
1349 au BufNewFile,BufRead .login*,.cshrc*,csh.cshrc,csh.login,csh.logout,*.csh,.alias call SetFileTypeCSH() 1368 au BufNewFile,BufRead .login*,.cshrc*,csh.cshrc,csh.login,csh.logout,*.csh,.alias call SetFileTypeCSH()
1350 1369
1351 fun! SetFileTypeCSH() 1370 fun! SetFileTypeCSH()
1352 if exists("g:filetype_csh") 1371 if exists("g:filetype_csh")
1353 exe "setf " . g:filetype_csh 1372 call SetFileTypeShell(g:filetype_csh)
1354 elseif &shell =~ "tcsh" 1373 elseif &shell =~ "tcsh"
1355 setf tcsh 1374 call SetFileTypeShell("tcsh")
1356 else 1375 else
1357 setf csh 1376 call SetFileTypeShell("csh")
1358 endif 1377 endif
1359 endfun 1378 endfun
1360 1379
1361 " Z-Shell script 1380 " Z-Shell script
1362 au BufNewFile,BufRead .zsh*,.zlog*,.zprofile,/etc/zprofile,.zfbfmarks,.zcompdump* setf zsh 1381 au BufNewFile,BufRead .zsh*,.zlog*,.zprofile,/etc/zprofile,.zfbfmarks,.zcompdump* setf zsh