cf9f5ab
" Vim support file to detect file types
cf9f5ab
"
cf9f5ab
" Maintainer:	Bram Moolenaar <Bram@vim.org>
cf9f5ab
" Last Change:	2008 Nov 01
cf9f5ab
cf9f5ab
" Listen very carefully, I will say this only once
cf9f5ab
if exists("did_load_filetypes")
cf9f5ab
  finish
cf9f5ab
endif
cf9f5ab
let did_load_filetypes = 1
cf9f5ab
cf9f5ab
" Line continuation is used here, remove 'C' from 'cpoptions'
cf9f5ab
let s:cpo_save = &cpo
cf9f5ab
set cpo&vim
cf9f5ab
cf9f5ab
augroup filetypedetect
cf9f5ab
cf9f5ab
" Ignored extensions
cf9f5ab
if exists("*fnameescape")
cf9f5ab
au BufNewFile,BufRead ?\+.orig,?\+.bak,?\+.old,?\+.new,?\+.dpkg-dist,?\+.dpkg-old,?\+.rpmsave,?\+.rpmnew
cf9f5ab
	\ exe "doau filetypedetect BufRead " . fnameescape(expand("<afile>:r"))
cf9f5ab
au BufNewFile,BufRead *~
cf9f5ab
	\ let s:name = expand("<afile>") |
cf9f5ab
	\ let s:short = substitute(s:name, '\~$', '', '') |
cf9f5ab
	\ if s:name != s:short && s:short != "" |
cf9f5ab
	\   exe "doau filetypedetect BufRead " . fnameescape(s:short) |
cf9f5ab
	\ endif |
cf9f5ab
	\ unlet! s:name s:short
cf9f5ab
au BufNewFile,BufRead ?\+.in
cf9f5ab
	\ if expand("<afile>:t") != "configure.in" |
cf9f5ab
	\   exe "doau filetypedetect BufRead " . fnameescape(expand("<afile>:r")) |
cf9f5ab
	\ endif
cf9f5ab
elseif &verbose > 0
cf9f5ab
  echomsg "Warning: some filetypes will not be recognized because this version of Vim does not have fnameescape()"
cf9f5ab
endif
cf9f5ab
cf9f5ab
" Pattern used to match file names which should not be inspected.
cf9f5ab
" Currently finds compressed files.
cf9f5ab
if !exists("g:ft_ignore_pat")
cf9f5ab
  let g:ft_ignore_pat = '\.\(Z\|gz\|bz2\|zip\|tgz\)$'
cf9f5ab
endif
cf9f5ab
cf9f5ab
" Function used for patterns that end in a star: don't set the filetype if the
cf9f5ab
" file name matches ft_ignore_pat.
cf9f5ab
func! s:StarSetf(ft)
cf9f5ab
  if expand("<amatch>") !~ g:ft_ignore_pat
cf9f5ab
    exe 'setf ' . a:ft
cf9f5ab
  endif
cf9f5ab
endfunc
cf9f5ab
cf9f5ab
" Abaqus or Trasys
cf9f5ab
au BufNewFile,BufRead *.inp			call s:Check_inp()
cf9f5ab
cf9f5ab
func! s:Check_inp()
cf9f5ab
  if getline(1) =~ '^\*'
cf9f5ab
    setf abaqus
cf9f5ab
  else
cf9f5ab
    let n = 1
cf9f5ab
    if line("$") > 500
cf9f5ab
      let nmax = 500
cf9f5ab
    else
cf9f5ab
      let nmax = line("$")
cf9f5ab
    endif
cf9f5ab
    while n <= nmax
cf9f5ab
      if getline(n) =~? "^header surface data"
cf9f5ab
	setf trasys
cf9f5ab
	break
cf9f5ab
      endif
cf9f5ab
      let n = n + 1
cf9f5ab
    endwhile
cf9f5ab
  endif
cf9f5ab
endfunc
cf9f5ab
cf9f5ab
" A-A-P recipe
cf9f5ab
au BufNewFile,BufRead *.aap			setf aap
cf9f5ab
cf9f5ab
" A2ps printing utility
cf9f5ab
au BufNewFile,BufRead etc/a2ps.cfg,etc/a2ps/*.cfg,a2psrc,.a2psrc setf a2ps
cf9f5ab
cf9f5ab
" ABAB/4
cf9f5ab
au BufNewFile,BufRead *.abap			setf abap
cf9f5ab
cf9f5ab
" ABC music notation
cf9f5ab
au BufNewFile,BufRead *.abc			setf abc
cf9f5ab
cf9f5ab
" ABEL
cf9f5ab
au BufNewFile,BufRead *.abl			setf abel
cf9f5ab
cf9f5ab
" AceDB
cf9f5ab
au BufNewFile,BufRead *.wrm			setf acedb
cf9f5ab
cf9f5ab
" Ada (83, 9X, 95)
cf9f5ab
au BufNewFile,BufRead *.adb,*.ads,*.ada		setf ada
cf9f5ab
if has("vms")
cf9f5ab
  au BufNewFile,BufRead *.gpr,*.ada_m,*.adc	setf ada
cf9f5ab
else
cf9f5ab
  au BufNewFile,BufRead *.gpr			setf ada
cf9f5ab
endif
cf9f5ab
cf9f5ab
" AHDL
cf9f5ab
au BufNewFile,BufRead *.tdf			setf ahdl
cf9f5ab
cf9f5ab
" AMPL
cf9f5ab
au BufNewFile,BufRead *.run			setf ampl
cf9f5ab
cf9f5ab
" Ant
cf9f5ab
au BufNewFile,BufRead build.xml			setf ant
cf9f5ab
cf9f5ab
" Apache style config file
cf9f5ab
au BufNewFile,BufRead proftpd.conf*		call s:StarSetf('apachestyle')
cf9f5ab
cf9f5ab
" Apache config file
cf9f5ab
au BufNewFile,BufRead .htaccess			 setf apache
cf9f5ab
au BufNewFile,BufRead httpd.conf*,srm.conf*,access.conf*,apache.conf*,apache2.conf*,/etc/apache2/*.conf* call s:StarSetf('apache')
cf9f5ab
cf9f5ab
" XA65 MOS6510 cross assembler
cf9f5ab
au BufNewFile,BufRead *.a65			setf a65
cf9f5ab
cf9f5ab
" Applescript
cf9f5ab
au BufNewFile,BufRead *.scpt			setf applescript
cf9f5ab
cf9f5ab
" Applix ELF
cf9f5ab
au BufNewFile,BufRead *.am
cf9f5ab
	\ if expand("<afile>") !~? 'Makefile.am\>' | setf elf | endif
cf9f5ab
cf9f5ab
" ALSA configuration
cf9f5ab
au BufNewFile,BufRead ~/.asoundrc,/usr/share/alsa/alsa.conf,/etc/asound.conf	setf alsaconf
cf9f5ab
cf9f5ab
" Arc Macro Language
cf9f5ab
au BufNewFile,BufRead *.aml			setf aml
cf9f5ab
cf9f5ab
" Arch Inventory file
cf9f5ab
au BufNewFile,BufRead .arch-inventory,=tagging-method	setf arch
cf9f5ab
cf9f5ab
" ART*Enterprise (formerly ART-IM)
cf9f5ab
au BufNewFile,BufRead *.art			setf art
cf9f5ab
cf9f5ab
" ASN.1
cf9f5ab
au BufNewFile,BufRead *.asn,*.asn1		setf asn
cf9f5ab
cf9f5ab
" Active Server Pages (with Visual Basic Script)
cf9f5ab
au BufNewFile,BufRead *.asa
cf9f5ab
	\ if exists("g:filetype_asa") |
cf9f5ab
	\   exe "setf " . g:filetype_asa |
cf9f5ab
	\ else |
cf9f5ab
	\   setf aspvbs |
cf9f5ab
	\ endif
cf9f5ab
cf9f5ab
" Active Server Pages (with Perl or Visual Basic Script)
cf9f5ab
au BufNewFile,BufRead *.asp
cf9f5ab
	\ if exists("g:filetype_asp") |
cf9f5ab
	\   exe "setf " . g:filetype_asp |
cf9f5ab
	\ elseif getline(1) . getline(2) . getline(3) =~? "perlscript" |
cf9f5ab
	\   setf aspperl |
cf9f5ab
	\ else |
cf9f5ab
	\   setf aspvbs |
cf9f5ab
	\ endif
cf9f5ab
cf9f5ab
" Grub (must be before catch *.lst)
cf9f5ab
au BufNewFile,BufRead /boot/grub/menu.lst,/boot/grub/grub.conf,/etc/grub.conf	setf grub
cf9f5ab
cf9f5ab
" Assembly (all kinds)
cf9f5ab
" *.lst is not pure assembly, it has two extra columns (address, byte codes)
cf9f5ab
au BufNewFile,BufRead *.asm,*.[sS],*.[aA],*.mac,*.lst	call s:FTasm()
cf9f5ab
cf9f5ab
" This function checks for the kind of assembly that is wanted by the user, or
cf9f5ab
" can be detected from the first five lines of the file.
cf9f5ab
func! s:FTasm()
cf9f5ab
  " make sure b:asmsyntax exists
cf9f5ab
  if !exists("b:asmsyntax")
cf9f5ab
    let b:asmsyntax = ""
cf9f5ab
  endif
cf9f5ab
cf9f5ab
  if b:asmsyntax == ""
cf9f5ab
    call s:FTasmsyntax()
cf9f5ab
  endif
cf9f5ab
cf9f5ab
  " if b:asmsyntax still isn't set, default to asmsyntax or GNU
cf9f5ab
  if b:asmsyntax == ""
cf9f5ab
    if exists("g:asmsyntax")
cf9f5ab
      let b:asmsyntax = g:asmsyntax
cf9f5ab
    else
cf9f5ab
      let b:asmsyntax = "asm"
cf9f5ab
    endif
cf9f5ab
  endif
cf9f5ab
cf9f5ab
  exe "setf " . fnameescape(b:asmsyntax)
cf9f5ab
endfunc
cf9f5ab
cf9f5ab
func! s:FTasmsyntax()
cf9f5ab
  " see if file contains any asmsyntax=foo overrides. If so, change
cf9f5ab
  " b:asmsyntax appropriately
cf9f5ab
  let head = " ".getline(1)." ".getline(2)." ".getline(3)." ".getline(4).
cf9f5ab
	\" ".getline(5)." "
cf9f5ab
  let match = matchstr(head, '\sasmsyntax=\zs[a-zA-Z0-9]\+\ze\s')
cf9f5ab
  if match != ''
cf9f5ab
    let b:asmsyntax = match
cf9f5ab
  elseif ((head =~? '\.title') || (head =~? '\.ident') || (head =~? '\.macro') || (head =~? '\.subtitle') || (head =~? '\.library'))
cf9f5ab
    let b:asmsyntax = "vmasm"
cf9f5ab
  endif
cf9f5ab
endfunc
cf9f5ab
cf9f5ab
" Macro (VAX)
cf9f5ab
au BufNewFile,BufRead *.mar			setf vmasm
cf9f5ab
cf9f5ab
" Atlas
cf9f5ab
au BufNewFile,BufRead *.atl,*.as		setf atlas
cf9f5ab
cf9f5ab
" Autoit v3
cf9f5ab
au BufNewFile,BufRead *.au3			setf autoit
cf9f5ab
cf9f5ab
" Autohotkey
cf9f5ab
au BufNewFile,BufRead *.ahk			setf autohotkey
cf9f5ab
cf9f5ab
" Automake
cf9f5ab
au BufNewFile,BufRead [mM]akefile.am,GNUmakefile.am	setf automake
cf9f5ab
cf9f5ab
" Autotest .at files are actually m4
cf9f5ab
au BufNewFile,BufRead *.at			setf m4
cf9f5ab
cf9f5ab
" Avenue
cf9f5ab
au BufNewFile,BufRead *.ave			setf ave
cf9f5ab
cf9f5ab
" Awk
cf9f5ab
au BufNewFile,BufRead *.awk			setf awk
cf9f5ab
cf9f5ab
" B
cf9f5ab
au BufNewFile,BufRead *.mch,*.ref,*.imp		setf b
cf9f5ab
cf9f5ab
" BASIC or Visual Basic
cf9f5ab
au BufNewFile,BufRead *.bas			call s:FTVB("basic")
cf9f5ab
cf9f5ab
" Check if one of the first five lines contains "VB_Name".  In that case it is
cf9f5ab
" probably a Visual Basic file.  Otherwise it's assumed to be "alt" filetype.
cf9f5ab
func! s:FTVB(alt)
cf9f5ab
  if getline(1).getline(2).getline(3).getline(4).getline(5) =~? 'VB_Name\|Begin VB\.\(Form\|MDIForm\|UserControl\)'
cf9f5ab
    setf vb
cf9f5ab
  else
cf9f5ab
    exe "setf " . a:alt
cf9f5ab
  endif
cf9f5ab
endfunc
cf9f5ab
cf9f5ab
" Visual Basic Script (close to Visual Basic)
cf9f5ab
au BufNewFile,BufRead *.vbs,*.dsm,*.ctl		setf vb
cf9f5ab
cf9f5ab
" IBasic file (similar to QBasic)
cf9f5ab
au BufNewFile,BufRead *.iba,*.ibi		setf ibasic
cf9f5ab
cf9f5ab
" FreeBasic file (similar to QBasic)
cf9f5ab
au BufNewFile,BufRead *.fb,*.bi			setf freebasic
cf9f5ab
cf9f5ab
" Batch file for MSDOS.
cf9f5ab
au BufNewFile,BufRead *.bat,*.sys		setf dosbatch
cf9f5ab
" *.cmd is close to a Batch file, but on OS/2 Rexx files also use *.cmd.
cf9f5ab
au BufNewFile,BufRead *.cmd
cf9f5ab
	\ if getline(1) =~ '^/\*' | setf rexx | else | setf dosbatch | endif
cf9f5ab
cf9f5ab
" Batch file for 4DOS
cf9f5ab
au BufNewFile,BufRead *.btm			call s:FTbtm()
cf9f5ab
func! s:FTbtm()
cf9f5ab
  if exists("g:dosbatch_syntax_for_btm") && g:dosbatch_syntax_for_btm
cf9f5ab
    setf dosbatch
cf9f5ab
  else
cf9f5ab
    setf btm
cf9f5ab
  endif
cf9f5ab
endfunc
cf9f5ab
cf9f5ab
" BC calculator
cf9f5ab
au BufNewFile,BufRead *.bc			setf bc
cf9f5ab
cf9f5ab
" BDF font
cf9f5ab
au BufNewFile,BufRead *.bdf			setf bdf
cf9f5ab
cf9f5ab
" BibTeX bibliography database file
cf9f5ab
au BufNewFile,BufRead *.bib			setf bib
cf9f5ab
cf9f5ab
" BibTeX Bibliography Style
cf9f5ab
au BufNewFile,BufRead *.bst			setf bst
cf9f5ab
cf9f5ab
" BIND configuration
cf9f5ab
au BufNewFile,BufRead named.conf,rndc.conf	setf named
cf9f5ab
cf9f5ab
" BIND zone
cf9f5ab
au BufNewFile,BufRead named.root		setf bindzone
cf9f5ab
au BufNewFile,BufRead *.db			call s:BindzoneCheck('')
cf9f5ab
cf9f5ab
func! s:BindzoneCheck(default)
cf9f5ab
  if getline(1).getline(2).getline(3).getline(4) =~ '^; <<>> DiG [0-9.]\+ <<>>\|BIND.*named\|$ORIGIN\|$TTL\|IN\s\+SOA'
cf9f5ab
    setf bindzone
cf9f5ab
  elseif a:default != ''
cf9f5ab
    exe 'setf ' . a:default
cf9f5ab
  endif
cf9f5ab
endfunc
cf9f5ab
cf9f5ab
" Blank
cf9f5ab
au BufNewFile,BufRead *.bl			setf blank
cf9f5ab
cf9f5ab
" Blkid cache file
cf9f5ab
au BufNewFile,BufRead /etc/blkid.tab,/etc/blkid.tab.old   setf xml
cf9f5ab
cf9f5ab
" C or lpc
cf9f5ab
au BufNewFile,BufRead *.c			call s:FTlpc()
cf9f5ab
cf9f5ab
func! s:FTlpc()
cf9f5ab
  if exists("g:lpc_syntax_for_c")
cf9f5ab
    let lnum = 1
cf9f5ab
    while lnum <= 12
cf9f5ab
      if getline(lnum) =~# '^\(//\|inherit\|private\|protected\|nosave\|string\|object\|mapping\|mixed\)'
cf9f5ab
	setf lpc
cf9f5ab
	return
cf9f5ab
      endif
cf9f5ab
      let lnum = lnum + 1
cf9f5ab
    endwhile
cf9f5ab
  endif
cf9f5ab
  setf c
cf9f5ab
endfunc
cf9f5ab
cf9f5ab
" Calendar
cf9f5ab
au BufNewFile,BufRead calendar			setf calendar
cf9f5ab
au BufNewFile,BufRead */.calendar/*,
cf9f5ab
	\*/share/calendar/*/calendar.*,*/share/calendar/calendar.*
cf9f5ab
	\					call s:StarSetf('calendar')
cf9f5ab
cf9f5ab
" C#
cf9f5ab
au BufNewFile,BufRead *.cs			setf cs
cf9f5ab
cf9f5ab
" Cdrdao TOC
cf9f5ab
au BufNewFile,BufRead *.toc			setf cdrtoc
cf9f5ab
cf9f5ab
" Cdrdao config
cf9f5ab
au BufNewFile,BufRead etc/cdrdao.conf,etc/defaults/cdrdao,etc/default/cdrdao,~/.cdrdao						setf cdrdaoconf
cf9f5ab
cf9f5ab
" Cfengine
cf9f5ab
au BufNewFile,BufRead cfengine.conf		setf cfengine
cf9f5ab
cf9f5ab
" Comshare Dimension Definition Language
cf9f5ab
au BufNewFile,BufRead *.cdl			setf cdl
cf9f5ab
cf9f5ab
" Conary Recipe
cf9f5ab
au BufNewFile,BufRead *.recipe			setf conaryrecipe
cf9f5ab
cf9f5ab
" Controllable Regex Mutilator
cf9f5ab
au BufNewFile,BufRead *.crm			setf crm
cf9f5ab
cf9f5ab
" Cyn++
cf9f5ab
au BufNewFile,BufRead *.cyn			setf cynpp
cf9f5ab
cf9f5ab
" Cynlib
cf9f5ab
" .cc and .cpp files can be C++ or Cynlib.
cf9f5ab
au BufNewFile,BufRead *.cc
cf9f5ab
	\ if exists("cynlib_syntax_for_cc")|setf cynlib|else|setf cpp|endif
cf9f5ab
au BufNewFile,BufRead *.cpp
cf9f5ab
	\ if exists("cynlib_syntax_for_cpp")|setf cynlib|else|setf cpp|endif
cf9f5ab
cf9f5ab
" C++
cf9f5ab
au BufNewFile,BufRead *.cxx,*.c++,*.hh,*.hxx,*.hpp,*.ipp,*.moc,*.tcc,*.inl setf cpp
cf9f5ab
if has("fname_case")
cf9f5ab
  au BufNewFile,BufRead *.C,*.H setf cpp
cf9f5ab
endif
cf9f5ab
cf9f5ab
" .h files can be C, Ch C++, ObjC or ObjC++.
cf9f5ab
" Set c_syntax_for_h if you want C, ch_syntax_for_h if you want Ch. ObjC is
cf9f5ab
" detected automatically.
cf9f5ab
au BufNewFile,BufRead *.h			call s:FTheader()
cf9f5ab
cf9f5ab
func! s:FTheader()
cf9f5ab
  if match(getline(1, min([line("$"), 200])), '^@\(interface\|end\|class\)') > -1
cf9f5ab
    setf objc
cf9f5ab
  elseif exists("g:c_syntax_for_h")
cf9f5ab
    setf c
cf9f5ab
  elseif exists("g:ch_syntax_for_h")
cf9f5ab
    setf ch
cf9f5ab
  else
cf9f5ab
    setf cpp
cf9f5ab
  endif
cf9f5ab
endfunc
cf9f5ab
cf9f5ab
" Ch (CHscript)
cf9f5ab
au BufNewFile,BufRead *.chf			setf ch
cf9f5ab
cf9f5ab
" TLH files are C++ headers generated by Visual C++'s #import from typelibs
cf9f5ab
au BufNewFile,BufRead *.tlh			setf cpp
cf9f5ab
cf9f5ab
" Cascading Style Sheets
cf9f5ab
au BufNewFile,BufRead *.css			setf css
cf9f5ab
cf9f5ab
" Century Term Command Scripts (*.cmd too)
cf9f5ab
au BufNewFile,BufRead *.con			setf cterm
cf9f5ab
cf9f5ab
" Changelog
cf9f5ab
au BufNewFile,BufRead changelog.Debian,changelog.dch,NEWS.Debian,NEWS.dch
cf9f5ab
					\	setf debchangelog
cf9f5ab
cf9f5ab
au BufNewFile,BufRead [cC]hange[lL]og
cf9f5ab
	\  if getline(1) =~ '; urgency='
cf9f5ab
	\|   setf debchangelog
cf9f5ab
	\| else
cf9f5ab
	\|   setf changelog
cf9f5ab
	\| endif
cf9f5ab
cf9f5ab
au BufNewFile,BufRead NEWS
cf9f5ab
	\  if getline(1) =~ '; urgency='
cf9f5ab
	\|   setf debchangelog
cf9f5ab
	\| endif
cf9f5ab
cf9f5ab
" CHILL
cf9f5ab
au BufNewFile,BufRead *..ch			setf chill
cf9f5ab
cf9f5ab
" Changes for WEB and CWEB or CHILL
cf9f5ab
au BufNewFile,BufRead *.ch			call s:FTchange()
cf9f5ab
cf9f5ab
" This function checks if one of the first ten lines start with a '@'.  In
cf9f5ab
" that case it is probably a change file.
cf9f5ab
" If the first line starts with # or ! it's probably a ch file.
cf9f5ab
" If a line has "main", "include", "//" ir "/*" it's probably ch.
cf9f5ab
" Otherwise CHILL is assumed.
cf9f5ab
func! s:FTchange()
cf9f5ab
  let lnum = 1
cf9f5ab
  while lnum <= 10
cf9f5ab
    if getline(lnum)[0] == '@'
cf9f5ab
      setf change
cf9f5ab
      return
cf9f5ab
    endif
cf9f5ab
    if lnum == 1 && (getline(1)[0] == '#' || getline(1)[0] == '!')
cf9f5ab
      setf ch
cf9f5ab
      return
cf9f5ab
    endif
cf9f5ab
    if getline(lnum) =~ "MODULE"
cf9f5ab
      setf chill
cf9f5ab
      return
cf9f5ab
    endif
cf9f5ab
    if getline(lnum) =~ 'main\s*(\|#\s*include\|//'
cf9f5ab
      setf ch
cf9f5ab
      return
cf9f5ab
    endif
cf9f5ab
    let lnum = lnum + 1
cf9f5ab
  endwhile
cf9f5ab
  setf chill
cf9f5ab
endfunc
cf9f5ab
cf9f5ab
" ChordPro
cf9f5ab
au BufNewFile,BufRead *.chopro,*.crd,*.cho,*.crdpro,*.chordpro	setf chordpro
cf9f5ab
cf9f5ab
" Clean
cf9f5ab
au BufNewFile,BufRead *.dcl,*.icl		setf clean
cf9f5ab
cf9f5ab
" Clever
cf9f5ab
au BufNewFile,BufRead *.eni			setf cl
cf9f5ab
cf9f5ab
" Clever or dtd
cf9f5ab
au BufNewFile,BufRead *.ent			call s:FTent()
cf9f5ab
cf9f5ab
func! s:FTent()
cf9f5ab
  " This function checks for valid cl syntax in the first five lines.
cf9f5ab
  " Look for either an opening comment, '#', or a block start, '{".
cf9f5ab
  " If not found, assume SGML.
cf9f5ab
  let lnum = 1
cf9f5ab
  while lnum < 6
cf9f5ab
    let line = getline(lnum)
cf9f5ab
    if line =~ '^\s*[#{]'
cf9f5ab
      setf cl
cf9f5ab
      return
cf9f5ab
    elseif line !~ '^\s*$'
cf9f5ab
      " Not a blank line, not a comment, and not a block start,
cf9f5ab
      " so doesn't look like valid cl code.
cf9f5ab
      break
cf9f5ab
    endif
cf9f5ab
    let lnum = lnum + 1
cf9f5ab
  endw
cf9f5ab
  setf dtd
cf9f5ab
endfunc
cf9f5ab
cf9f5ab
" Clipper (or FoxPro; could also be eviews)
cf9f5ab
au BufNewFile,BufRead *.prg
cf9f5ab
	\ if exists("g:filetype_prg") |
cf9f5ab
	\   exe "setf " . g:filetype_prg |
cf9f5ab
	\ else |
cf9f5ab
	\   setf clipper |
cf9f5ab
	\ endif
cf9f5ab
cf9f5ab
" Cmake
cf9f5ab
au BufNewFile,BufRead CMakeLists.txt,*.cmake,*.cmake.in		setf cmake
cf9f5ab
cf9f5ab
" Cmusrc
cf9f5ab
au BufNewFile,BufRead ~/.cmus/{autosave,rc,command-history,*.theme} setf cmusrc
cf9f5ab
au BufNewFile,BufRead */cmus/{rc,*.theme}			setf cmusrc
cf9f5ab
cf9f5ab
" Cobol
cf9f5ab
au BufNewFile,BufRead *.cbl,*.cob,*.lib	setf cobol
cf9f5ab
"   cobol or zope form controller python script? (heuristic)
cf9f5ab
au BufNewFile,BufRead *.cpy
cf9f5ab
	\ if getline(1) =~ '^##' |
cf9f5ab
	\   setf python |
cf9f5ab
	\ else |
cf9f5ab
	\   setf cobol |
cf9f5ab
	\ endif
cf9f5ab
cf9f5ab
" Coco/R
cf9f5ab
au BufNewFile,BufRead *.atg			setf coco
cf9f5ab
cf9f5ab
" Cold Fusion
cf9f5ab
au BufNewFile,BufRead *.cfm,*.cfi,*.cfc		setf cf
cf9f5ab
cf9f5ab
" Configure scripts
cf9f5ab
au BufNewFile,BufRead configure.in,configure.ac setf config
cf9f5ab
cf9f5ab
" CUDA  Cumpute Unified Device Architecture
cf9f5ab
au BufNewFile,BufRead *.cu			setf cuda
cf9f5ab
cf9f5ab
" WildPackets EtherPeek Decoder
cf9f5ab
au BufNewFile,BufRead *.dcd			setf dcd
cf9f5ab
cf9f5ab
" Enlightenment configuration files
cf9f5ab
au BufNewFile,BufRead *enlightenment/*.cfg	setf c
cf9f5ab
cf9f5ab
" Eterm
cf9f5ab
au BufNewFile,BufRead *Eterm/*.cfg		setf eterm
cf9f5ab
cf9f5ab
" Lynx config files
cf9f5ab
au BufNewFile,BufRead lynx.cfg			setf lynx
cf9f5ab
cf9f5ab
" Quake
cf9f5ab
au BufNewFile,BufRead *baseq[2-3]/*.cfg,*id1/*.cfg	setf quake
cf9f5ab
au BufNewFile,BufRead *quake[1-3]/*.cfg			setf quake
cf9f5ab
cf9f5ab
" Quake C
cf9f5ab
au BufNewFile,BufRead *.qc			setf c
cf9f5ab
cf9f5ab
" Configure files
cf9f5ab
au BufNewFile,BufRead *.cfg			setf cfg
cf9f5ab
cf9f5ab
" Communicating Sequential Processes
cf9f5ab
au BufNewFile,BufRead *.csp,*.fdr		setf csp
cf9f5ab
cf9f5ab
" CUPL logic description and simulation
cf9f5ab
au BufNewFile,BufRead *.pld			setf cupl
cf9f5ab
au BufNewFile,BufRead *.si			setf cuplsim
cf9f5ab
cf9f5ab
" Debian Control
cf9f5ab
au BufNewFile,BufRead */debian/control		setf debcontrol
cf9f5ab
au BufNewFile,BufRead control
cf9f5ab
	\  if getline(1) =~ '^Source:'
cf9f5ab
	\|   setf debcontrol
cf9f5ab
	\| endif
cf9f5ab
cf9f5ab
" Debian Sources.list
cf9f5ab
au BufNewFile,BufRead /etc/apt/sources.list	setf debsources
cf9f5ab
cf9f5ab
" Deny hosts
cf9f5ab
au BufNewFile,BufRead denyhosts.conf		setf denyhosts
cf9f5ab
cf9f5ab
" ROCKLinux package description
cf9f5ab
au BufNewFile,BufRead *.desc			setf desc
cf9f5ab
cf9f5ab
" the D language or dtrace
cf9f5ab
au BufNewFile,BufRead *.d			call s:DtraceCheck()
cf9f5ab
cf9f5ab
func! s:DtraceCheck()
cf9f5ab
  let lines = getline(1, min([line("$"), 100]))
cf9f5ab
  if match(lines, '^#!\S\+dtrace\|#pragma\s\+D\s\+option\|:\S\{-}:\S\{-}:') > -1
cf9f5ab
    setf dtrace
cf9f5ab
  else
cf9f5ab
    setf d
cf9f5ab
  endif
cf9f5ab
endfunc
cf9f5ab
cf9f5ab
" Desktop files
cf9f5ab
au BufNewFile,BufRead *.desktop,.directory	setf desktop
cf9f5ab
cf9f5ab
" Dict config
cf9f5ab
au BufNewFile,BufRead dict.conf,.dictrc		setf dictconf
cf9f5ab
cf9f5ab
" Dictd config
cf9f5ab
au BufNewFile,BufRead dictd.conf		setf dictdconf
cf9f5ab
cf9f5ab
" Diff files
cf9f5ab
au BufNewFile,BufRead *.diff,*.rej,*.patch	setf diff
cf9f5ab
cf9f5ab
" Dircolors
cf9f5ab
au BufNewFile,BufRead .dir_colors,/etc/DIR_COLORS	setf dircolors
cf9f5ab
cf9f5ab
" Diva (with Skill) or InstallShield
cf9f5ab
au BufNewFile,BufRead *.rul
cf9f5ab
	\ if getline(1).getline(2).getline(3).getline(4).getline(5).getline(6) =~? 'InstallShield' |
cf9f5ab
	\   setf ishd |
cf9f5ab
	\ else |
cf9f5ab
	\   setf diva |
cf9f5ab
	\ endif
cf9f5ab
cf9f5ab
" DCL (Digital Command Language - vms) or DNS zone file
cf9f5ab
au BufNewFile,BufRead *.com			call s:BindzoneCheck('dcl')
cf9f5ab
cf9f5ab
" DOT
cf9f5ab
au BufNewFile,BufRead *.dot			setf dot
cf9f5ab
cf9f5ab
" Dylan - lid files
cf9f5ab
au BufNewFile,BufRead *.lid			setf dylanlid
cf9f5ab
cf9f5ab
" Dylan - intr files (melange)
cf9f5ab
au BufNewFile,BufRead *.intr			setf dylanintr
cf9f5ab
cf9f5ab
" Dylan
cf9f5ab
au BufNewFile,BufRead *.dylan			setf dylan
cf9f5ab
cf9f5ab
" Microsoft Module Definition
cf9f5ab
au BufNewFile,BufRead *.def			setf def
cf9f5ab
cf9f5ab
" Dracula
cf9f5ab
au BufNewFile,BufRead *.drac,*.drc,*lvs,*lpe	setf dracula
cf9f5ab
cf9f5ab
" dsl
cf9f5ab
au BufNewFile,BufRead *.dsl			setf dsl
cf9f5ab
cf9f5ab
" DTD (Document Type Definition for XML)
cf9f5ab
au BufNewFile,BufRead *.dtd			setf dtd
cf9f5ab
cf9f5ab
" EDIF (*.edf,*.edif,*.edn,*.edo)
cf9f5ab
au BufNewFile,BufRead *.ed\(f\|if\|n\|o\)	setf edif
cf9f5ab
cf9f5ab
" Embedix Component Description
cf9f5ab
au BufNewFile,BufRead *.ecd			setf ecd
cf9f5ab
cf9f5ab
" Eiffel or Specman
cf9f5ab
au BufNewFile,BufRead *.e,*.E			call s:FTe()
cf9f5ab
cf9f5ab
" Elinks configuration
cf9f5ab
au BufNewFile,BufRead */etc/elinks.conf,*/.elinks/elinks.conf	setf elinks
cf9f5ab
cf9f5ab
func! s:FTe()
cf9f5ab
  let n = 1
cf9f5ab
  while n < 100 && n < line("$")
cf9f5ab
    if getline(n) =~ "^\\s*\\(<'\\|'>\\)\\s*$"
cf9f5ab
      setf specman
cf9f5ab
      return
cf9f5ab
    endif
cf9f5ab
    let n = n + 1
cf9f5ab
  endwhile
cf9f5ab
  setf eiffel
cf9f5ab
endfunc
cf9f5ab
cf9f5ab
" ERicsson LANGuage; Yaws is erlang too
cf9f5ab
au BufNewFile,BufRead *.erl,*.hrl,*.yaws	setf erlang
cf9f5ab
cf9f5ab
" Elm Filter Rules file
cf9f5ab
au BufNewFile,BufRead filter-rules		setf elmfilt
cf9f5ab
cf9f5ab
" ESMTP rc file
cf9f5ab
au BufNewFile,BufRead *esmtprc			setf esmtprc
cf9f5ab
cf9f5ab
" ESQL-C
cf9f5ab
au BufNewFile,BufRead *.ec,*.EC			setf esqlc
cf9f5ab
cf9f5ab
" Esterel
cf9f5ab
au BufNewFile,BufRead *.strl			setf esterel
cf9f5ab
cf9f5ab
" Essbase script
cf9f5ab
au BufNewFile,BufRead *.csc			setf csc
cf9f5ab
cf9f5ab
" Exim
cf9f5ab
au BufNewFile,BufRead exim.conf			setf exim
cf9f5ab
cf9f5ab
" Expect
cf9f5ab
au BufNewFile,BufRead *.exp			setf expect
cf9f5ab
cf9f5ab
" Exports
cf9f5ab
au BufNewFile,BufRead exports			setf exports
cf9f5ab
cf9f5ab
" Factor
cf9f5ab
au BufNewFile,BufRead *.factor			setf factor
cf9f5ab
cf9f5ab
" Fetchmail RC file
cf9f5ab
au BufNewFile,BufRead .fetchmailrc		setf fetchmail
cf9f5ab
cf9f5ab
" FlexWiki
cf9f5ab
au BufNewFile,BufRead *.wiki			setf flexwiki
cf9f5ab
cf9f5ab
" Focus Executable
cf9f5ab
au BufNewFile,BufRead *.fex,*.focexec		setf focexec
cf9f5ab
cf9f5ab
" Focus Master file (but not for auto.master)
cf9f5ab
au BufNewFile,BufRead auto.master		setf conf
cf9f5ab
au BufNewFile,BufRead *.mas,*.master		setf master
cf9f5ab
cf9f5ab
" Forth
cf9f5ab
au BufNewFile,BufRead *.fs,*.ft			setf forth
cf9f5ab
cf9f5ab
" Reva Forth
cf9f5ab
au BufNewFile,BufRead *.frt			setf reva
cf9f5ab
cf9f5ab
" Fortran
cf9f5ab
if has("fname_case")
cf9f5ab
  au BufNewFile,BufRead *.F,*.FOR,*.FPP,*.FTN,*.F77,*.F90,*.F95	 setf fortran
cf9f5ab
endif
cf9f5ab
au BufNewFile,BufRead   *.f,*.for,*.fortran,*.fpp,*.ftn,*.f77,*.f90,*.f95  setf fortran
cf9f5ab
cf9f5ab
" Framescript
cf9f5ab
au BufNewFile,BufRead *.fsl			setf framescript
cf9f5ab
cf9f5ab
" FStab
cf9f5ab
au BufNewFile,BufRead fstab,mtab		setf fstab
cf9f5ab
cf9f5ab
" GDB command files
cf9f5ab
au BufNewFile,BufRead .gdbinit			setf gdb
cf9f5ab
cf9f5ab
" GDMO
cf9f5ab
au BufNewFile,BufRead *.mo,*.gdmo		setf gdmo
cf9f5ab
cf9f5ab
" Gedcom
cf9f5ab
au BufNewFile,BufRead *.ged			setf gedcom
cf9f5ab
cf9f5ab
" Git
cf9f5ab
autocmd BufNewFile,BufRead *.git/COMMIT_EDITMSG    setf gitcommit
cf9f5ab
autocmd BufNewFile,BufRead *.git/config,.gitconfig setf gitconfig
cf9f5ab
autocmd BufNewFile,BufRead git-rebase-todo         setf gitrebase
cf9f5ab
autocmd BufNewFile,BufRead .msg.[0-9]*
cf9f5ab
      \ if getline(1) =~ '^From.*# This line is ignored.$' |
cf9f5ab
      \   setf gitsendemail |
cf9f5ab
      \ endif
cf9f5ab
autocmd BufNewFile,BufRead *.git/**
cf9f5ab
      \ if getline(1) =~ '^\x\{40\}\>\|^ref: ' |
cf9f5ab
      \   setf git |
cf9f5ab
      \ endif
cf9f5ab
cf9f5ab
" Gkrellmrc
cf9f5ab
au BufNewFile,BufRead gkrellmrc,gkrellmrc_?	setf gkrellmrc
cf9f5ab
cf9f5ab
" GP scripts (2.0 and onward)
cf9f5ab
au BufNewFile,BufRead *.gp,.gprc		setf gp
cf9f5ab
cf9f5ab
" GPG
cf9f5ab
au BufNewFile,BufRead */.gnupg/options		setf gpg
cf9f5ab
au BufNewFile,BufRead */.gnupg/gpg.conf		setf gpg
cf9f5ab
au BufNewFile,BufRead /usr/**/gnupg/options.skel setf gpg
cf9f5ab
cf9f5ab
" Gnuplot scripts
cf9f5ab
au BufNewFile,BufRead *.gpi			setf gnuplot
cf9f5ab
cf9f5ab
" GrADS scripts
cf9f5ab
au BufNewFile,BufRead *.gs			setf grads
cf9f5ab
cf9f5ab
" Gretl
cf9f5ab
au BufNewFile,BufRead *.gretl			setf gretl
cf9f5ab
cf9f5ab
" Groovy
cf9f5ab
au BufNewFile,BufRead *.groovy			setf groovy
cf9f5ab
cf9f5ab
" GNU Server Pages
cf9f5ab
au BufNewFile,BufRead *.gsp			setf gsp
cf9f5ab
cf9f5ab
" Group file
cf9f5ab
au BufNewFile,BufRead /etc/group,/etc/group-,/etc/group.edit,/etc/gshadow,/etc/gshadow-,/etc/gshadow.edit,/var/backups/group.bak,/var/backups/gshadow.bak  setf group
cf9f5ab
cf9f5ab
" GTK RC
cf9f5ab
au BufNewFile,BufRead .gtkrc,gtkrc		setf gtkrc
cf9f5ab
cf9f5ab
" Haml
cf9f5ab
au BufNewFile,BufRead *.haml			setf haml
cf9f5ab
cf9f5ab
" Hamster Classic | Playground files
cf9f5ab
au BufNewFile,BufRead *.hsc,*.hsm		setf hamster
cf9f5ab
cf9f5ab
" Haskell
cf9f5ab
au BufNewFile,BufRead *.hs			setf haskell
cf9f5ab
au BufNewFile,BufRead *.lhs			setf lhaskell
cf9f5ab
au BufNewFile,BufRead *.chs			setf chaskell
cf9f5ab
cf9f5ab
" Haste
cf9f5ab
au BufNewFile,BufRead *.ht			setf haste
cf9f5ab
au BufNewFile,BufRead *.htpp			setf hastepreproc
cf9f5ab
cf9f5ab
" Hercules
cf9f5ab
au BufNewFile,BufRead *.vc,*.ev,*.rs,*.sum,*.errsum	setf hercules
cf9f5ab
cf9f5ab
" HEX (Intel)
cf9f5ab
au BufNewFile,BufRead *.hex,*.h32		setf hex
cf9f5ab
cf9f5ab
" Tilde (must be before HTML)
cf9f5ab
au BufNewFile,BufRead *.t.html			setf tilde
cf9f5ab
cf9f5ab
" HTML (.shtml and .stm for server side)
cf9f5ab
au BufNewFile,BufRead *.html,*.htm,*.shtml,*.stm  call s:FThtml()
cf9f5ab
cf9f5ab
" Distinguish between HTML, XHTML and Django
cf9f5ab
func! s:FThtml()
cf9f5ab
  let n = 1
cf9f5ab
  while n < 10 && n < line("$")
cf9f5ab
    if getline(n) =~ '\
cf9f5ab
      setf xhtml
cf9f5ab
      return
cf9f5ab
    endif
cf9f5ab
    if getline(n) =~ '{%\s*\(extends\|block\)\>'
cf9f5ab
      setf htmldjango
cf9f5ab
      return
cf9f5ab
    endif
cf9f5ab
    let n = n + 1
cf9f5ab
  endwhile
cf9f5ab
  setf html
cf9f5ab
endfunc
cf9f5ab
cf9f5ab
" HTML with Ruby - eRuby
cf9f5ab
au BufNewFile,BufRead *.erb,*.rhtml		setf eruby
cf9f5ab
cf9f5ab
" HTML with M4
cf9f5ab
au BufNewFile,BufRead *.html.m4			setf htmlm4
cf9f5ab
cf9f5ab
" HTML Cheetah template
cf9f5ab
au BufNewFile,BufRead *.tmpl			setf htmlcheetah
cf9f5ab
cf9f5ab
" Host config
cf9f5ab
au BufNewFile,BufRead /etc/host.conf		setf hostconf
cf9f5ab
cf9f5ab
" Hosts access
cf9f5ab
au BufNewFile,BufRead /etc/hosts.allow,/etc/hosts.deny  setf hostsaccess
cf9f5ab
cf9f5ab
" Hyper Builder
cf9f5ab
au BufNewFile,BufRead *.hb			setf hb
cf9f5ab
cf9f5ab
" Icon
cf9f5ab
au BufNewFile,BufRead *.icn			setf icon
cf9f5ab
cf9f5ab
" IDL (Interface Description Language)
cf9f5ab
au BufNewFile,BufRead *.idl			call s:FTidl()
cf9f5ab
cf9f5ab
" Distinguish between standard IDL and MS-IDL
cf9f5ab
func! s:FTidl()
cf9f5ab
  let n = 1
cf9f5ab
  while n < 50 && n < line("$")
cf9f5ab
    if getline(n) =~ '^\s*import\s\+"\(unknwn\|objidl\)\.idl"'
cf9f5ab
      setf msidl
cf9f5ab
      return
cf9f5ab
    endif
cf9f5ab
    let n = n + 1
cf9f5ab
  endwhile
cf9f5ab
  setf idl
cf9f5ab
endfunc
cf9f5ab
cf9f5ab
" Microsoft IDL (Interface Description Language)  Also *.idl
cf9f5ab
" MOF = WMI (Windows Management Instrumentation) Managed Object Format
cf9f5ab
au BufNewFile,BufRead *.odl,*.mof		setf msidl
cf9f5ab
cf9f5ab
" Icewm menu
cf9f5ab
au BufNewFile,BufRead */.icewm/menu		setf icemenu
cf9f5ab
cf9f5ab
" Indent profile (must come before IDL *.pro!)
cf9f5ab
au BufNewFile,BufRead .indent.pro		setf indent
cf9f5ab
au BufNewFile,BufRead indent.pro		call s:ProtoCheck('indent')
cf9f5ab
cf9f5ab
" IDL (Interactive Data Language)
cf9f5ab
au BufNewFile,BufRead *.pro			call s:ProtoCheck('idlang')
cf9f5ab
cf9f5ab
" Distinguish between "default" and Cproto prototype file. */
cf9f5ab
func! s:ProtoCheck(default)
cf9f5ab
  " Cproto files have a comment in the first line and a function prototype in
cf9f5ab
  " the second line, it always ends in ";".  Indent files may also have
cf9f5ab
  " comments, thus we can't match comments to see the difference.
cf9f5ab
  if getline(2) =~ ';$'
cf9f5ab
    setf cpp
cf9f5ab
  else
cf9f5ab
    exe 'setf ' . a:default
cf9f5ab
  endif
cf9f5ab
endfunc
cf9f5ab
cf9f5ab
cf9f5ab
" Indent RC
cf9f5ab
au BufNewFile,BufRead indentrc			setf indent
cf9f5ab
cf9f5ab
" Inform
cf9f5ab
au BufNewFile,BufRead *.inf,*.INF		setf inform
cf9f5ab
cf9f5ab
" Initng
cf9f5ab
au BufNewFile,BufRead /etc/initng/**/*.i,*.ii	setf initng
cf9f5ab
cf9f5ab
" Ipfilter
cf9f5ab
au BufNewFile,BufRead ipf.conf,ipf6.conf,ipf.rules	setf ipfilter
cf9f5ab
cf9f5ab
" Informix 4GL (source - canonical, include file, I4GL+M4 preproc.)
cf9f5ab
au BufNewFile,BufRead *.4gl,*.4gh,*.m4gl	setf fgl
cf9f5ab
cf9f5ab
" .INI file for MSDOS
cf9f5ab
au BufNewFile,BufRead *.ini			setf dosini
cf9f5ab
cf9f5ab
" SysV Inittab
cf9f5ab
au BufNewFile,BufRead inittab			setf inittab
cf9f5ab
cf9f5ab
" Inno Setup
cf9f5ab
au BufNewFile,BufRead *.iss			setf iss
cf9f5ab
cf9f5ab
" JAL
cf9f5ab
au BufNewFile,BufRead *.jal,*.JAL		setf jal
cf9f5ab
cf9f5ab
" Jam
cf9f5ab
au BufNewFile,BufRead *.jpl,*.jpr		setf jam
cf9f5ab
cf9f5ab
" Java
cf9f5ab
au BufNewFile,BufRead *.java,*.jav		setf java
cf9f5ab
cf9f5ab
" JavaCC
cf9f5ab
au BufNewFile,BufRead *.jj,*.jjt		setf javacc
cf9f5ab
cf9f5ab
" JavaScript, ECMAScript
cf9f5ab
au BufNewFile,BufRead *.js,*.javascript,*.es	setf javascript
cf9f5ab
cf9f5ab
" Java Server Pages
cf9f5ab
au BufNewFile,BufRead *.jsp			setf jsp
cf9f5ab
cf9f5ab
" Java Properties resource file (note: doesn't catch font.properties.pl)
cf9f5ab
au BufNewFile,BufRead *.properties,*.properties_??,*.properties_??_??	setf jproperties
cf9f5ab
au BufNewFile,BufRead *.properties_??_??_*	call s:StarSetf('jproperties')
cf9f5ab
cf9f5ab
" Jess
cf9f5ab
au BufNewFile,BufRead *.clp			setf jess
cf9f5ab
cf9f5ab
" Jgraph
cf9f5ab
au BufNewFile,BufRead *.jgr			setf jgraph
cf9f5ab
cf9f5ab
" Kixtart
cf9f5ab
au BufNewFile,BufRead *.kix			setf kix
cf9f5ab
cf9f5ab
" Kimwitu[++]
cf9f5ab
au BufNewFile,BufRead *.k			setf kwt
cf9f5ab
cf9f5ab
" KDE script
cf9f5ab
au BufNewFile,BufRead *.ks			setf kscript
cf9f5ab
cf9f5ab
" Kconfig
cf9f5ab
au BufNewFile,BufRead Kconfig,Kconfig.debug	setf kconfig
cf9f5ab
cf9f5ab
" Lace (ISE)
cf9f5ab
au BufNewFile,BufRead *.ace,*.ACE		setf lace
cf9f5ab
cf9f5ab
" Latte
cf9f5ab
au BufNewFile,BufRead *.latte,*.lte		setf latte
cf9f5ab
cf9f5ab
" Limits
cf9f5ab
au BufNewFile,BufRead /etc/limits		setf limits
cf9f5ab
cf9f5ab
" LambdaProlog (*.mod too, see Modsim)
cf9f5ab
au BufNewFile,BufRead *.sig			setf lprolog
cf9f5ab
cf9f5ab
" LDAP LDIF
cf9f5ab
au BufNewFile,BufRead *.ldif			setf ldif
cf9f5ab
cf9f5ab
" Ld loader
cf9f5ab
au BufNewFile,BufRead *.ld			setf ld
cf9f5ab
cf9f5ab
" Lex
cf9f5ab
au BufNewFile,BufRead *.lex,*.l			setf lex
cf9f5ab
cf9f5ab
" Libao
cf9f5ab
au BufNewFile,BufRead /etc/libao.conf,*/.libao	setf libao
cf9f5ab
cf9f5ab
" Libsensors
cf9f5ab
au BufNewFile,BufRead /etc/sensors.conf		setf sensors
cf9f5ab
cf9f5ab
" LFTP
cf9f5ab
au BufNewFile,BufRead lftp.conf,.lftprc,*lftp/rc	setf lftp
cf9f5ab
cf9f5ab
" Lifelines (or Lex for C++!)
cf9f5ab
au BufNewFile,BufRead *.ll			setf lifelines
cf9f5ab
cf9f5ab
" Lilo: Linux loader
cf9f5ab
au BufNewFile,BufRead lilo.conf*		call s:StarSetf('lilo')
cf9f5ab
cf9f5ab
" Lisp (*.el = ELisp, *.cl = Common Lisp, *.jl = librep Lisp)
cf9f5ab
if has("fname_case")
cf9f5ab
  au BufNewFile,BufRead *.lsp,*.lisp,*.el,*.cl,*.jl,*.L,.emacs,.sawfishrc setf lisp
cf9f5ab
else
cf9f5ab
  au BufNewFile,BufRead *.lsp,*.lisp,*.el,*.cl,*.jl,.emacs,.sawfishrc setf lisp
cf9f5ab
endif
cf9f5ab
cf9f5ab
" SBCL implementation of Common Lisp
cf9f5ab
au BufNewFile,BufRead sbclrc,.sbclrc		setf lisp
cf9f5ab
cf9f5ab
" Lite
cf9f5ab
au BufNewFile,BufRead *.lite,*.lt		setf lite
cf9f5ab
cf9f5ab
" LiteStep RC files
cf9f5ab
au BufNewFile,BufRead */LiteStep/*/*.rc		setf litestep
cf9f5ab
cf9f5ab
" Login access
cf9f5ab
au BufNewFile,BufRead /etc/login.access		setf loginaccess
cf9f5ab
cf9f5ab
" Login defs
cf9f5ab
au BufNewFile,BufRead /etc/login.defs		setf logindefs
cf9f5ab
cf9f5ab
" Logtalk
cf9f5ab
au BufNewFile,BufRead *.lgt			setf logtalk
cf9f5ab
cf9f5ab
" LOTOS
cf9f5ab
au BufNewFile,BufRead *.lot,*.lotos		setf lotos
cf9f5ab
cf9f5ab
" Lout (also: *.lt)
cf9f5ab
au BufNewFile,BufRead *.lou,*.lout		setf lout
cf9f5ab
cf9f5ab
" Lua
cf9f5ab
au BufNewFile,BufRead *.lua			setf lua
cf9f5ab
cf9f5ab
" Linden Scripting Language (Second Life)
cf9f5ab
au BufNewFile,BufRead *.lsl			setf lsl
cf9f5ab
cf9f5ab
" Lynx style file (or LotusScript!)
cf9f5ab
au BufNewFile,BufRead *.lss			setf lss
cf9f5ab
cf9f5ab
" M4
cf9f5ab
au BufNewFile,BufRead *.m4
cf9f5ab
	\ if expand("<afile>") !~? 'html.m4$\|fvwm2rc' | setf m4 | endif
cf9f5ab
cf9f5ab
" MaGic Point
cf9f5ab
au BufNewFile,BufRead *.mgp			setf mgp
cf9f5ab
cf9f5ab
" Mail (for Elm, trn, mutt, muttng, rn, slrn)
cf9f5ab
au BufNewFile,BufRead snd.\d\+,.letter,.letter.\d\+,.followup,.article,.article.\d\+,pico.\d\+,mutt{ng,}-*-\w\+,mutt[[:alnum:]_-]\{6\},ae\d\+.txt,/tmp/SLRN[0-9A-Z.]\+,*.eml setf mail
cf9f5ab
cf9f5ab
" Mail aliases
cf9f5ab
au BufNewFile,BufRead /etc/mail/aliases,/etc/aliases	setf mailaliases
cf9f5ab
cf9f5ab
" Mailcap configuration file
cf9f5ab
au BufNewFile,BufRead .mailcap,mailcap		setf mailcap
cf9f5ab
cf9f5ab
" Makefile
cf9f5ab
au BufNewFile,BufRead *[mM]akefile,*.mk,*.mak,*.dsp setf make
cf9f5ab
cf9f5ab
" MakeIndex
cf9f5ab
au BufNewFile,BufRead *.ist,*.mst		setf ist
cf9f5ab
cf9f5ab
" Manpage
cf9f5ab
au BufNewFile,BufRead *.man			setf man
cf9f5ab
cf9f5ab
" Man config
cf9f5ab
au BufNewFile,BufRead /etc/man.conf,man.config	setf manconf
cf9f5ab
cf9f5ab
" Maple V
cf9f5ab
au BufNewFile,BufRead *.mv,*.mpl,*.mws		setf maple
cf9f5ab
cf9f5ab
" Map (UMN mapserver config file)
cf9f5ab
au BufNewFile,BufRead *.map			setf map
cf9f5ab
cf9f5ab
" Mason
cf9f5ab
au BufNewFile,BufRead *.mason,*.mhtml		setf mason
cf9f5ab
cf9f5ab
" Matlab or Objective C
cf9f5ab
au BufNewFile,BufRead *.m			call s:FTm()
cf9f5ab
cf9f5ab
func! s:FTm()
cf9f5ab
  let n = 1
cf9f5ab
  while n < 10
cf9f5ab
    let line = getline(n)
cf9f5ab
    if line =~ '^\s*\(#\s*\(include\|import\)\>\|/\*\)'
cf9f5ab
      setf objc
cf9f5ab
      return
cf9f5ab
    endif
cf9f5ab
    if line =~ '^\s*%'
cf9f5ab
      setf matlab
cf9f5ab
      return
cf9f5ab
    endif
cf9f5ab
    if line =~ '^\s*(\*'
cf9f5ab
      setf mma
cf9f5ab
      return
cf9f5ab
    endif
cf9f5ab
    let n = n + 1
cf9f5ab
  endwhile
cf9f5ab
  if exists("g:filetype_m")
cf9f5ab
    exe "setf " . g:filetype_m
cf9f5ab
  else
cf9f5ab
    setf matlab
cf9f5ab
  endif
cf9f5ab
endfunc
cf9f5ab
cf9f5ab
" Mathematica notebook
cf9f5ab
au BufNewFile,BufRead *.nb			setf mma
cf9f5ab
cf9f5ab
" Maya Extension Language
cf9f5ab
au BufNewFile,BufRead *.mel			setf mel
cf9f5ab
cf9f5ab
" Messages
cf9f5ab
au BufNewFile,BufRead /var/log/messages,/var/log/messages.*[0-9]  setf messages
cf9f5ab
cf9f5ab
" Metafont
cf9f5ab
au BufNewFile,BufRead *.mf			setf mf
cf9f5ab
cf9f5ab
" MetaPost
cf9f5ab
au BufNewFile,BufRead *.mp			setf mp
cf9f5ab
cf9f5ab
" MGL
cf9f5ab
au BufNewFile,BufRead *.mgl			setf mgl
cf9f5ab
cf9f5ab
" MMIX or VMS makefile
cf9f5ab
au BufNewFile,BufRead *.mms			call s:FTmms()
cf9f5ab
cf9f5ab
" Symbian meta-makefile definition (MMP)
cf9f5ab
au BufNewFile,BufRead *.mmp			setf mmp
cf9f5ab
cf9f5ab
func! s:FTmms()
cf9f5ab
  let n = 1
cf9f5ab
  while n < 10
cf9f5ab
    let line = getline(n)
cf9f5ab
    if line =~ '^\s*\(%\|//\)' || line =~ '^\*'
cf9f5ab
      setf mmix
cf9f5ab
      return
cf9f5ab
    endif
cf9f5ab
    if line =~ '^\s*#'
cf9f5ab
      setf make
cf9f5ab
      return
cf9f5ab
    endif
cf9f5ab
    let n = n + 1
cf9f5ab
  endwhile
cf9f5ab
  setf mmix
cf9f5ab
endfunc
cf9f5ab
cf9f5ab
cf9f5ab
" Modsim III (or LambdaProlog)
cf9f5ab
au BufNewFile,BufRead *.mod
cf9f5ab
	\ if getline(1) =~ '\<module\>' |
cf9f5ab
	\   setf lprolog |
cf9f5ab
	\ else |
cf9f5ab
	\   setf modsim3 |
cf9f5ab
	\ endif
cf9f5ab
cf9f5ab
" Modula 2
cf9f5ab
au BufNewFile,BufRead *.m2,*.DEF,*.MOD,*.md,*.mi setf modula2
cf9f5ab
cf9f5ab
" Modula 3 (.m3, .i3, .mg, .ig)
cf9f5ab
au BufNewFile,BufRead *.[mi][3g]		setf modula3
cf9f5ab
cf9f5ab
" Monk
cf9f5ab
au BufNewFile,BufRead *.isc,*.monk,*.ssc,*.tsc	setf monk
cf9f5ab
cf9f5ab
" MOO
cf9f5ab
au BufNewFile,BufRead *.moo			setf moo
cf9f5ab
cf9f5ab
" Modconf
cf9f5ab
au BufNewFile,BufRead /etc/modules.conf,/etc/conf.modules	setf modconf
cf9f5ab
au BufNewFile,BufRead /etc/modutils/*
cf9f5ab
	\ if executable(expand("<afile>")) != 1
cf9f5ab
	\|  call s:StarSetf('modconf')
cf9f5ab
	\|endif
cf9f5ab
cf9f5ab
" Mplayer config
cf9f5ab
au BufNewFile,BufRead mplayer.conf,*/.mplayer/config	setf mplayerconf
cf9f5ab
cf9f5ab
" Moterola S record
cf9f5ab
au BufNewFile,BufRead *.s19,*.s28,*.s37		setf srec
cf9f5ab
cf9f5ab
" Mrxvtrc
cf9f5ab
au BufNewFile,BufRead mrxvtrc,.mrxvtrc		setf mrxvtrc
cf9f5ab
cf9f5ab
" Msql
cf9f5ab
au BufNewFile,BufRead *.msql			setf msql
cf9f5ab
cf9f5ab
" Mysql
cf9f5ab
au BufNewFile,BufRead *.mysql			setf mysql
cf9f5ab
cf9f5ab
" M$ Resource files
cf9f5ab
au BufNewFile,BufRead *.rc			setf rc
cf9f5ab
cf9f5ab
" MuPAD source
cf9f5ab
au BufRead,BufNewFile *.mu			setf mupad
cf9f5ab
cf9f5ab
" Mush
cf9f5ab
au BufNewFile,BufRead *.mush			setf mush
cf9f5ab
cf9f5ab
" Mutt setup file (also for Muttng)
cf9f5ab
au BufNewFile,BufRead Mutt{ng,}rc		setf muttrc
cf9f5ab
cf9f5ab
" Nano
cf9f5ab
au BufNewFile,BufRead /etc/nanorc,.nanorc	setf nanorc
cf9f5ab
cf9f5ab
" Nastran input/DMAP
cf9f5ab
"au BufNewFile,BufRead *.dat			setf nastran
cf9f5ab
cf9f5ab
" Natural
cf9f5ab
au BufNewFile,BufRead *.NS[ACGLMNPS]		setf natural
cf9f5ab
cf9f5ab
" Netrc
cf9f5ab
au BufNewFile,BufRead .netrc			setf netrc
cf9f5ab
cf9f5ab
" Novell netware batch files
cf9f5ab
au BufNewFile,BufRead *.ncf			setf ncf
cf9f5ab
cf9f5ab
" Nroff/Troff (*.ms and *.t are checked below)
cf9f5ab
au BufNewFile,BufRead *.me
cf9f5ab
	\ if expand("<afile>") != "read.me" && expand("<afile>") != "click.me" |
cf9f5ab
	\   setf nroff |
cf9f5ab
	\ endif
cf9f5ab
au BufNewFile,BufRead *.tr,*.nr,*.roff,*.tmac,*.mom	setf nroff
cf9f5ab
au BufNewFile,BufRead *.[1-9]			call s:FTnroff()
cf9f5ab
cf9f5ab
" This function checks if one of the first five lines start with a dot.  In
cf9f5ab
" that case it is probably an nroff file: 'filetype' is set and 1 is returned.
cf9f5ab
func! s:FTnroff()
cf9f5ab
  if getline(1)[0] . getline(2)[0] . getline(3)[0] . getline(4)[0] . getline(5)[0] =~ '\.'
cf9f5ab
    setf nroff
cf9f5ab
    return 1
cf9f5ab
  endif
cf9f5ab
  return 0
cf9f5ab
endfunc
cf9f5ab
cf9f5ab
" Nroff or Objective C++
cf9f5ab
au BufNewFile,BufRead *.mm			call s:FTmm()
cf9f5ab
cf9f5ab
func! s:FTmm()
cf9f5ab
  let n = 1
cf9f5ab
  while n < 10
cf9f5ab
    let line = getline(n)
cf9f5ab
    if line =~ '^\s*\(#\s*\(include\|import\)\>\|/\*\)'
cf9f5ab
      setf objcpp
cf9f5ab
      return
cf9f5ab
    endif
cf9f5ab
    let n = n + 1
cf9f5ab
  endwhile
cf9f5ab
  setf nroff
cf9f5ab
endfunc
cf9f5ab
cf9f5ab
" Not Quite C
cf9f5ab
au BufNewFile,BufRead *.nqc			setf nqc
cf9f5ab
cf9f5ab
" NSIS
cf9f5ab
au BufNewFile,BufRead *.nsi			setf nsis
cf9f5ab
cf9f5ab
" OCAML
cf9f5ab
au BufNewFile,BufRead *.ml,*.mli,*.mll,*.mly	setf ocaml
cf9f5ab
cf9f5ab
" Occam
cf9f5ab
au BufNewFile,BufRead *.occ			setf occam
cf9f5ab
cf9f5ab
" Omnimark
cf9f5ab
au BufNewFile,BufRead *.xom,*.xin		setf omnimark
cf9f5ab
cf9f5ab
" OpenROAD
cf9f5ab
au BufNewFile,BufRead *.or			setf openroad
cf9f5ab
cf9f5ab
" OPL
cf9f5ab
au BufNewFile,BufRead *.[Oo][Pp][Ll]		setf opl
cf9f5ab
cf9f5ab
" Oracle config file
cf9f5ab
au BufNewFile,BufRead *.ora			setf ora
cf9f5ab
cf9f5ab
" Packet filter conf
cf9f5ab
au BufNewFile,BufRead pf.conf			setf pf
cf9f5ab
cf9f5ab
" Pam conf
cf9f5ab
au BufNewFile,BufRead /etc/pam.conf		setf pamconf
cf9f5ab
cf9f5ab
" PApp
cf9f5ab
au BufNewFile,BufRead *.papp,*.pxml,*.pxsl	setf papp
cf9f5ab
cf9f5ab
" Password file
cf9f5ab
au BufNewFile,BufRead /etc/passwd,/etc/passwd-,/etc/passwd.edit,/etc/shadow,/etc/shadow-,/var/backups/passwd.bak,/var/backups/shadow.bak setf passwd
cf9f5ab
cf9f5ab
" Pascal (also *.p)
cf9f5ab
au BufNewFile,BufRead *.pas			setf pascal
cf9f5ab
cf9f5ab
" Delphi project file
cf9f5ab
au BufNewFile,BufRead *.dpr			setf pascal
cf9f5ab
cf9f5ab
" PDF
cf9f5ab
au BufNewFile,BufRead *.pdf			setf pdf
cf9f5ab
cf9f5ab
" Perl
cf9f5ab
if has("fname_case")
cf9f5ab
  au BufNewFile,BufRead *.pl,*.PL		call s:FTpl()
cf9f5ab
else
cf9f5ab
  au BufNewFile,BufRead *.pl			call s:FTpl()
cf9f5ab
endif
cf9f5ab
au BufNewFile,BufRead *.plx,*.al		setf perl
cf9f5ab
cf9f5ab
func! s:FTpl()
cf9f5ab
  if exists("g:filetype_pl")
cf9f5ab
    exe "setf " . g:filetype_pl
cf9f5ab
  else
cf9f5ab
    " recognize Prolog by specific text in the first non-empty line
cf9f5ab
    " require a blank after the '%' because Perl uses "%list" and "%translate"
cf9f5ab
    let l = getline(nextnonblank(1))
cf9f5ab
    if l =~ '\<prolog\>' || l =~ '^\s*\(%\+\(\s\|$\)\|/\*\)' || l =~ ':-'
cf9f5ab
      setf prolog
cf9f5ab
    else
cf9f5ab
      setf perl
cf9f5ab
    endif
cf9f5ab
  endif
cf9f5ab
endfunc
cf9f5ab
cf9f5ab
" Perl, XPM or XPM2
cf9f5ab
au BufNewFile,BufRead *.pm
cf9f5ab
	\ if getline(1) =~ "XPM2" |
cf9f5ab
	\   setf xpm2 |
cf9f5ab
	\ elseif getline(1) =~ "XPM" |
cf9f5ab
	\   setf xpm |
cf9f5ab
	\ else |
cf9f5ab
	\   setf perl |
cf9f5ab
	\ endif
cf9f5ab
cf9f5ab
" Perl POD
cf9f5ab
au BufNewFile,BufRead *.pod			setf pod
cf9f5ab
cf9f5ab
" Php, php3, php4, etc.
cf9f5ab
" Also Phtml (was used for PHP 2 in the past)
cf9f5ab
" Also .ctp for Cake template file
cf9f5ab
au BufNewFile,BufRead *.php,*.php\d,*.phtml,*.ctp	setf php
cf9f5ab
cf9f5ab
" Pike
cf9f5ab
au BufNewFile,BufRead *.pike,*.lpc,*.ulpc,*.pmod setf pike
cf9f5ab
cf9f5ab
" Pinfo config
cf9f5ab
au BufNewFile,BufRead */etc/pinforc,*/.pinforc	setf pinfo
cf9f5ab
cf9f5ab
" Palm Resource compiler
cf9f5ab
au BufNewFile,BufRead *.rcp			setf pilrc
cf9f5ab
cf9f5ab
" Pine config
cf9f5ab
au BufNewFile,BufRead .pinerc,pinerc,.pinercex,pinercex		setf pine
cf9f5ab
cf9f5ab
" PL/M (also: *.inp)
cf9f5ab
au BufNewFile,BufRead *.plm,*.p36,*.pac		setf plm
cf9f5ab
cf9f5ab
" PL/SQL
cf9f5ab
au BufNewFile,BufRead *.pls,*.plsql		setf plsql
cf9f5ab
cf9f5ab
" PLP
cf9f5ab
au BufNewFile,BufRead *.plp			setf plp
cf9f5ab
cf9f5ab
" PO and PO template (GNU gettext)
cf9f5ab
au BufNewFile,BufRead *.po,*.pot		setf po
cf9f5ab
cf9f5ab
" Postfix main config
cf9f5ab
au BufNewFile,BufRead main.cf			setf pfmain
cf9f5ab
cf9f5ab
" PostScript (+ font files, encapsulated PostScript, Adobe Illustrator)
cf9f5ab
au BufNewFile,BufRead *.ps,*.pfa,*.afm,*.eps,*.epsf,*.epsi,*.ai	  setf postscr
cf9f5ab
cf9f5ab
" PostScript Printer Description
cf9f5ab
au BufNewFile,BufRead *.ppd			setf ppd
cf9f5ab
cf9f5ab
" Povray
cf9f5ab
au BufNewFile,BufRead *.pov			setf pov
cf9f5ab
cf9f5ab
" Povray configuration
cf9f5ab
au BufNewFile,BufRead .povrayrc			setf povini
cf9f5ab
cf9f5ab
" Povray, PHP or assembly
cf9f5ab
au BufNewFile,BufRead *.inc			call s:FTinc()
cf9f5ab
cf9f5ab
func! s:FTinc()
cf9f5ab
  if exists("g:filetype_inc")
cf9f5ab
    exe "setf " . g:filetype_inc
cf9f5ab
  else
cf9f5ab
    let lines = getline(1).getline(2).getline(3)
cf9f5ab
    if lines =~? "perlscript"
cf9f5ab
      setf aspperl
cf9f5ab
    elseif lines =~ "<%"
cf9f5ab
      setf aspvbs
cf9f5ab
    elseif lines =~ "
cf9f5ab
      setf php
cf9f5ab
    else
cf9f5ab
      call s:FTasmsyntax()
cf9f5ab
      if exists("b:asmsyntax")
cf9f5ab
	exe "setf " . fnameescape(b:asmsyntax)
cf9f5ab
      else
cf9f5ab
	setf pov
cf9f5ab
      endif
cf9f5ab
    endif
cf9f5ab
  endif
cf9f5ab
endfunc
cf9f5ab
cf9f5ab
" Printcap and Termcap
cf9f5ab
au BufNewFile,BufRead *printcap
cf9f5ab
	\ let b:ptcap_type = "print" | setf ptcap
cf9f5ab
au BufNewFile,BufRead *termcap
cf9f5ab
	\ let b:ptcap_type = "term" | setf ptcap
cf9f5ab
cf9f5ab
" PCCTS / ANTRL
cf9f5ab
"au BufNewFile,BufRead *.g			setf antrl
cf9f5ab
au BufNewFile,BufRead *.g			setf pccts
cf9f5ab
cf9f5ab
" PPWizard
cf9f5ab
au BufNewFile,BufRead *.it,*.ih			setf ppwiz
cf9f5ab
cf9f5ab
" Oracle Pro*C/C++
cf9f5ab
au BufNewFile,BufRead *.pc			setf proc
cf9f5ab
cf9f5ab
" Privoxy actions file
cf9f5ab
au BufNewFile,BufRead *.action			setf privoxy
cf9f5ab
cf9f5ab
" Procmail
cf9f5ab
au BufNewFile,BufRead .procmail,.procmailrc	setf procmail
cf9f5ab
cf9f5ab
" Progress or CWEB
cf9f5ab
au BufNewFile,BufRead *.w			call s:FTprogress_cweb()
cf9f5ab
cf9f5ab
func! s:FTprogress_cweb()
cf9f5ab
  if exists("g:filetype_w")
cf9f5ab
    exe "setf " . g:filetype_w
cf9f5ab
    return
cf9f5ab
  endif
cf9f5ab
  if getline(1) =~ '&ANALYZE' || getline(3) =~ '&GLOBAL-DEFINE'
cf9f5ab
    setf progress
cf9f5ab
  else
cf9f5ab
    setf cweb
cf9f5ab
  endif
cf9f5ab
endfunc
cf9f5ab
cf9f5ab
" Progress or assembly
cf9f5ab
au BufNewFile,BufRead *.i			call s:FTprogress_asm()
cf9f5ab
cf9f5ab
func! s:FTprogress_asm()
cf9f5ab
  if exists("g:filetype_i")
cf9f5ab
    exe "setf " . g:filetype_i
cf9f5ab
    return
cf9f5ab
  endif
cf9f5ab
  " This function checks for an assembly comment the first ten lines.
cf9f5ab
  " If not found, assume Progress.
cf9f5ab
  let lnum = 1
cf9f5ab
  while lnum <= 10 && lnum < line('$')
cf9f5ab
    let line = getline(lnum)
cf9f5ab
    if line =~ '^\s*;' || line =~ '^\*'
cf9f5ab
      call s:FTasm()
cf9f5ab
      return
cf9f5ab
    elseif line !~ '^\s*$' || line =~ '^/\*'
cf9f5ab
      " Not an empty line: Doesn't look like valid assembly code.
cf9f5ab
      " Or it looks like a Progress /* comment
cf9f5ab
      break
cf9f5ab
    endif
cf9f5ab
    let lnum = lnum + 1
cf9f5ab
  endw
cf9f5ab
  setf progress
cf9f5ab
endfunc
cf9f5ab
cf9f5ab
" Progress or Pascal
cf9f5ab
au BufNewFile,BufRead *.p			call s:FTprogress_pascal()
cf9f5ab
cf9f5ab
func! s:FTprogress_pascal()
cf9f5ab
  if exists("g:filetype_p")
cf9f5ab
    exe "setf " . g:filetype_p
cf9f5ab
    return
cf9f5ab
  endif
cf9f5ab
  " This function checks for valid Pascal syntax in the first ten lines.
cf9f5ab
  " Look for either an opening comment or a program start.
cf9f5ab
  " If not found, assume Progress.
cf9f5ab
  let lnum = 1
cf9f5ab
  while lnum <= 10 && lnum < line('$')
cf9f5ab
    let line = getline(lnum)
cf9f5ab
    if line =~ '^\s*\(program\|unit\|procedure\|function\|const\|type\|var\)\>'
cf9f5ab
	\ || line =~ '^\s*{' || line =~ '^\s*(\*'
cf9f5ab
      setf pascal
cf9f5ab
      return
cf9f5ab
    elseif line !~ '^\s*$' || line =~ '^/\*'
cf9f5ab
      " Not an empty line: Doesn't look like valid Pascal code.
cf9f5ab
      " Or it looks like a Progress /* comment
cf9f5ab
      break
cf9f5ab
    endif
cf9f5ab
    let lnum = lnum + 1
cf9f5ab
  endw
cf9f5ab
  setf progress
cf9f5ab
endfunc
cf9f5ab
cf9f5ab
cf9f5ab
" Software Distributor Product Specification File (POSIX 1387.2-1995)
cf9f5ab
au BufNewFile,BufRead *.psf			setf psf
cf9f5ab
au BufNewFile,BufRead INDEX,INFO
cf9f5ab
	\ if getline(1) =~ '^\s*\(distribution\|installed_software\|root\|bundle\|product\)\s*$' |
cf9f5ab
	\   setf psf |
cf9f5ab
	\ endif
cf9f5ab
cf9f5ab
" Prolog
cf9f5ab
au BufNewFile,BufRead *.pdb			setf prolog
cf9f5ab
cf9f5ab
" Promela
cf9f5ab
au BufNewFile,BufRead *.pml			setf promela
cf9f5ab
cf9f5ab
" Protocols
cf9f5ab
au BufNewFile,BufRead /etc/protocols		setf protocols
cf9f5ab
cf9f5ab
" Pyrex
cf9f5ab
au BufNewFile,BufRead *.pyx,*.pxd		setf pyrex
cf9f5ab
cf9f5ab
" Python
cf9f5ab
au BufNewFile,BufRead *.py,*.pyw		setf python
cf9f5ab
cf9f5ab
" Quixote (Python-based web framework)
cf9f5ab
au BufNewFile,BufRead *.ptl			setf python
cf9f5ab
cf9f5ab
" Radiance
cf9f5ab
au BufNewFile,BufRead *.rad,*.mat		setf radiance
cf9f5ab
cf9f5ab
" Ratpoison config/command files
cf9f5ab
au BufNewFile,BufRead .ratpoisonrc,ratpoisonrc	setf ratpoison
cf9f5ab
cf9f5ab
" RCS file
cf9f5ab
au BufNewFile,BufRead *\,v			setf rcs
cf9f5ab
cf9f5ab
" Readline
cf9f5ab
au BufNewFile,BufRead .inputrc,inputrc		setf readline
cf9f5ab
cf9f5ab
" Registry for MS-Windows
cf9f5ab
au BufNewFile,BufRead *.reg
cf9f5ab
	\ if getline(1) =~? '^REGEDIT[0-9]*\s*$\|^Windows Registry Editor Version \d*\.\d*\s*$' | setf registry | endif
cf9f5ab
cf9f5ab
" Renderman Interface Bytestream
cf9f5ab
au BufNewFile,BufRead *.rib			setf rib
cf9f5ab
cf9f5ab
" Rexx
cf9f5ab
au BufNewFile,BufRead *.rexx,*.rex,*.jrexx,*.rxj,*.orx	setf rexx
cf9f5ab
cf9f5ab
" R (Splus)
cf9f5ab
if has("fname_case")
cf9f5ab
  au BufNewFile,BufRead *.s,*.S			setf r
cf9f5ab
else
cf9f5ab
  au BufNewFile,BufRead *.s			setf r
cf9f5ab
endif
cf9f5ab
cf9f5ab
" R Help file
cf9f5ab
if has("fname_case")
cf9f5ab
  au BufNewFile,BufRead *.rd,*.Rd		setf rhelp
cf9f5ab
else
cf9f5ab
  au BufNewFile,BufRead *.rd			setf rhelp
cf9f5ab
endif
cf9f5ab
cf9f5ab
" R noweb file
cf9f5ab
if has("fname_case")
cf9f5ab
  au BufNewFile,BufRead *.Rnw,*.rnw,*.Snw,*.snw		setf rnoweb
cf9f5ab
else
cf9f5ab
  au BufNewFile,BufRead *.rnw,*.snw			setf rnoweb
cf9f5ab
endif
cf9f5ab
cf9f5ab
" Rexx, Rebol or R
cf9f5ab
au BufNewFile,BufRead *.r,*.R			call s:FTr()
cf9f5ab
cf9f5ab
func! s:FTr()
cf9f5ab
  let max = line("$") > 50 ? 50 : line("$")
cf9f5ab
cf9f5ab
  for n in range(1, max)
cf9f5ab
    " Rebol is easy to recognize, check for that first
cf9f5ab
    if getline(n) =~? '\<REBOL\>'
cf9f5ab
      setf rebol
cf9f5ab
      return
cf9f5ab
    endif
cf9f5ab
  endfor
cf9f5ab
cf9f5ab
  for n in range(1, max)
cf9f5ab
    " R has # comments
cf9f5ab
    if getline(n) =~ '^\s*#'
cf9f5ab
      setf r
cf9f5ab
      return
cf9f5ab
    endif
cf9f5ab
    " Rexx has /* comments */
cf9f5ab
    if getline(n) =~ '^\s*/\*'
cf9f5ab
      setf rexx
cf9f5ab
      return
cf9f5ab
    endif
cf9f5ab
  endfor
cf9f5ab
cf9f5ab
  " Nothing recognized, assume Rexx
cf9f5ab
  setf rexx
cf9f5ab
endfunc
cf9f5ab
cf9f5ab
" Remind
cf9f5ab
au BufNewFile,BufRead .reminders*		call s:StarSetf('remind')
cf9f5ab
cf9f5ab
" Resolv.conf
cf9f5ab
au BufNewFile,BufRead resolv.conf		setf resolv
cf9f5ab
cf9f5ab
" Relax NG Compact
cf9f5ab
au BufNewFile,BufRead *.rnc			setf rnc
cf9f5ab
cf9f5ab
" RPL/2
cf9f5ab
au BufNewFile,BufRead *.rpl			setf rpl
cf9f5ab
cf9f5ab
" Robots.txt
cf9f5ab
au BufNewFile,BufRead robots.txt		setf robots
cf9f5ab
cf9f5ab
" Rpcgen
cf9f5ab
au BufNewFile,BufRead *.x			setf rpcgen
cf9f5ab
cf9f5ab
" reStructuredText Documentation Format
cf9f5ab
au BufNewFile,BufRead *.rst			setf rst
cf9f5ab
cf9f5ab
" RTF
cf9f5ab
au BufNewFile,BufRead *.rtf			setf rtf
cf9f5ab
cf9f5ab
" Interactive Ruby shell
cf9f5ab
au BufNewFile,BufRead .irbrc,irbrc		setf ruby
cf9f5ab
cf9f5ab
" Ruby
cf9f5ab
au BufNewFile,BufRead *.rb,*.rbw,*.gem,*.gemspec	setf ruby
cf9f5ab
cf9f5ab
" Ruby on Rails
cf9f5ab
au BufNewFile,BufRead *.builder,*.rxml,*.rjs	setf ruby
cf9f5ab
cf9f5ab
" Rantfile and Rakefile is like Ruby
cf9f5ab
au BufNewFile,BufRead [rR]antfile,*.rant,[rR]akefile,*.rake	setf ruby
cf9f5ab
cf9f5ab
" S-lang (or shader language!)
cf9f5ab
au BufNewFile,BufRead *.sl			setf slang
cf9f5ab
cf9f5ab
" Samba config
cf9f5ab
au BufNewFile,BufRead smb.conf			setf samba
cf9f5ab
cf9f5ab
" SAS script
cf9f5ab
au BufNewFile,BufRead *.sas			setf sas
cf9f5ab
cf9f5ab
" Sass
cf9f5ab
au BufNewFile,BufRead *.sass			setf sass
cf9f5ab
cf9f5ab
" Sather
cf9f5ab
au BufNewFile,BufRead *.sa			setf sather
cf9f5ab
cf9f5ab
" Scilab
cf9f5ab
au BufNewFile,BufRead *.sci,*.sce		setf scilab
cf9f5ab
cf9f5ab
" SD: Streaming Descriptors
cf9f5ab
au BufNewFile,BufRead *.sd			setf sd
cf9f5ab
cf9f5ab
" SDL
cf9f5ab
au BufNewFile,BufRead *.sdl,*.pr		setf sdl
cf9f5ab
cf9f5ab
" sed
cf9f5ab
au BufNewFile,BufRead *.sed			setf sed
cf9f5ab
cf9f5ab
" Sieve (RFC 3028)
cf9f5ab
au BufNewFile,BufRead *.siv			setf sieve
cf9f5ab
cf9f5ab
" Sendmail
cf9f5ab
au BufNewFile,BufRead sendmail.cf		setf sm
cf9f5ab
cf9f5ab
" Sendmail .mc files are actually m4.  Could also be MS Message text file.
cf9f5ab
au BufNewFile,BufRead *.mc			call s:McSetf()
cf9f5ab
cf9f5ab
func! s:McSetf()
cf9f5ab
  " Rely on the file to start with a comment.
cf9f5ab
  " MS message text files use ';', Sendmail files use '#' or 'dnl'
cf9f5ab
  for lnum in range(1, min([line("$"), 20]))
cf9f5ab
    let line = getline(lnum)
cf9f5ab
    if line =~ '^\s*\(#\|dnl\)'
cf9f5ab
      setf m4  " Sendmail .mc file
cf9f5ab
      return
cf9f5ab
    elseif line =~ '^\s*;'
cf9f5ab
      setf msmessages  " MS Message text file
cf9f5ab
      return
cf9f5ab
    endif
cf9f5ab
  endfor
cf9f5ab
  setf m4  " Default: Sendmail .mc file
cf9f5ab
endfunc
cf9f5ab
cf9f5ab
" Services
cf9f5ab
au BufNewFile,BufRead /etc/services		setf services
cf9f5ab
cf9f5ab
" Service Location config
cf9f5ab
au BufNewFile,BufRead /etc/slp.conf		setf slpconf
cf9f5ab
cf9f5ab
" Service Location registration
cf9f5ab
au BufNewFile,BufRead /etc/slp.reg		setf slpreg
cf9f5ab
cf9f5ab
" Service Location SPI
cf9f5ab
au BufNewFile,BufRead /etc/slp.spi		setf slpspi
cf9f5ab
cf9f5ab
" Setserial config
cf9f5ab
au BufNewFile,BufRead /etc/serial.conf		setf setserial
cf9f5ab
cf9f5ab
" SGML
cf9f5ab
au BufNewFile,BufRead *.sgm,*.sgml
cf9f5ab
	\ if getline(1).getline(2).getline(3).getline(4).getline(5) =~? 'linuxdoc' |
cf9f5ab
	\   setf sgmllnx |
cf9f5ab
	\ elseif getline(1) =~ '
cf9f5ab
	\   let b:docbk_type="sgml" |
cf9f5ab
	\   setf docbk |
cf9f5ab
	\ else |
cf9f5ab
	\   setf sgml |
cf9f5ab
	\ endif
cf9f5ab
cf9f5ab
" SGMLDECL
cf9f5ab
au BufNewFile,BufRead *.decl,*.dcl,*.dec
cf9f5ab
	\ if getline(1).getline(2).getline(3) =~? '^
cf9f5ab
	\    setf sgmldecl |
cf9f5ab
	\ endif
cf9f5ab
cf9f5ab
" SGML catalog file
cf9f5ab
au BufNewFile,BufRead catalog			setf catalog
cf9f5ab
au BufNewFile,BufRead sgml.catalog*		call s:StarSetf('catalog')
cf9f5ab
cf9f5ab
" Shell scripts (sh, ksh, bash, bash2, csh); Allow .profile_foo etc.
cf9f5ab
" Gentoo ebuilds are actually bash scripts
cf9f5ab
au BufNewFile,BufRead .bashrc*,bashrc,bash.bashrc,.bash_profile*,.bash_logout*,*.bash,*.ebuild call SetFileTypeSH("bash")
cf9f5ab
au BufNewFile,BufRead .kshrc*,*.ksh call SetFileTypeSH("ksh")
cf9f5ab
au BufNewFile,BufRead /etc/profile,.profile*,*.sh,*.env call SetFileTypeSH(getline(1))
cf9f5ab
cf9f5ab
" Also called from scripts.vim.
cf9f5ab
func! SetFileTypeSH(name)
cf9f5ab
  if expand("<amatch>") =~ g:ft_ignore_pat
cf9f5ab
    return
cf9f5ab
  endif
cf9f5ab
  if a:name =~ '\<ksh\>'
cf9f5ab
    let b:is_kornshell = 1
cf9f5ab
    if exists("b:is_bash")
cf9f5ab
      unlet b:is_bash
cf9f5ab
    endif
cf9f5ab
    if exists("b:is_sh")
cf9f5ab
      unlet b:is_sh
cf9f5ab
    endif
cf9f5ab
  elseif exists("g:bash_is_sh") || a:name =~ '\<bash\>' || a:name =~ '\<bash2\>'
cf9f5ab
    let b:is_bash = 1
cf9f5ab
    if exists("b:is_kornshell")
cf9f5ab
      unlet b:is_kornshell
cf9f5ab
    endif
cf9f5ab
    if exists("b:is_sh")
cf9f5ab
      unlet b:is_sh
cf9f5ab
    endif
cf9f5ab
  elseif a:name =~ '\<sh\>'
cf9f5ab
    let b:is_sh = 1
cf9f5ab
    if exists("b:is_kornshell")
cf9f5ab
      unlet b:is_kornshell
cf9f5ab
    endif
cf9f5ab
    if exists("b:is_bash")
cf9f5ab
      unlet b:is_bash
cf9f5ab
    endif
cf9f5ab
  endif
cf9f5ab
  call SetFileTypeShell("sh")
cf9f5ab
endfunc
cf9f5ab
cf9f5ab
" For shell-like file types, check for an "exec" command hidden in a comment,
cf9f5ab
" as used for Tcl.
cf9f5ab
" Also called from scripts.vim, thus can't be local to this script.
cf9f5ab
func! SetFileTypeShell(name)
cf9f5ab
  if expand("<amatch>") =~ g:ft_ignore_pat
cf9f5ab
    return
cf9f5ab
  endif
cf9f5ab
  let l = 2
cf9f5ab
  while l < 20 && l < line("$") && getline(l) =~ '^\s*\(#\|$\)'
cf9f5ab
    " Skip empty and comment lines.
cf9f5ab
    let l = l + 1
cf9f5ab
  endwhile
cf9f5ab
  if l < line("$") && getline(l) =~ '\s*exec\s' && getline(l - 1) =~ '^\s*#.*\\$'
cf9f5ab
    " Found an "exec" line after a comment with continuation
cf9f5ab
    let n = substitute(getline(l),'\s*exec\s\+\([^ ]*/\)\=', '', '')
cf9f5ab
    if n =~ '\
cf9f5ab
      setf tcl
cf9f5ab
      return
cf9f5ab
    endif
cf9f5ab
  endif
cf9f5ab
  exe "setf " . a:name
cf9f5ab
endfunc
cf9f5ab
cf9f5ab
" tcsh scripts
cf9f5ab
au BufNewFile,BufRead .tcshrc*,*.tcsh,tcsh.tcshrc,tcsh.login	call SetFileTypeShell("tcsh")
cf9f5ab
cf9f5ab
" csh scripts, but might also be tcsh scripts (on some systems csh is tcsh)
cf9f5ab
au BufNewFile,BufRead .login*,.cshrc*,csh.cshrc,csh.login,csh.logout,*.csh,.alias  call s:CSH()
cf9f5ab
cf9f5ab
func! s:CSH()
cf9f5ab
  if exists("g:filetype_csh")
cf9f5ab
    call SetFileTypeShell(g:filetype_csh)
cf9f5ab
  elseif &shell =~ "tcsh"
cf9f5ab
    call SetFileTypeShell("tcsh")
cf9f5ab
  else
cf9f5ab
    call SetFileTypeShell("csh")
cf9f5ab
  endif
cf9f5ab
endfunc
cf9f5ab
cf9f5ab
" Z-Shell script
cf9f5ab
au BufNewFile,BufRead .zprofile,/etc/zprofile,.zfbfmarks  setf zsh
cf9f5ab
au BufNewFile,BufRead .zsh*,.zlog*,.zcompdump*  call s:StarSetf('zsh')
cf9f5ab
au BufNewFile,BufRead *.zsh 			setf zsh
cf9f5ab
cf9f5ab
" Scheme
cf9f5ab
au BufNewFile,BufRead *.scm,*.ss		setf scheme
cf9f5ab
cf9f5ab
" Screen RC
cf9f5ab
au BufNewFile,BufRead .screenrc,screenrc	setf screen
cf9f5ab
cf9f5ab
" Simula
cf9f5ab
au BufNewFile,BufRead *.sim			setf simula
cf9f5ab
cf9f5ab
" SINDA
cf9f5ab
au BufNewFile,BufRead *.sin,*.s85		setf sinda
cf9f5ab
cf9f5ab
" SiSU
cf9f5ab
au BufNewFile,BufRead *.sst,*.ssm,*.ssi,*.-sst,*._sst setf sisu
cf9f5ab
au BufNewFile,BufRead *.sst.meta,*.-sst.meta,*._sst.meta setf sisu
cf9f5ab
cf9f5ab
" SKILL
cf9f5ab
au BufNewFile,BufRead *.il,*.ils,*.cdf		setf skill
cf9f5ab
cf9f5ab
" SLRN
cf9f5ab
au BufNewFile,BufRead .slrnrc			setf slrnrc
cf9f5ab
au BufNewFile,BufRead *.score			setf slrnsc
cf9f5ab
cf9f5ab
" Smalltalk (and TeX)
cf9f5ab
au BufNewFile,BufRead *.st			setf st
cf9f5ab
au BufNewFile,BufRead *.cls
cf9f5ab
	\ if getline(1) =~ '^%' |
cf9f5ab
	\  setf tex |
cf9f5ab
	\ else |
cf9f5ab
	\  setf st |
cf9f5ab
	\ endif
cf9f5ab
cf9f5ab
" Smarty templates
cf9f5ab
au BufNewFile,BufRead *.tpl			setf smarty
cf9f5ab
cf9f5ab
" SMIL or XML
cf9f5ab
au BufNewFile,BufRead *.smil
cf9f5ab
	\ if getline(1) =~ '' |
cf9f5ab
	\   setf xml |
cf9f5ab
	\ else |
cf9f5ab
	\   setf smil |
cf9f5ab
	\ endif
cf9f5ab
cf9f5ab
" SMIL or SNMP MIB file
cf9f5ab
au BufNewFile,BufRead *.smi
cf9f5ab
	\ if getline(1) =~ '\<smil\>' |
cf9f5ab
	\   setf smil |
cf9f5ab
	\ else |
cf9f5ab
	\   setf mib |
cf9f5ab
	\ endif
cf9f5ab
cf9f5ab
" SMITH
cf9f5ab
au BufNewFile,BufRead *.smt,*.smith		setf smith
cf9f5ab
cf9f5ab
" Snobol4 and spitbol
cf9f5ab
au BufNewFile,BufRead *.sno,*.spt		setf snobol4
cf9f5ab
cf9f5ab
" SNMP MIB files
cf9f5ab
au BufNewFile,BufRead *.mib,*.my		setf mib
cf9f5ab
cf9f5ab
" Snort Configuration
cf9f5ab
au BufNewFile,BufRead *.hog,snort.conf,vision.conf	setf hog
cf9f5ab
au BufNewFile,BufRead *.rules			call s:FTRules()
cf9f5ab
cf9f5ab
let s:ft_rules_udev_rules_pattern = '^\s*\cudev_rules\s*=\s*"\([^"]\{-1,}\)/*".*'
cf9f5ab
func! s:FTRules()
cf9f5ab
  if expand('<amatch>:p') =~ '^/etc/udev/\%(rules\.d/\)\=.*\.rules$'
cf9f5ab
    setf udevrules
cf9f5ab
    return
cf9f5ab
  endif
cf9f5ab
  try
cf9f5ab
    let config_lines = readfile('/etc/udev/udev.conf')
cf9f5ab
  catch /^Vim\%((\a\+)\)\=:E484/
cf9f5ab
    setf hog
cf9f5ab
    return
cf9f5ab
  endtry
cf9f5ab
  let dir = expand('<amatch>:p:h')
cf9f5ab
  for line in config_lines
cf9f5ab
    if line =~ s:ft_rules_udev_rules_pattern
cf9f5ab
      let udev_rules = substitute(line, s:ft_rules_udev_rules_pattern, '\1', "")
cf9f5ab
      if dir == udev_rules
cf9f5ab
        setf udevrules
cf9f5ab
      endif
cf9f5ab
      break
cf9f5ab
    endif
cf9f5ab
  endfor
cf9f5ab
  setf hog
cf9f5ab
endfunc
cf9f5ab
cf9f5ab
cf9f5ab
" Spec (Linux RPM)
cf9f5ab
au BufNewFile,BufRead *.spec			setf spec
cf9f5ab
cf9f5ab
" Speedup (AspenTech plant simulator)
cf9f5ab
au BufNewFile,BufRead *.speedup,*.spdata,*.spd	setf spup
cf9f5ab
cf9f5ab
" Slice
cf9f5ab
au BufNewFile,BufRead *.ice			setf slice
cf9f5ab
cf9f5ab
" Spice
cf9f5ab
au BufNewFile,BufRead *.sp,*.spice		setf spice
cf9f5ab
cf9f5ab
" Spyce
cf9f5ab
au BufNewFile,BufRead *.spy,*.spi		setf spyce
cf9f5ab
cf9f5ab
" Squid
cf9f5ab
au BufNewFile,BufRead squid.conf		setf squid
cf9f5ab
cf9f5ab
" SQL for Oracle Designer
cf9f5ab
au BufNewFile,BufRead *.tyb,*.typ,*.tyc,*.pkb,*.pks	setf sql
cf9f5ab
cf9f5ab
" SQL
cf9f5ab
au BufNewFile,BufRead *.sql			call s:SQL()
cf9f5ab
cf9f5ab
func! s:SQL()
cf9f5ab
  if exists("g:filetype_sql")
cf9f5ab
    exe "setf " . g:filetype_sql
cf9f5ab
  else
cf9f5ab
    setf sql
cf9f5ab
  endif
cf9f5ab
endfunc
cf9f5ab
cf9f5ab
" SQLJ
cf9f5ab
au BufNewFile,BufRead *.sqlj			setf sqlj
cf9f5ab
cf9f5ab
" SQR
cf9f5ab
au BufNewFile,BufRead *.sqr,*.sqi		setf sqr
cf9f5ab
cf9f5ab
" OpenSSH configuration
cf9f5ab
au BufNewFile,BufRead ssh_config,*/.ssh/config	setf sshconfig
cf9f5ab
cf9f5ab
" OpenSSH server configuration
cf9f5ab
au BufNewFile,BufRead sshd_config		setf sshdconfig
cf9f5ab
cf9f5ab
" Stata
cf9f5ab
au BufNewFile,BufRead *.ado,*.class,*.do,*.imata,*.mata   setf stata
cf9f5ab
cf9f5ab
" SMCL
cf9f5ab
au BufNewFile,BufRead *.hlp,*.ihlp,*.smcl	setf smcl
cf9f5ab
cf9f5ab
" Stored Procedures
cf9f5ab
au BufNewFile,BufRead *.stp			setf stp
cf9f5ab
cf9f5ab
" Standard ML
cf9f5ab
au BufNewFile,BufRead *.sml			setf sml
cf9f5ab
cf9f5ab
" Sratus VOS command macro
cf9f5ab
au BufNewFile,BufRead *.cm			setf voscm
cf9f5ab
cf9f5ab
" Sysctl
cf9f5ab
au BufNewFile,BufRead /etc/sysctl.conf		setf sysctl
cf9f5ab
cf9f5ab
" Sudoers
cf9f5ab
au BufNewFile,BufRead /etc/sudoers,sudoers.tmp	setf sudoers
cf9f5ab
cf9f5ab
" If the file has an extension of 't' and is in a directory 't' then it is
cf9f5ab
" almost certainly a Perl test file.
cf9f5ab
" If the first line starts with '#' and contains 'perl' it's probably a Perl
cf9f5ab
" file.
cf9f5ab
" (Slow test) If a file contains a 'use' statement then it is almost certainly
cf9f5ab
" a Perl file.
cf9f5ab
func! s:FTperl()
cf9f5ab
  if expand("%:e") == 't' && expand("%:p:h:t") == 't'
cf9f5ab
    setf perl
cf9f5ab
    return 1
cf9f5ab
  endif
cf9f5ab
  if getline(1)[0] == '#' && getline(1) =~ 'perl'
cf9f5ab
    setf perl
cf9f5ab
    return 1
cf9f5ab
  endif
cf9f5ab
  if search('^use\s\s*\k', 'nc', 30)
cf9f5ab
    setf perl
cf9f5ab
    return 1
cf9f5ab
  endif
cf9f5ab
  return 0
cf9f5ab
endfunc
cf9f5ab
cf9f5ab
" Tads (or Nroff or Perl test file)
cf9f5ab
au BufNewFile,BufRead *.t
cf9f5ab
	\ if !s:FTnroff() && !s:FTperl() | setf tads | endif
cf9f5ab
cf9f5ab
" Tags
cf9f5ab
au BufNewFile,BufRead tags			setf tags
cf9f5ab
cf9f5ab
" TAK
cf9f5ab
au BufNewFile,BufRead *.tak			setf tak
cf9f5ab
cf9f5ab
" Tcl (JACL too)
cf9f5ab
au BufNewFile,BufRead *.tcl,*.tk,*.itcl,*.itk,*.jacl	setf tcl
cf9f5ab
cf9f5ab
" TealInfo
cf9f5ab
au BufNewFile,BufRead *.tli			setf tli
cf9f5ab
cf9f5ab
" Telix Salt
cf9f5ab
au BufNewFile,BufRead *.slt			setf tsalt
cf9f5ab
cf9f5ab
" Terminfo
cf9f5ab
au BufNewFile,BufRead *.ti			setf terminfo
cf9f5ab
cf9f5ab
" TeX
cf9f5ab
au BufNewFile,BufRead *.latex,*.sty,*.dtx,*.ltx,*.bbl	setf tex
cf9f5ab
au BufNewFile,BufRead *.tex			call s:FTtex()
cf9f5ab
cf9f5ab
" Choose context, plaintex, or tex (LaTeX) based on these rules:
cf9f5ab
" 1. Check the first line of the file for "%&<format>".
cf9f5ab
" 2. Check the first 1000 non-comment lines for LaTeX or ConTeXt keywords.
cf9f5ab
" 3. Default to "latex" or to g:tex_flavor, can be set in user's vimrc.
cf9f5ab
func! s:FTtex()
cf9f5ab
  let firstline = getline(1)
cf9f5ab
  if firstline =~ '^%&\s*\a\+'
cf9f5ab
    let format = tolower(matchstr(firstline, '\a\+'))
cf9f5ab
    let format = substitute(format, 'pdf', '', '')
cf9f5ab
    if format == 'tex'
cf9f5ab
      let format = 'plain'
cf9f5ab
    endif
cf9f5ab
  else
cf9f5ab
    " Default value, may be changed later:
cf9f5ab
    let format = exists("g:tex_flavor") ? g:tex_flavor : 'plain'
cf9f5ab
    " Save position, go to the top of the file, find first non-comment line.
cf9f5ab
    let save_cursor = getpos('.')
cf9f5ab
    call cursor(1,1)
cf9f5ab
    let firstNC = search('^\s*[^[:space:]%]', 'c', 1000)
cf9f5ab
    if firstNC " Check the next thousand lines for a LaTeX or ConTeXt keyword.
cf9f5ab
      let lpat = 'documentclass\>\|usepackage\>\|begin{\|newcommand\>\|renewcommand\>'
cf9f5ab
      let cpat = 'start\a\+\|setup\a\+\|usemodule\|enablemode\|enableregime\|setvariables\|useencoding\|usesymbols\|stelle\a\+\|verwende\a\+\|stel\a\+\|gebruik\a\+\|usa\a\+\|imposta\a\+\|regle\a\+\|utilisemodule\>'
cf9f5ab
      let kwline = search('^\s*\\\%(' . lpat . '\)\|^\s*\\\(' . cpat . '\)',
cf9f5ab
			      \ 'cnp', firstNC + 1000)
cf9f5ab
      if kwline == 1	" lpat matched
cf9f5ab
	let format = 'latex'
cf9f5ab
      elseif kwline == 2	" cpat matched
cf9f5ab
	let format = 'context'
cf9f5ab
      endif		" If neither matched, keep default set above.
cf9f5ab
      " let lline = search('^\s*\\\%(' . lpat . '\)', 'cn', firstNC + 1000)
cf9f5ab
      " let cline = search('^\s*\\\%(' . cpat . '\)', 'cn', firstNC + 1000)
cf9f5ab
      " if cline > 0
cf9f5ab
      "   let format = 'context'
cf9f5ab
      " endif
cf9f5ab
      " if lline > 0 && (cline == 0 || cline > lline)
cf9f5ab
      "   let format = 'tex'
cf9f5ab
      " endif
cf9f5ab
    endif " firstNC
cf9f5ab
    call setpos('.', save_cursor)
cf9f5ab
  endif " firstline =~ '^%&\s*\a\+'
cf9f5ab
cf9f5ab
  " Translation from formats to file types.  TODO:  add AMSTeX, RevTex, others?
cf9f5ab
  if format == 'plain'
cf9f5ab
    setf plaintex
cf9f5ab
  elseif format == 'context'
cf9f5ab
    setf context
cf9f5ab
  else " probably LaTeX
cf9f5ab
    setf tex
cf9f5ab
  endif
cf9f5ab
  return
cf9f5ab
endfunc
cf9f5ab
cf9f5ab
" ConTeXt
cf9f5ab
au BufNewFile,BufRead tex/context/*/*.tex,*.mkii,*.mkiv   setf context
cf9f5ab
cf9f5ab
" Texinfo
cf9f5ab
au BufNewFile,BufRead *.texinfo,*.texi,*.txi	setf texinfo
cf9f5ab
cf9f5ab
" TeX configuration
cf9f5ab
au BufNewFile,BufRead texmf.cnf			setf texmf
cf9f5ab
cf9f5ab
" Tidy config
cf9f5ab
au BufNewFile,BufRead .tidyrc,tidyrc		setf tidy
cf9f5ab
cf9f5ab
" TF mud client
cf9f5ab
au BufNewFile,BufRead *.tf,.tfrc,tfrc		setf tf
cf9f5ab
cf9f5ab
" TPP - Text Presentation Program
cf9f5ab
au BufNewFile,BufReadPost *.tpp			setf tpp
cf9f5ab
cf9f5ab
" Trustees
cf9f5ab
au BufNewFile,BufRead trustees.conf		setf trustees
cf9f5ab
cf9f5ab
" TSS - Geometry
cf9f5ab
au BufNewFile,BufReadPost *.tssgm		setf tssgm
cf9f5ab
cf9f5ab
" TSS - Optics
cf9f5ab
au BufNewFile,BufReadPost *.tssop		setf tssop
cf9f5ab
cf9f5ab
" TSS - Command Line (temporary)
cf9f5ab
au BufNewFile,BufReadPost *.tsscl		setf tsscl
cf9f5ab
cf9f5ab
" Motif UIT/UIL files
cf9f5ab
au BufNewFile,BufRead *.uit,*.uil		setf uil
cf9f5ab
cf9f5ab
" Udev conf
cf9f5ab
au BufNewFile,BufRead /etc/udev/udev.conf	setf udevconf
cf9f5ab
cf9f5ab
" Udev permissions
cf9f5ab
au BufNewFile,BufRead /etc/udev/permissions.d/*.permissions setf udevperm
cf9f5ab
"
cf9f5ab
" Udev symlinks config
cf9f5ab
au BufNewFile,BufRead /etc/udev/cdsymlinks.conf	setf sh
cf9f5ab
cf9f5ab
" UnrealScript
cf9f5ab
au BufNewFile,BufRead *.uc			setf uc
cf9f5ab
cf9f5ab
" Updatedb
cf9f5ab
au BufNewFile,BufRead /etc/updatedb.conf	setf updatedb
cf9f5ab
cf9f5ab
" Vera
cf9f5ab
au BufNewFile,BufRead *.vr,*.vri,*.vrh		setf vera
cf9f5ab
cf9f5ab
" Verilog HDL
cf9f5ab
au BufNewFile,BufRead *.v			setf verilog
cf9f5ab
cf9f5ab
" Verilog-AMS HDL
cf9f5ab
au BufNewFile,BufRead *.va,*.vams		setf verilogams
cf9f5ab
cf9f5ab
" VHDL
cf9f5ab
au BufNewFile,BufRead *.hdl,*.vhd,*.vhdl,*.vbe,*.vst  setf vhdl
cf9f5ab
au BufNewFile,BufRead *.vhdl_[0-9]*		call s:StarSetf('vhdl')
cf9f5ab
cf9f5ab
" Vim script
cf9f5ab
au BufNewFile,BufRead *.vim,*.vba,.exrc,_exrc	setf vim
cf9f5ab
cf9f5ab
" Viminfo file
cf9f5ab
au BufNewFile,BufRead .viminfo,_viminfo		setf viminfo
cf9f5ab
cf9f5ab
" Virata Config Script File or Drupal module
cf9f5ab
au BufRead,BufNewFile *.hw,*.module,*.pkg
cf9f5ab
	\ if getline(1) =~ '
cf9f5ab
	\   setf php |
cf9f5ab
	\ else |
cf9f5ab
	\   setf virata |
cf9f5ab
	\ endif
cf9f5ab
cf9f5ab
" Visual Basic (also uses *.bas) or FORM
cf9f5ab
au BufNewFile,BufRead *.frm			call s:FTVB("form")
cf9f5ab
cf9f5ab
" SaxBasic is close to Visual Basic
cf9f5ab
au BufNewFile,BufRead *.sba			setf vb
cf9f5ab
cf9f5ab
" Vgrindefs file
cf9f5ab
au BufNewFile,BufRead vgrindefs			setf vgrindefs
cf9f5ab
cf9f5ab
" VRML V1.0c
cf9f5ab
au BufNewFile,BufRead *.wrl			setf vrml
cf9f5ab
cf9f5ab
" Webmacro
cf9f5ab
au BufNewFile,BufRead *.wm			setf webmacro
cf9f5ab
cf9f5ab
" Wget config
cf9f5ab
au BufNewFile,BufRead .wgetrc,wgetrc		setf wget
cf9f5ab
cf9f5ab
" Website MetaLanguage
cf9f5ab
au BufNewFile,BufRead *.wml			setf wml
cf9f5ab
cf9f5ab
" Winbatch
cf9f5ab
au BufNewFile,BufRead *.wbt			setf winbatch
cf9f5ab
cf9f5ab
" WSML
cf9f5ab
au BufNewFile,BufRead *.wsml			setf wsml
cf9f5ab
cf9f5ab
" WvDial
cf9f5ab
au BufNewFile,BufRead wvdial.conf,.wvdialrc	setf wvdial
cf9f5ab
cf9f5ab
" CVS RC file
cf9f5ab
au BufNewFile,BufRead .cvsrc			setf cvsrc
cf9f5ab
cf9f5ab
" CVS commit file
cf9f5ab
au BufNewFile,BufRead cvs\d\+			setf cvs
cf9f5ab
cf9f5ab
" WEB (*.web is also used for Winbatch: Guess, based on expecting "%" comment
cf9f5ab
" lines in a WEB file).
cf9f5ab
au BufNewFile,BufRead *.web
cf9f5ab
	\ if getline(1)[0].getline(2)[0].getline(3)[0].getline(4)[0].getline(5)[0] =~ "%" |
cf9f5ab
	\   setf web |
cf9f5ab
	\ else |
cf9f5ab
	\   setf winbatch |
cf9f5ab
	\ endif
cf9f5ab
cf9f5ab
" Windows Scripting Host and Windows Script Component
cf9f5ab
au BufNewFile,BufRead *.ws[fc]			setf wsh
cf9f5ab
cf9f5ab
" XHTML
cf9f5ab
au BufNewFile,BufRead *.xhtml,*.xht		setf xhtml
cf9f5ab
cf9f5ab
" X Pixmap (dynamically sets colors, use BufEnter to make it work better)
cf9f5ab
au BufEnter *.xpm
cf9f5ab
	\ if getline(1) =~ "XPM2" |
cf9f5ab
	\   setf xpm2 |
cf9f5ab
	\ else |
cf9f5ab
	\   setf xpm |
cf9f5ab
	\ endif
cf9f5ab
au BufEnter *.xpm2				setf xpm2
cf9f5ab
cf9f5ab
" XFree86 config
cf9f5ab
au BufNewFile,BufRead XF86Config
cf9f5ab
	\ if getline(1) =~ '\<XConfigurator\>' |
cf9f5ab
	\   let b:xf86c_xfree86_version = 3 |
cf9f5ab
	\ endif |
cf9f5ab
	\ setf xf86conf
cf9f5ab
cf9f5ab
" Xorg config
cf9f5ab
au BufNewFile,BufRead xorg.conf,xorg.conf-4	let b:xf86c_xfree86_version = 4 | setf xf86conf
cf9f5ab
cf9f5ab
" Xinetd conf
cf9f5ab
au BufNewFile,BufRead /etc/xinetd.conf		setf xinetd
cf9f5ab
cf9f5ab
" XS Perl extension interface language
cf9f5ab
au BufNewFile,BufRead *.xs			setf xs
cf9f5ab
cf9f5ab
" X resources file
cf9f5ab
au BufNewFile,BufRead .Xdefaults,.Xpdefaults,.Xresources,xdm-config,*.ad setf xdefaults
cf9f5ab
cf9f5ab
" Xmath
cf9f5ab
au BufNewFile,BufRead *.msc,*.msf		setf xmath
cf9f5ab
au BufNewFile,BufRead *.ms
cf9f5ab
	\ if !s:FTnroff() | setf xmath | endif
cf9f5ab
cf9f5ab
" XML  specific variants: docbk and xbl
cf9f5ab
au BufNewFile,BufRead *.xml			call s:FTxml()
cf9f5ab
cf9f5ab
func! s:FTxml()
cf9f5ab
  let n = 1
cf9f5ab
  while n < 100 && n < line("$")
cf9f5ab
    let line = getline(n)
cf9f5ab
    if line =~ '
cf9f5ab
      let b:docbk_type = "xml"
cf9f5ab
      setf docbk
cf9f5ab
      return
cf9f5ab
    endif
cf9f5ab
    if line =~ 'xmlns:xbl="http://www.mozilla.org/xbl"'
cf9f5ab
      setf xbl
cf9f5ab
      return
cf9f5ab
    endif
cf9f5ab
    let n += 1
cf9f5ab
  endwhile
cf9f5ab
  setf xml
cf9f5ab
endfunc
cf9f5ab
cf9f5ab
" XMI (holding UML models) is also XML
cf9f5ab
au BufNewFile,BufRead *.xmi			setf xml
cf9f5ab
cf9f5ab
" CSPROJ files are Visual Studio.NET's XML-based project config files
cf9f5ab
au BufNewFile,BufRead *.csproj,*.csproj.user	setf xml
cf9f5ab
cf9f5ab
" Qt Linguist translation source and Qt User Interface Files are XML
cf9f5ab
au BufNewFile,BufRead *.ts,*.ui			setf xml
cf9f5ab
cf9f5ab
" TPM's are RDF-based descriptions of TeX packages (Nikolai Weibull)
cf9f5ab
au BufNewFile,BufRead *.tpm			setf xml
cf9f5ab
cf9f5ab
" Xdg menus
cf9f5ab
au BufNewFile,BufRead /etc/xdg/menus/*.menu	setf xml
cf9f5ab
cf9f5ab
" ATI graphics driver configuration
cf9f5ab
au BufNewFile,BufRead fglrxrc			setf xml
cf9f5ab
cf9f5ab
" XLIFF (XML Localisation Interchange File Format) is also XML
cf9f5ab
au BufNewFile,BufRead *.xlf			setf xml
cf9f5ab
au BufNewFile,BufRead *.xliff			setf xml
cf9f5ab
cf9f5ab
" X11 xmodmap (also see below)
cf9f5ab
au BufNewFile,BufRead *Xmodmap			setf xmodmap
cf9f5ab
cf9f5ab
" Xquery
cf9f5ab
au BufNewFile,BufRead *.xq,*.xql,*.xqm,*.xquery,*.xqy	setf xquery
cf9f5ab
cf9f5ab
" XSD
cf9f5ab
au BufNewFile,BufRead *.xsd			setf xsd
cf9f5ab
cf9f5ab
" Xslt
cf9f5ab
au BufNewFile,BufRead *.xsl,*.xslt		setf xslt
cf9f5ab
cf9f5ab
" Yacc
cf9f5ab
au BufNewFile,BufRead *.yy			setf yacc
cf9f5ab
cf9f5ab
" Yacc or racc
cf9f5ab
au BufNewFile,BufRead *.y			call s:FTy()
cf9f5ab
cf9f5ab
func! s:FTy()
cf9f5ab
  let n = 1
cf9f5ab
  while n < 100 && n < line("$")
cf9f5ab
    let line = getline(n)
cf9f5ab
    if line =~ '^\s*%'
cf9f5ab
      setf yacc
cf9f5ab
      return
cf9f5ab
    endif
cf9f5ab
    if getline(n) =~ '^\s*\(#\|class\>\)' && getline(n) !~ '^\s*#\s*include'
cf9f5ab
      setf racc
cf9f5ab
      return
cf9f5ab
    endif
cf9f5ab
    let n = n + 1
cf9f5ab
  endwhile
cf9f5ab
  setf yacc
cf9f5ab
endfunc
cf9f5ab
cf9f5ab
cf9f5ab
" Yaml
cf9f5ab
au BufNewFile,BufRead *.yaml,*.yml		setf yaml
cf9f5ab
cf9f5ab
" Zope
cf9f5ab
"   dtml (zope dynamic template markup language), pt (zope page template),
cf9f5ab
"   cpt (zope form controller page template)
cf9f5ab
au BufNewFile,BufRead *.dtml,*.pt,*.cpt		call s:FThtml()
cf9f5ab
"   zsql (zope sql method)
cf9f5ab
au BufNewFile,BufRead *.zsql			call s:SQL()
cf9f5ab
cf9f5ab
" Z80 assembler asz80
cf9f5ab
au BufNewFile,BufRead *.z8a			setf z8a
cf9f5ab
cf9f5ab
augroup END
cf9f5ab
cf9f5ab
cf9f5ab
" Source the user-specified filetype file, for backwards compatibility with
cf9f5ab
" Vim 5.x.
cf9f5ab
if exists("myfiletypefile") && filereadable(expand(myfiletypefile))
cf9f5ab
  execute "source " . myfiletypefile
cf9f5ab
endif
cf9f5ab
cf9f5ab
cf9f5ab
" Check for "*" after loading myfiletypefile, so that scripts.vim is only used
cf9f5ab
" when there are no matching file name extensions.
cf9f5ab
" Don't do this for compressed files.
cf9f5ab
augroup filetypedetect
cf9f5ab
au BufNewFile,BufRead *
cf9f5ab
	\ if !did_filetype() && expand("<amatch>") !~ g:ft_ignore_pat
cf9f5ab
	\ | runtime! scripts.vim | endif
cf9f5ab
au StdinReadPost * if !did_filetype() | runtime! scripts.vim | endif
cf9f5ab
cf9f5ab
cf9f5ab
" Extra checks for when no filetype has been detected now.  Mostly used for
cf9f5ab
" patterns that end in "*".  E.g., "zsh*" matches "zsh.vim", but that's a Vim
cf9f5ab
" script file.
cf9f5ab
" Most of these should call s:StarSetf() to avoid names ending in .gz and the
cf9f5ab
" like are used.
cf9f5ab
cf9f5ab
" More Apache files.
cf9f5ab
au BufNewFile,BufRead /etc/apache2/conf.*/*,/etc/apache2/sites-*/*,/etc/apache2/mods-*/*		call s:StarSetf('apache')
cf9f5ab
cf9f5ab
" Asterisk config file
cf9f5ab
au BufNewFile,BufRead *asterisk/*.conf*		call s:StarSetf('asterisk')
cf9f5ab
au BufNewFile,BufRead *asterisk*/*voicemail.conf* call s:StarSetf('asteriskvm')
cf9f5ab
cf9f5ab
" Bazaar version control
cf9f5ab
au BufNewFile,BufRead bzr_log.*			setf bzr
cf9f5ab
cf9f5ab
" BIND zone
cf9f5ab
au BufNewFile,BufRead */named/db.*,*/bind/db.*	call s:StarSetf('bindzone')
cf9f5ab
cf9f5ab
" Changelog
cf9f5ab
au BufNewFile,BufRead [cC]hange[lL]og*
cf9f5ab
	\ if getline(1) =~ '; urgency='
cf9f5ab
	\|  call s:StarSetf('debchangelog')
cf9f5ab
	\|else
cf9f5ab
	\|  call s:StarSetf('changelog')
cf9f5ab
	\|endif
cf9f5ab
cf9f5ab
" Crontab
cf9f5ab
au BufNewFile,BufRead crontab,crontab.*,/etc/cron.d/*		call s:StarSetf('crontab')
cf9f5ab
cf9f5ab
" Debian Sources.list
cf9f5ab
au BufNewFile,BufRead /etc/apt/sources.list.d/*	call s:StarSetf('debsources')
cf9f5ab
cf9f5ab
" Dracula
cf9f5ab
au BufNewFile,BufRead drac.*			call s:StarSetf('dracula')
cf9f5ab
cf9f5ab
" Fvwm
cf9f5ab
au BufNewFile,BufRead */.fvwm/*			call s:StarSetf('fvwm')
cf9f5ab
au BufNewFile,BufRead *fvwmrc*,*fvwm95*.hook
cf9f5ab
	\ let b:fvwm_version = 1 | call s:StarSetf('fvwm')
cf9f5ab
au BufNewFile,BufRead *fvwm2rc*
cf9f5ab
	\ if expand("<afile>:e") == "m4"
cf9f5ab
	\|  call s:StarSetf('fvwm2m4')
cf9f5ab
	\|else
cf9f5ab
	\|  let b:fvwm_version = 2 | call s:StarSetf('fvwm')
cf9f5ab
	\|endif
cf9f5ab
cf9f5ab
" GTK RC
cf9f5ab
au BufNewFile,BufRead .gtkrc*,gtkrc*		call s:StarSetf('gtkrc')
cf9f5ab
cf9f5ab
" Jam
cf9f5ab
au BufNewFile,BufRead Prl*.*,JAM*.*		call s:StarSetf('jam')
cf9f5ab
cf9f5ab
" Jargon
cf9f5ab
au! BufNewFile,BufRead *jarg*
cf9f5ab
	\ if getline(1).getline(2).getline(3).getline(4).getline(5) =~? 'THIS IS THE JARGON FILE'
cf9f5ab
	\|  call s:StarSetf('jargon')
cf9f5ab
	\|endif
cf9f5ab
cf9f5ab
" Kconfig
cf9f5ab
au BufNewFile,BufRead Kconfig.*			call s:StarSetf('kconfig')
cf9f5ab
cf9f5ab
" Makefile
cf9f5ab
au BufNewFile,BufRead [mM]akefile*		call s:StarSetf('make')
cf9f5ab
cf9f5ab
" Ruby Makefile
cf9f5ab
au BufNewFile,BufRead [rR]akefile*		call s:StarSetf('ruby')
cf9f5ab
cf9f5ab
" Mail (also matches muttrc.vim, so this is below the other checks)
cf9f5ab
au BufNewFile,BufRead mutt[[:alnum:]._-]\{6\}	setf mail
cf9f5ab
cf9f5ab
" Modconf
cf9f5ab
au BufNewFile,BufRead /etc/modprobe.*		call s:StarSetf('modconf')
cf9f5ab
cf9f5ab
" Mutt setup file
cf9f5ab
au BufNewFile,BufRead .mutt{ng,}rc*,*/.mutt{ng,}/mutt{ng,}rc*	call s:StarSetf('muttrc')
cf9f5ab
au BufNewFile,BufRead mutt{ng,}rc*,Mutt{ng,}rc*		call s:StarSetf('muttrc')
cf9f5ab
cf9f5ab
" Nroff macros
cf9f5ab
au BufNewFile,BufRead tmac.*			call s:StarSetf('nroff')
cf9f5ab
cf9f5ab
" Pam conf
cf9f5ab
au BufNewFile,BufRead /etc/pam.d/*		call s:StarSetf('pamconf')
cf9f5ab
cf9f5ab
" Printcap and Termcap
cf9f5ab
au BufNewFile,BufRead *printcap*
cf9f5ab
	\ if !did_filetype()
cf9f5ab
	\|  let b:ptcap_type = "print" | call s:StarSetf('ptcap')
cf9f5ab
	\|endif
cf9f5ab
au BufNewFile,BufRead *termcap*
cf9f5ab
	\ if !did_filetype()
cf9f5ab
	\|  let b:ptcap_type = "term" | call s:StarSetf('ptcap')
cf9f5ab
	\|endif
cf9f5ab
cf9f5ab
" Vim script
cf9f5ab
au BufNewFile,BufRead *vimrc*			call s:StarSetf('vim')
cf9f5ab
cf9f5ab
" Subversion commit file
cf9f5ab
au BufNewFile,BufRead svn-commit*.tmp		setf svn
cf9f5ab
cf9f5ab
" X resources file
cf9f5ab
au BufNewFile,BufRead Xresources*,*/app-defaults/*,*/Xresources/* call s:StarSetf('xdefaults')
cf9f5ab
cf9f5ab
" XFree86 config
cf9f5ab
au BufNewFile,BufRead XF86Config-4*
cf9f5ab
	\ let b:xf86c_xfree86_version = 4 | call s:StarSetf('xf86conf')
cf9f5ab
au BufNewFile,BufRead XF86Config*
cf9f5ab
	\ if getline(1) =~ '\<XConfigurator\>'
cf9f5ab
	\|  let b:xf86c_xfree86_version = 3
cf9f5ab
	\|endif
cf9f5ab
	\|call s:StarSetf('xf86conf')
cf9f5ab
cf9f5ab
" X11 xmodmap
cf9f5ab
au BufNewFile,BufRead *xmodmap*			call s:StarSetf('xmodmap')
cf9f5ab
cf9f5ab
" Xinetd conf
cf9f5ab
au BufNewFile,BufRead /etc/xinetd.d/*		call s:StarSetf('xinetd')
cf9f5ab
cf9f5ab
" Z-Shell script
cf9f5ab
au BufNewFile,BufRead zsh*,zlog*		call s:StarSetf('zsh')
cf9f5ab
cf9f5ab
cf9f5ab
" Generic configuration file (check this last, it's just guessing!)
cf9f5ab
au BufNewFile,BufRead,StdinReadPost *
cf9f5ab
	\ if !did_filetype() && expand("<amatch>") !~ g:ft_ignore_pat
cf9f5ab
	\    && (getline(1) =~ '^#' || getline(2) =~ '^#' || getline(3) =~ '^#'
cf9f5ab
	\	|| getline(4) =~ '^#' || getline(5) =~ '^#') |
cf9f5ab
	\   setf conf |
cf9f5ab
	\ endif
cf9f5ab
cf9f5ab
" Use the plugin-filetype checks last, they may overrule any of the previously
cf9f5ab
" detected filetypes.
cf9f5ab
runtime! ftdetect/*.vim
cf9f5ab
cf9f5ab
augroup END
cf9f5ab
cf9f5ab
cf9f5ab
" If the GUI is already running, may still need to install the Syntax menu.
cf9f5ab
" Don't do it when the 'M' flag is included in 'guioptions'.
cf9f5ab
if has("menu") && has("gui_running")
cf9f5ab
      \ && !exists("did_install_syntax_menu") && &guioptions !~# "M"
cf9f5ab
  source <sfile>:p:h/menu.vim
cf9f5ab
endif
cf9f5ab
cf9f5ab
" Function called for testing all functions defined here.  These are
cf9f5ab
" script-local, thus need to be executed here.
cf9f5ab
" Returns a string with error messages (hopefully empty).
cf9f5ab
func! TestFiletypeFuncs(testlist)
cf9f5ab
  let output = ''
cf9f5ab
  for f in a:testlist
cf9f5ab
    try
cf9f5ab
      exe f
cf9f5ab
    catch
cf9f5ab
      let output = output . "\n" . f . ": " . v:exception
cf9f5ab
    endtry
cf9f5ab
  endfor
cf9f5ab
  return output
cf9f5ab
endfunc
cf9f5ab
cf9f5ab
" Restore 'cpoptions'
cf9f5ab
let &cpo = s:cpo_save
cf9f5ab
unlet s:cpo_save