au BufNewFile,BufRead *.desktop,.directory setf desktop
" Dict config
au BufNewFile,BufRead dict.conf,.dictrc setf dictconf
" Dictd config
au BufNewFile,BufRead dictd.conf setf dictdconf
" Diff files
au BufNewFile,BufRead *.diff,*.rej,*.patch setf diff
" Dircolors
au BufNewFile,BufRead .dir_colors,.dircolors,*/etc/DIR_COLORS setf dircolors
" Diva (with Skill) or InstallShield
au BufNewFile,BufRead *.rul
\ if getline(1).getline(2).getline(3).getline(4).getline(5).getline(6) =~? 'InstallShield' |
\ setf ishd |
\ else |
\ setf diva |
\ endif
" DCL (Digital Command Language - vms) or DNS zone file
au BufNewFile,BufRead *.com call s:BindzoneCheck('dcl')
" DOT
au BufNewFile,BufRead *.dot setf dot
" Dylan - lid files
au BufNewFile,BufRead *.lid setf dylanlid
" Dylan - intr files (melange)
au BufNewFile,BufRead *.intr setf dylanintr
" Dylan
au BufNewFile,BufRead *.dylan setf dylan
" Microsoft Module Definition
au BufNewFile,BufRead *.def setf def
" Dracula
au BufNewFile,BufRead *.drac,*.drc,*lvs,*lpe setf dracula
" Datascript
au BufNewFile,BufRead *.ds setf datascript
" dsl
au BufNewFile,BufRead *.dsl setf dsl
" DTD (Document Type Definition for XML)
au BufNewFile,BufRead *.dtd setf dtd
" EDIF (*.edf,*.edif,*.edn,*.edo)
au BufNewFile,BufRead *.ed\(f\|if\|n\|o\) setf edif
" Embedix Component Description
au BufNewFile,BufRead *.ecd setf ecd
" Eiffel or Specman
au BufNewFile,BufRead *.e,*.E call s:FTe()
" Elinks configuration
au BufNewFile,BufRead */etc/elinks.conf,*/.elinks/elinks.conf setf elinks
func! s:FTe()
let n = 1
while n < 100 && n < line("$")
if getline(n) =~ "^\\s*\\(<'\\|'>\\)\\s*$"
setf specman
return
endif
let n = n + 1
endwhile
setf eiffel
endfunc
" ERicsson LANGuage; Yaws is erlang too
au BufNewFile,BufRead *.erl,*.hrl,*.yaws setf erlang
" Elm Filter Rules file
au BufNewFile,BufRead filter-rules setf elmfilt
" ESMTP rc file
au BufNewFile,BufRead *esmtprc setf esmtprc
" ESQL-C
au BufNewFile,BufRead *.ec,*.EC setf esqlc
" Esterel
au BufNewFile,BufRead *.strl setf esterel
" Essbase script
au BufNewFile,BufRead *.csc setf csc
" Exim
au BufNewFile,BufRead exim.conf setf exim
" Expect
au BufNewFile,BufRead *.exp setf expect
" Exports
au BufNewFile,BufRead exports setf exports
" Falcon
au BufNewFile,BufRead *.fal setf falcon
" Fantom
au BufNewFile,BufRead *.fan,*.fwt setf fan
" Factor
au BufNewFile,BufRead *.factor setf factor
" Fetchmail RC file
au BufNewFile,BufRead .fetchmailrc setf fetchmail
" FlexWiki - disabled, because it has side effects when a .wiki file
" is not actually FlexWiki
"au BufNewFile,BufRead *.wiki setf flexwiki
" Focus Executable
au BufNewFile,BufRead *.fex,*.focexec setf focexec
" Focus Master file (but not for auto.master)
au BufNewFile,BufRead auto.master setf conf
au BufNewFile,BufRead *.mas,*.master setf master
" Forth
au BufNewFile,BufRead *.fs,*.ft setf forth
" Reva Forth
au BufNewFile,BufRead *.frt setf reva
" Fortran
if has("fname_case")
au BufNewFile,BufRead *.F,*.FOR,*.FPP,*.FTN,*.F77,*.F90,*.F95,*.F03,*.F08 setf fortran
endif
au BufNewFile,BufRead *.f,*.for,*.fortran,*.fpp,*.ftn,*.f77,*.f90,*.f95,*.f03,*.f08 setf fortran
" Framescript
au BufNewFile,BufRead *.fsl setf framescript
" FStab
au BufNewFile,BufRead fstab,mtab setf fstab
" GDB command files
au BufNewFile,BufRead .gdbinit setf gdb
" GDMO
au BufNewFile,BufRead *.mo,*.gdmo setf gdmo
" Gedcom
au BufNewFile,BufRead *.ged,lltxxxxx.txt setf gedcom
" Git
au BufNewFile,BufRead *.git/COMMIT_EDITMSG setf gitcommit
au BufNewFile,BufRead *.git/config,.gitconfig,.gitmodules setf gitconfig
au BufNewFile,BufRead *.git/modules/**/COMMIT_EDITMSG setf gitcommit
au BufNewFile,BufRead *.git/modules/**/config setf gitconfig
au BufNewFile,BufRead git-rebase-todo setf gitrebase
au BufNewFile,BufRead .msg.[0-9]*
\ if getline(1) =~ '^From.*# This line is ignored.$' |
\ setf gitsendemail |
\ endif
au BufNewFile,BufRead *.git/**
\ if getline(1) =~ '^\x\{40\}\>\|^ref: ' |
\ setf git |
\ endif
" Gkrellmrc
au BufNewFile,BufRead gkrellmrc,gkrellmrc_? setf gkrellmrc
" GP scripts (2.0 and onward)
au BufNewFile,BufRead *.gp,.gprc setf gp
" GPG
au BufNewFile,BufRead */.gnupg/options setf gpg
au BufNewFile,BufRead */.gnupg/gpg.conf setf gpg
au BufNewFile,BufRead */usr/**/gnupg/options.skel setf gpg
" gnash(1) configuration files
au BufNewFile,BufRead gnashrc,.gnashrc,gnashpluginrc,.gnashpluginrc setf gnash
" Gitolite
au BufNewFile,BufRead gitolite.conf setf gitolite
au BufNewFile,BufRead */gitolite-admin/conf/* call s:StarSetf('gitolite')
au BufNewFile,BufRead {,.}gitolite.rc,example.gitolite.rc setf perl
" Gnuplot scripts
au BufNewFile,BufRead *.gpi setf gnuplot
" GrADS scripts
au BufNewFile,BufRead *.gs setf grads
" Gretl
au BufNewFile,BufRead *.gretl setf gretl
" Groovy
au BufNewFile,BufRead *.groovy setf groovy
" GNU Server Pages
au BufNewFile,BufRead *.gsp setf gsp
" Group file
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
" GTK RC
au BufNewFile,BufRead .gtkrc,gtkrc setf gtkrc
" Haml
au BufNewFile,BufRead *.haml setf haml
" Hamster Classic | Playground files
au BufNewFile,BufRead *.hsc,*.hsm setf hamster
" Haskell
au BufNewFile,BufRead *.hs,*.hs-boot setf haskell
au BufNewFile,BufRead *.lhs setf lhaskell
au BufNewFile,BufRead *.chs setf chaskell
" Haste
au BufNewFile,BufRead *.ht setf haste
au BufNewFile,BufRead *.htpp setf hastepreproc
" Hercules
au BufNewFile,BufRead *.vc,*.ev,*.rs,*.sum,*.errsum setf hercules
" HEX (Intel)
au BufNewFile,BufRead *.hex,*.h32 setf hex
" Tilde (must be before HTML)
au BufNewFile,BufRead *.t.html setf tilde
" HTML (.shtml and .stm for server side)
au BufNewFile,BufRead *.html,*.htm,*.shtml,*.stm call s:FThtml()
" Distinguish between HTML, XHTML and Django
func! s:FThtml()
let n = 1
while n < 10 && n < line("$")
if getline(n) =~ '\<DTD\s\+XHTML\s'
setf xhtml
return
endif
if getline(n) =~ '{%\s*\(extends\|block\)\>'
setf htmldjango
return
endif
let n = n + 1
endwhile
setf html
endfunc
" HTML with Ruby - eRuby
au BufNewFile,BufRead *.erb,*.rhtml setf eruby
" HTML with M4
au BufNewFile,BufRead *.html.m4 setf htmlm4
" HTML Cheetah template
au BufNewFile,BufRead *.tmpl setf htmlcheetah
" Host config
au BufNewFile,BufRead */etc/host.conf setf hostconf
" Hosts access
au BufNewFile,BufRead */etc/hosts.allow,*/etc/hosts.deny setf hostsaccess
" Hyper Builder
au BufNewFile,BufRead *.hb setf hb
" Icon
au BufNewFile,BufRead *.icn setf icon
" IDL (Interface Description Language)
au BufNewFile,BufRead *.idl call s:FTidl()
" Distinguish between standard IDL and MS-IDL
func! s:FTidl()
let n = 1
while n < 50 && n < line("$")
if getline(n) =~ '^\s*import\s\+"\(unknwn\|objidl\)\.idl"'
setf msidl
return
endif
let n = n + 1
endwhile
setf idl
endfunc
" Microsoft IDL (Interface Description Language) Also *.idl
" MOF = WMI (Windows Management Instrumentation) Managed Object Format
au BufNewFile,BufRead *.odl,*.mof setf msidl
" Icewm menu
au BufNewFile,BufRead */.icewm/menu setf icemenu
" Indent profile (must come before IDL *.pro!)
au BufNewFile,BufRead .indent.pro setf indent
au BufNewFile,BufRead indent.pro call s:ProtoCheck('indent')
" IDL (Interactive Data Language)
au BufNewFile,BufRead *.pro call s:ProtoCheck('idlang')
" Distinguish between "default" and Cproto prototype file. */
func! s:ProtoCheck(default)
" Cproto files have a comment in the first line and a function prototype in
" the second line, it always ends in ";". Indent files may also have
" comments, thus we can't match comments to see the difference.
" IDL files can have a single ';' in the second line, require at least one
" chacter before the ';'.
if getline(2) =~ '.;$'
setf cpp
else
exe 'setf ' . a:default
endif
endfunc
" Indent RC
au BufNewFile,BufRead indentrc setf indent
" Inform
au BufNewFile,BufRead *.inf,*.INF setf inform
" Initng
au BufNewFile,BufRead */etc/initng/**/*.i,*.ii setf initng
" Ipfilter
au BufNewFile,BufRead ipf.conf,ipf6.conf,ipf.rules setf ipfilter
" Informix 4GL (source - canonical, include file, I4GL+M4 preproc.)
au BufNewFile,BufRead *.4gl,*.4gh,*.m4gl setf fgl
" .INI file for MSDOS
au BufNewFile,BufRead *.ini setf dosini
" SysV Inittab
au BufNewFile,BufRead inittab setf inittab
" Inno Setup
au BufNewFile,BufRead *.iss setf iss
" JAL
au BufNewFile,BufRead *.jal,*.JAL setf jal
" Jam
au BufNewFile,BufRead *.jpl,*.jpr setf jam
" Java
au BufNewFile,BufRead *.java,*.jav setf java
" JavaCC
au BufNewFile,BufRead *.jj,*.jjt setf javacc
" JavaScript, ECMAScript
au BufNewFile,BufRead *.js,*.javascript,*.es,*.jsx,*.json setf javascript
au BufNewFile,BufRead *.lsp,*.lisp,*.el,*.cl,*.jl,*.L,.emacs,.sawfishrc setf lisp
else
au BufNewFile,BufRead *.lsp,*.lisp,*.el,*.cl,*.jl,.emacs,.sawfishrc setf lisp
endif
" SBCL implementation of Common Lisp
au BufNewFile,BufRead sbclrc,.sbclrc setf lisp
" Liquid
au BufNewFile,BufRead *.liquid setf liquid
" Lite
au BufNewFile,BufRead *.lite,*.lt setf lite
" LiteStep RC files
au BufNewFile,BufRead */LiteStep/*/*.rc setf litestep
" Login access
au BufNewFile,BufRead */etc/login.access setf loginaccess
" Login defs
au BufNewFile,BufRead */etc/login.defs setf logindefs
" Logtalk
au BufNewFile,BufRead *.lgt setf logtalk
" LOTOS
au BufNewFile,BufRead *.lot,*.lotos setf lotos
" Lout (also: *.lt)
au BufNewFile,BufRead *.lou,*.lout setf lout
" Lua
au BufNewFile,BufRead *.lua setf lua
" Linden Scripting Language (Second Life)
au BufNewFile,BufRead *.lsl setf lsl
" Lynx style file (or LotusScript!)
au BufNewFile,BufRead *.lss setf lss
" M4
au BufNewFile,BufRead *.m4
\ if expand("<afile>") !~? 'html.m4$\|fvwm2rc' | setf m4 | endif
" MaGic Point
au BufNewFile,BufRead *.mgp setf mgp
" Mail (for Elm, trn, mutt, muttng, rn, slrn)
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
" Mail aliases
au BufNewFile,BufRead */etc/mail/aliases,*/etc/aliases setf mailaliases
" Mailcap configuration file
au BufNewFile,BufRead .mailcap,mailcap setf mailcap
" Makefile
au BufNewFile,BufRead *[mM]akefile,*.mk,*.mak,*.dsp setf make
" MakeIndex
au BufNewFile,BufRead *.ist,*.mst setf ist
" Manpage
au BufNewFile,BufRead *.man setf man
" Man config
au BufNewFile,BufRead */etc/man.conf,man.config setf manconf
" Maple V
au BufNewFile,BufRead *.mv,*.mpl,*.mws setf maple
" Map (UMN mapserver config file)
au BufNewFile,BufRead *.map setf map
" Markdown
au BufNewFile,BufRead *.markdown,*.mdown,*.mkd,*.mkdn,README.md setf markdown
" Mason
au BufNewFile,BufRead *.mason,*.mhtml setf mason
" Matlab or Objective C
au BufNewFile,BufRead *.m call s:FTm()
func! s:FTm()
let n = 1
while n < 10
let line = getline(n)
if line =~ '^\s*\(#\s*\(include\|import\)\>\|/\*\|//\)'
setf objc
return
endif
if line =~ '^\s*%'
setf matlab
return
endif
if line =~ '^\s*(\*'
setf mma
return
endif
let n = n + 1
endwhile
if exists("g:filetype_m")
exe "setf " . g:filetype_m
else
setf matlab
endif
endfunc
" Mathematica notebook
au BufNewFile,BufRead *.nb setf mma
" Maya Extension Language
au BufNewFile,BufRead *.mel setf mel
" Mercurial config (looks like generic config file)
au BufNewFile,BufRead *.hgrc,*hgrc setf cfg
" Messages (logs mostly)
au BufNewFile,BufRead */log/{auth,cron,daemon,debug,kern,lpr,mail,messages,news/news,syslog,user}{,.log,.err,.info,.warn,.crit,.notice}{,.[0-9]*,-[0-9]*} setf messages
" Metafont
au BufNewFile,BufRead *.mf setf mf
" MetaPost
au BufNewFile,BufRead *.mp setf mp
" MGL
au BufNewFile,BufRead *.mgl setf mgl
" MMIX or VMS makefile
au BufNewFile,BufRead *.mms call s:FTmms()
" Symbian meta-makefile definition (MMP)
au BufNewFile,BufRead *.mmp setf mmp
func! s:FTmms()
let n = 1
while n < 10
let line = getline(n)
if line =~ '^\s*\(%\|//\)' || line =~ '^\*'
setf mmix
return
endif
if line =~ '^\s*#'
setf make
return
endif
let n = n + 1
endwhile
setf mmix
endfunc
" Modsim III (or LambdaProlog)
au BufNewFile,BufRead *.mod
\ if getline(1) =~ '\<module\>' |
\ setf lprolog |
\ else |
\ setf modsim3 |
\ endif
" Modula 2
au BufNewFile,BufRead *.m2,*.DEF,*.MOD,*.md,*.mi setf modula2
" Modula 3 (.m3, .i3, .mg, .ig)
au BufNewFile,BufRead *.[mi][3g] setf modula3
" Monk
au BufNewFile,BufRead *.isc,*.monk,*.ssc,*.tsc setf monk
" MOO
au BufNewFile,BufRead *.moo setf moo
" Modconf
au BufNewFile,BufRead */etc/modules.conf,*/etc/modules,*/etc/conf.modules setf modconf
" Mplayer config
au BufNewFile,BufRead mplayer.conf,*/.mplayer/config setf mplayerconf
" Moterola S record
au BufNewFile,BufRead *.s19,*.s28,*.s37 setf srec
" Mrxvtrc
au BufNewFile,BufRead mrxvtrc,.mrxvtrc setf mrxvtrc
" Msql
au BufNewFile,BufRead *.msql setf msql
" Mysql
au BufNewFile,BufRead *.mysql setf mysql
" Mutt setup files (must be before catch *.rc)
au BufNewFile,BufRead */etc/Muttrc.d/* call s:StarSetf('muttrc')
" M$ Resource files
au BufNewFile,BufRead *.rc setf rc
" MuPAD source
au BufRead,BufNewFile *.mu setf mupad
" Mush
au BufNewFile,BufRead *.mush setf mush
" Mutt setup file (also for Muttng)
au BufNewFile,BufRead Mutt{ng,}rc setf muttrc
" Nano
au BufNewFile,BufRead */etc/nanorc,.nanorc setf nanorc
" Nastran input/DMAP
"au BufNewFile,BufRead *.dat setf nastran
" Natural
au BufNewFile,BufRead *.NS[ACGLMNPS] setf natural
" Netrc
au BufNewFile,BufRead .netrc setf netrc
" Ninja file
au BufNewFile,BufRead *.ninja setf ninja
" Novell netware batch files
au BufNewFile,BufRead *.ncf setf ncf
" Nroff/Troff (*.ms and *.t are checked below)
au BufNewFile,BufRead *.me
\ if expand("<afile>") != "read.me" && expand("<afile>") != "click.me" |
\ setf nroff |
\ endif
au BufNewFile,BufRead *.tr,*.nr,*.roff,*.tmac,*.mom setf nroff
au BufNewFile,BufRead *.[1-9] call s:FTnroff()
" This function checks if one of the first five lines start with a dot. In
" that case it is probably an nroff file: 'filetype' is set and 1 is returned.
if line =~ '^\s*\(#\s*\(include\|import\)\>\|/\*\)'
setf objcpp
return
endif
let n = n + 1
endwhile
setf nroff
endfunc
" Not Quite C
au BufNewFile,BufRead *.nqc setf nqc
" NSIS
au BufNewFile,BufRead *.nsi,*.nsh setf nsis
" OCAML
au BufNewFile,BufRead *.ml,*.mli,*.mll,*.mly,.ocamlinit setf ocaml
" Occam
au BufNewFile,BufRead *.occ setf occam
" Omnimark
au BufNewFile,BufRead *.xom,*.xin setf omnimark
" OpenROAD
au BufNewFile,BufRead *.or setf openroad
" OPL
au BufNewFile,BufRead *.[Oo][Pp][Ll] setf opl
" Oracle config file
au BufNewFile,BufRead *.ora setf ora
" Packet filter conf
au BufNewFile,BufRead pf.conf setf pf
" Pam conf
au BufNewFile,BufRead */etc/pam.conf setf pamconf
" PApp
au BufNewFile,BufRead *.papp,*.pxml,*.pxsl setf papp
" Password file
au BufNewFile,BufRead */etc/passwd,*/etc/passwd-,*/etc/passwd.edit,*/etc/shadow,*/etc/shadow-,*/etc/shadow.edit,*/var/backups/passwd.bak,*/var/backups/shadow.bak setf passwd
" Pascal (also *.p)
au BufNewFile,BufRead *.pas setf pascal
" Delphi project file
au BufNewFile,BufRead *.dpr setf pascal
" PDF
au BufNewFile,BufRead *.pdf setf pdf
" Perl
if has("fname_case")
au BufNewFile,BufRead *.pl,*.PL call s:FTpl()
else
au BufNewFile,BufRead *.pl call s:FTpl()
endif
au BufNewFile,BufRead *.plx,*.al setf perl
au BufNewFile,BufRead *.p6,*.pm6 setf perl6
func! s:FTpl()
if exists("g:filetype_pl")
exe "setf " . g:filetype_pl
else
" recognize Prolog by specific text in the first non-empty line
" require a blank after the '%' because Perl uses "%list" and "%translate"
let l = getline(nextnonblank(1))
if l =~ '\<prolog\>' || l =~ '^\s*\(%\+\(\s\|$\)\|/\*\)' || l =~ ':-'
setf prolog
else
setf perl
endif
endif
endfunc
" Perl, XPM or XPM2
au BufNewFile,BufRead *.pm
\ if getline(1) =~ "XPM2" |
\ setf xpm2 |
\ elseif getline(1) =~ "XPM" |
\ setf xpm |
\ else |
\ setf perl |
\ endif
" Perl POD
au BufNewFile,BufRead *.pod setf pod
" Php, php3, php4, etc.
" Also Phtml (was used for PHP 2 in the past)
" Also .ctp for Cake template file
au BufNewFile,BufRead *.php,*.php\d,*.phtml,*.ctp setf php
" Pike
au BufNewFile,BufRead *.pike,*.lpc,*.ulpc,*.pmod setf pike
" Pinfo config
au BufNewFile,BufRead */etc/pinforc,*/.pinforc setf pinfo
" Palm Resource compiler
au BufNewFile,BufRead *.rcp setf pilrc
" Pine config
au BufNewFile,BufRead .pinerc,pinerc,.pinercex,pinercex setf pine
" PL/M (also: *.inp)
au BufNewFile,BufRead *.plm,*.p36,*.pac setf plm
" PL/SQL
au BufNewFile,BufRead *.pls,*.plsql setf plsql
" PLP
au BufNewFile,BufRead *.plp setf plp
" PO and PO template (GNU gettext)
au BufNewFile,BufRead *.po,*.pot setf po
" Postfix main config
au BufNewFile,BufRead main.cf setf pfmain
" PostScript (+ font files, encapsulated PostScript, Adobe Illustrator)
au BufNewFile,BufRead *.ps,*.pfa,*.afm,*.eps,*.epsf,*.epsi,*.ai setf postscr
" PostScript Printer Description
au BufNewFile,BufRead *.ppd setf ppd
" Povray
au BufNewFile,BufRead *.pov setf pov
" Povray configuration
au BufNewFile,BufRead .povrayrc setf povini
" Povray, PHP or assembly
au BufNewFile,BufRead *.inc call s:FTinc()
func! s:FTinc()
if exists("g:filetype_inc")
exe "setf " . g:filetype_inc
else
let lines = getline(1).getline(2).getline(3)
if lines =~? "perlscript"
setf aspperl
elseif lines =~ "<%"
setf aspvbs
elseif lines =~ "<?"
setf php
else
call s:FTasmsyntax()
if exists("b:asmsyntax")
exe "setf " . fnameescape(b:asmsyntax)
else
setf pov
endif
endif
endif
endfunc
" Printcap and Termcap
au BufNewFile,BufRead *printcap
\ let b:ptcap_type = "print" | setf ptcap
au BufNewFile,BufRead *termcap
\ let b:ptcap_type = "term" | setf ptcap
" PCCTS / ANTRL
"au BufNewFile,BufRead *.g setf antrl
au BufNewFile,BufRead *.g setf pccts
" PPWizard
au BufNewFile,BufRead *.it,*.ih setf ppwiz
" Obj 3D file format
" TODO: is there a way to avoid MS-Windows Object files?
au BufNewFile,BufRead *.obj setf obj
" Oracle Pro*C/C++
au BufNewFile,BufRead *.pc setf proc
" Privoxy actions file
au BufNewFile,BufRead *.action setf privoxy
" Procmail
au BufNewFile,BufRead .procmail,.procmailrc setf procmail
" Progress or CWEB
au BufNewFile,BufRead *.w call s:FTprogress_cweb()
func! s:FTprogress_cweb()
if exists("g:filetype_w")
exe "setf " . g:filetype_w
return
endif
if getline(1) =~ '&ANALYZE' || getline(3) =~ '&GLOBAL-DEFINE'
setf progress
else
setf cweb
endif
endfunc
" Progress or assembly
au BufNewFile,BufRead *.i call s:FTprogress_asm()
func! s:FTprogress_asm()
if exists("g:filetype_i")
exe "setf " . g:filetype_i
return
endif
" This function checks for an assembly comment the first ten lines.
" If not found, assume Progress.
let lnum = 1
while lnum <= 10 && lnum < line('$')
let line = getline(lnum)
if line =~ '^\s*;' || line =~ '^\*'
call s:FTasm()
return
elseif line !~ '^\s*$' || line =~ '^/\*'
" Not an empty line: Doesn't look like valid assembly code.
" Or it looks like a Progress /* comment
break
endif
let lnum = lnum + 1
endw
setf progress
endfunc
" Progress or Pascal
au BufNewFile,BufRead *.p call s:FTprogress_pascal()
func! s:FTprogress_pascal()
if exists("g:filetype_p")
exe "setf " . g:filetype_p
return
endif
" This function checks for valid Pascal syntax in the first ten lines.
" Look for either an opening comment or a program start.
" If not found, assume Progress.
let lnum = 1
while lnum <= 10 && lnum < line('$')
let line = getline(lnum)
if line =~ '^\s*\(program\|unit\|procedure\|function\|const\|type\|var\)\>'
\ || line =~ '^\s*{' || line =~ '^\s*(\*'
setf pascal
return
elseif line !~ '^\s*$' || line =~ '^/\*'
" Not an empty line: Doesn't look like valid Pascal code.
" For shell-like file types, check for an "exec" command hidden in a comment,
" as used for Tcl.
" Also called from scripts.vim, thus can't be local to this script.
func! SetFileTypeShell(name)
if expand("<amatch>") =~ g:ft_ignore_pat
return
endif
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
endfunc
" tcsh scripts
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 s:CSH()
func! s:CSH()
if exists("g:filetype_csh")
call SetFileTypeShell(g:filetype_csh)
elseif &shell =~ "tcsh"
call SetFileTypeShell("tcsh")
else
call SetFileTypeShell("csh")
endif
endfunc
" Z-Shell script
au BufNewFile,BufRead .zprofile,*/etc/zprofile,.zfbfmarks setf zsh
au BufNewFile,BufRead .zsh*,.zlog*,.zcompdump* call s:StarSetf('zsh')
au BufNewFile,BufRead *.zsh setf zsh
" Scheme
au BufNewFile,BufRead *.scm,*.ss,*.rkt setf scheme
" Screen RC
au BufNewFile,BufRead .screenrc,screenrc setf screen
" Simula
au BufNewFile,BufRead *.sim setf simula
" SINDA
au BufNewFile,BufRead *.sin,*.s85 setf sinda
" SiSU
au BufNewFile,BufRead *.sst,*.ssm,*.ssi,*.-sst,*._sst setf sisu
au BufNewFile,BufRead *.sst.meta,*.-sst.meta,*._sst.meta setf sisu
" SKILL
au BufNewFile,BufRead *.il,*.ils,*.cdf setf skill
" SLRN
au BufNewFile,BufRead .slrnrc setf slrnrc
au BufNewFile,BufRead *.score setf slrnsc
" Smalltalk (and TeX)
au BufNewFile,BufRead *.st setf st
au BufNewFile,BufRead *.cls
\ if getline(1) =~ '^%' |
\ setf tex |
\ else |
\ setf st |
\ endif
" Smarty templates
au BufNewFile,BufRead *.tpl setf smarty
" SMIL or XML
au BufNewFile,BufRead *.smil
\ if getline(1) =~ '<?\s*xml.*?>' |
\ setf xml |
\ else |
\ setf smil |
\ endif
" SMIL or SNMP MIB file
au BufNewFile,BufRead *.smi
\ if getline(1) =~ '\<smil\>' |
\ setf smil |
\ else |
\ setf mib |
\ endif
" SMITH
au BufNewFile,BufRead *.smt,*.smith setf smith
" Snobol4 and spitbol
au BufNewFile,BufRead *.sno,*.spt setf snobol4
" SNMP MIB files
au BufNewFile,BufRead *.mib,*.my setf mib
" Snort Configuration
au BufNewFile,BufRead *.hog,snort.conf,vision.conf setf hog
au BufNewFile,BufRead *.rules call s:FTRules()
let s:ft_rules_udev_rules_pattern = '^\s*\cudev_rules\s*=\s*"\([^"]\{-1,}\)/*".*'
func! s:FTRules()
let path = expand('<amatch>:p')
if path =~ '^/\(etc/udev/\%(rules\.d/\)\=.*\.rules\|lib/udev/\%(rules\.d/\)\=.*\.rules\)$'
setf udevrules
return
endif
if path =~ '^/etc/ufw/'
setf conf " Better than hog
return
endif
try
let config_lines = readfile('/etc/udev/udev.conf')
catch /^Vim\%((\a\+)\)\=:E484/
setf hog
return
endtry
let dir = expand('<amatch>:p:h')
for line in config_lines
if line =~ s:ft_rules_udev_rules_pattern
let udev_rules = substitute(line, s:ft_rules_udev_rules_pattern, '\1', "")
if dir == udev_rules
setf udevrules
endif
break
endif
endfor
setf hog
endfunc
" Spec (Linux RPM)
au BufNewFile,BufRead *.spec setf spec
" Speedup (AspenTech plant simulator)
au BufNewFile,BufRead *.speedup,*.spdata,*.spd setf spup
" Slice
au BufNewFile,BufRead *.ice setf slice
" Spice
au BufNewFile,BufRead *.sp,*.spice setf spice
" Spyce
au BufNewFile,BufRead *.spy,*.spi setf spyce
" Squid
au BufNewFile,BufRead squid.conf setf squid
" SQL for Oracle Designer
au BufNewFile,BufRead *.tyb,*.typ,*.tyc,*.pkb,*.pks setf sql
" SQL
au BufNewFile,BufRead *.sql call s:SQL()
func! s:SQL()
if exists("g:filetype_sql")
exe "setf " . g:filetype_sql
else
setf sql
endif
endfunc
" SQLJ
au BufNewFile,BufRead *.sqlj setf sqlj
" SQR
au BufNewFile,BufRead *.sqr,*.sqi setf sqr
" OpenSSH configuration
au BufNewFile,BufRead ssh_config,*/.ssh/config setf sshconfig
" OpenSSH server configuration
au BufNewFile,BufRead sshd_config setf sshdconfig
" Stata
au BufNewFile,BufRead *.ado,*.class,*.do,*.imata,*.mata setf stata
" SMCL
au BufNewFile,BufRead *.hlp,*.ihlp,*.smcl setf smcl
" Stored Procedures
au BufNewFile,BufRead *.stp setf stp
" Standard ML
au BufNewFile,BufRead *.sml setf sml
" Sratus VOS command macro
au BufNewFile,BufRead *.cm setf voscm
" Sysctl
au BufNewFile,BufRead */etc/sysctl.conf,*/etc/sysctl.d/*.conf setf sysctl
" Synopsys Design Constraints
au BufNewFile,BufRead *.sdc setf sdc
" Sudoers
au BufNewFile,BufRead */etc/sudoers,sudoers.tmp setf sudoers
" SVG (Scalable Vector Graphics)
au BufNewFile,BufRead *.svg setf svg
" If the file has an extension of 't' and is in a directory 't' then it is
" almost certainly a Perl test file.
" If the first line starts with '#' and contains 'perl' it's probably a Perl
" file.
" (Slow test) If a file contains a 'use' statement then it is almost certainly
" a Perl file.
func! s:FTperl()
if expand("%:e") == 't' && expand("%:p:h:t") == 't'
setf perl
return 1
endif
if getline(1)[0] == '#' && getline(1) =~ 'perl'
setf perl
return 1
endif
if search('^use\s\s*\k', 'nc', 30)
setf perl
return 1
endif
return 0
endfunc
" Tads (or Nroff or Perl test file)
au BufNewFile,BufRead *.t
\ if !s:FTnroff() && !s:FTperl() | setf tads | endif
" Tags
au BufNewFile,BufRead tags setf tags
" TAK
au BufNewFile,BufRead *.tak setf tak
" Task
au BufRead,BufNewFile {pending,completed,undo}.data setf taskdata
au BufRead,BufNewFile *.task setf taskedit
" Tcl (JACL too)
au BufNewFile,BufRead *.tcl,*.tk,*.itcl,*.itk,*.jacl setf tcl
" TealInfo
au BufNewFile,BufRead *.tli setf tli
" Telix Salt
au BufNewFile,BufRead *.slt setf tsalt
" Terminfo
au BufNewFile,BufRead *.ti setf terminfo
" TeX
au BufNewFile,BufRead *.latex,*.sty,*.dtx,*.ltx,*.bbl setf tex
au BufNewFile,BufRead *.tex call s:FTtex()
" Choose context, plaintex, or tex (LaTeX) based on these rules:
" 1. Check the first line of the file for "%&<format>".
" 2. Check the first 1000 non-comment lines for LaTeX or ConTeXt keywords.
" 3. Default to "latex" or to g:tex_flavor, can be set in user's vimrc.
func! s:FTtex()
let firstline = getline(1)
if firstline =~ '^%&\s*\a\+'
let format = tolower(matchstr(firstline, '\a\+'))
let format = substitute(format, 'pdf', '', '')
if format == 'tex'
let format = 'plain'
endif
else
" Default value, may be changed later:
let format = exists("g:tex_flavor") ? g:tex_flavor : 'plain'
" Save position, go to the top of the file, find first non-comment line.
let save_cursor = getpos('.')
call cursor(1,1)
let firstNC = search('^\s*[^[:space:]%]', 'c', 1000)
if firstNC " Check the next thousand lines for a LaTeX or ConTeXt keyword.
let lpat = 'documentclass\>\|usepackage\>\|begin{\|newcommand\>\|renewcommand\>'
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\>'
au BufNewFile,BufRead *.dtml,*.pt,*.cpt call s:FThtml()
" zsql (zope sql method)
au BufNewFile,BufRead *.zsql call s:SQL()
" Z80 assembler asz80
au BufNewFile,BufRead *.z8a setf z8a
augroup END
" Source the user-specified filetype file, for backwards compatibility with
" Vim 5.x.
if exists("myfiletypefile") && filereadable(expand(myfiletypefile))
execute "source " . myfiletypefile
endif
" Check for "*" after loading myfiletypefile, so that scripts.vim is only used
" when there are no matching file name extensions.
" Don't do this for compressed files.
augroup filetypedetect
au BufNewFile,BufRead *
\ if !did_filetype() && expand("<amatch>") !~ g:ft_ignore_pat
\ | runtime! scripts.vim | endif
au StdinReadPost * if !did_filetype() | runtime! scripts.vim | endif
" Extra checks for when no filetype has been detected now. Mostly used for
" patterns that end in "*". E.g., "zsh*" matches "zsh.vim", but that's a Vim
" script file.
" Most of these should call s:StarSetf() to avoid names ending in .gz and the
" like are used.
" More Apache config files
au BufNewFile,BufRead access.conf*,apache.conf*,apache2.conf*,httpd.conf*,srm.conf* call s:StarSetf('apache')
au BufNewFile,BufRead */etc/apache2/*.conf*,*/etc/apache2/conf.*/*,*/etc/apache2/mods-*/*,*/etc/apache2/sites-*/*,*/etc/httpd/conf.d/*.conf* call s:StarSetf('apache')
" Asterisk config file
au BufNewFile,BufRead *asterisk/*.conf* call s:StarSetf('asterisk')
au BufNewFile,BufRead *asterisk*/*voicemail.conf* call s:StarSetf('asteriskvm')
" Bazaar version control
au BufNewFile,BufRead bzr_log.* setf bzr
" BIND zone
au BufNewFile,BufRead */named/db.*,*/bind/db.* call s:StarSetf('bindzone')