home *** CD-ROM | disk | FTP | other *** search
/ SGI Freeware 1999 August / SGI Freeware 1999 August.iso / dist / fw_vim.idb / usr / freeware / share / vim / syntax / scripts.vim.z / scripts.vim
Encoding:
Text File  |  1998-10-28  |  2.5 KB  |  90 lines

  1. " Vim syntax support file
  2. " Maintainer:    Bram Moolenaar <Bram@vim.org>
  3. " Last change:    1997 August 26
  4.  
  5. " This file is called by an autocommand for every file that has just been
  6. " loaded into a buffer.  It checks if the first line of the file is recognized
  7. " as a file for which syntax highlighting is supported.  Only do this if there
  8. " was no match with a filename extension.
  9.  
  10. if !has("syntax_items")
  11.  
  12.   " Source the user-specified syntax highlighting file
  13.   if exists("myscriptsfile")
  14.     if file_readable(expand(myscriptsfile))
  15.       execute "so " . myscriptsfile
  16.     endif
  17.   endif
  18.  
  19. endif
  20.  
  21.  
  22. if !has("syntax_items")
  23.  
  24.   " Bourne-like shell scripts: sh ksh bash
  25.   if getline(1) =~ '^#!.*[/\\][bk]\=a\=sh\>'
  26.     if exists("is_bash")
  27.       unlet is_bash
  28.     endif
  29.     if exists("is_kornshell")
  30.       unlet is_kornshell
  31.     endif
  32.     " if bash is sh on your system as on Linux, you may prefer to
  33.     " add the following in your .vimrc file:
  34.     " let bash_is_sh=1
  35.     if exists("bash_is_sh") || getline(1) =~ '^#!.*[/\\]bash\>'
  36.       let is_bash=1
  37.     elseif getline(1) =~ '^#!.*[/\\]ksh\>'
  38.       let is_kornshell=1
  39.     endif
  40.     so <sfile>:p:h/sh.vim
  41.  
  42.   " csh and tcsh scripts
  43.   elseif getline(1) =~ '^#!.*[/\\]t\=csh\>'
  44.     so <sfile>:p:h/csh.vim
  45.  
  46.   " Z shell scripts
  47.   elseif getline(1) =~ '^#!.*[/\\]zsh\>'
  48.     so <sfile>:p:h/zsh.vim
  49.  
  50.   " ELM Mail files
  51.   elseif getline(1) =~ "^From [a-zA-Z][a-zA-Z_0-9\.-]*@.*[12][09][0-9][0-9]$"
  52.     so <sfile>:p:h/mail.vim
  53.  
  54.   " Expect scripts
  55.   elseif getline(1) =~ '^#!.*[/\\]expect\>'
  56.     so <sfile>:p:h/expect.vim
  57.  
  58.   " Perl
  59.   elseif getline(1) =~ '^#!.*[/\\][^/\\]*perl[^/\\]*\>'
  60.     so <sfile>:p:h/perl.vim
  61.  
  62.   " Vim scripts (must have '" vim' as the first line to trigger this)
  63.   elseif getline(1) =~ '^" *[vV]im$'
  64.     so <sfile>:p:h/vim.vim
  65.  
  66.   " Diff file:
  67.   " - "diff" in first line (context diff)
  68.   " - "--- " in first line and "+++ " in second line (unified diff).
  69.   " - "*** " in first line and "--- " in second line (context diff).
  70.   elseif getline(1) =~ '^diff\>' || (getline(1) =~ '^--- ' && getline(2) =~ '^+++ ') || (getline(1) =~ '^\*\*\* ' && getline(2) =~ '^--- ')
  71.     so <sfile>:p:h/diff.vim
  72.  
  73.   " PostScript Files (must have %!PS as the first line, like a2ps output)
  74.   elseif getline(1) =~ '^%![ \t]*PS'
  75.     so <sfile>:p:h/postscr.vim
  76.  
  77.   " Awk scripts
  78.   elseif getline(1) =~ '^#!.*awk\>'
  79.     so <sfile>:p:h/awk.vim
  80.  
  81.   " AmigaDos scripts
  82.   elseif $TERM == "amiga" && (getline(1) =~ "^;" || getline(1) =~ "^\.[bB][rR][aA]")
  83.     so <sfile>:p:h/amiga.vim
  84.  
  85.   endif
  86.  
  87. endif
  88.  
  89. " vim: ts=8
  90.