xref: /vim-8.2.3635/runtime/filetype.vim (revision e968e36a)
1" Vim support file to detect file types
2"
3" Maintainer:	Bram Moolenaar <[email protected]>
4" Last Change:	2014 Feb 26
5
6" Listen very carefully, I will say this only once
7if exists("did_load_filetypes")
8  finish
9endif
10let did_load_filetypes = 1
11
12" Line continuation is used here, remove 'C' from 'cpoptions'
13let s:cpo_save = &cpo
14set cpo&vim
15
16augroup filetypedetect
17
18" Ignored extensions
19if exists("*fnameescape")
20au BufNewFile,BufRead ?\+.orig,?\+.bak,?\+.old,?\+.new,?\+.dpkg-dist,?\+.dpkg-old,?\+.dpkg-new,?\+.dpkg-bak,?\+.rpmsave,?\+.rpmnew
21	\ exe "doau filetypedetect BufRead " . fnameescape(expand("<afile>:r"))
22au BufNewFile,BufRead *~
23	\ let s:name = expand("<afile>") |
24	\ let s:short = substitute(s:name, '\~$', '', '') |
25	\ if s:name != s:short && s:short != "" |
26	\   exe "doau filetypedetect BufRead " . fnameescape(s:short) |
27	\ endif |
28	\ unlet! s:name s:short
29au BufNewFile,BufRead ?\+.in
30	\ if expand("<afile>:t") != "configure.in" |
31	\   exe "doau filetypedetect BufRead " . fnameescape(expand("<afile>:r")) |
32	\ endif
33elseif &verbose > 0
34  echomsg "Warning: some filetypes will not be recognized because this version of Vim does not have fnameescape()"
35endif
36
37" Pattern used to match file names which should not be inspected.
38" Currently finds compressed files.
39if !exists("g:ft_ignore_pat")
40  let g:ft_ignore_pat = '\.\(Z\|gz\|bz2\|zip\|tgz\)$'
41endif
42
43" Function used for patterns that end in a star: don't set the filetype if the
44" file name matches ft_ignore_pat.
45func! s:StarSetf(ft)
46  if expand("<amatch>") !~ g:ft_ignore_pat
47    exe 'setf ' . a:ft
48  endif
49endfunc
50
51" Abaqus or Trasys
52au BufNewFile,BufRead *.inp			call s:Check_inp()
53
54func! s:Check_inp()
55  if getline(1) =~ '^\*'
56    setf abaqus
57  else
58    let n = 1
59    if line("$") > 500
60      let nmax = 500
61    else
62      let nmax = line("$")
63    endif
64    while n <= nmax
65      if getline(n) =~? "^header surface data"
66	setf trasys
67	break
68      endif
69      let n = n + 1
70    endwhile
71  endif
72endfunc
73
74" A-A-P recipe
75au BufNewFile,BufRead *.aap			setf aap
76
77" A2ps printing utility
78au BufNewFile,BufRead */etc/a2ps.cfg,*/etc/a2ps/*.cfg,a2psrc,.a2psrc setf a2ps
79
80" ABAB/4
81au BufNewFile,BufRead *.abap			setf abap
82
83" ABC music notation
84au BufNewFile,BufRead *.abc			setf abc
85
86" ABEL
87au BufNewFile,BufRead *.abl			setf abel
88
89" AceDB
90au BufNewFile,BufRead *.wrm			setf acedb
91
92" Ada (83, 9X, 95)
93au BufNewFile,BufRead *.adb,*.ads,*.ada		setf ada
94if has("vms")
95  au BufNewFile,BufRead *.gpr,*.ada_m,*.adc	setf ada
96else
97  au BufNewFile,BufRead *.gpr			setf ada
98endif
99
100" AHDL
101au BufNewFile,BufRead *.tdf			setf ahdl
102
103" AMPL
104au BufNewFile,BufRead *.run			setf ampl
105
106" Ant
107au BufNewFile,BufRead build.xml			setf ant
108
109" Arduino
110au BufNewFile,BufRead *.ino,*.pde		setf arduino
111
112" Apache style config file
113au BufNewFile,BufRead proftpd.conf*		call s:StarSetf('apachestyle')
114
115" Apache config file
116au BufNewFile,BufRead .htaccess,*/etc/httpd/*.conf		setf apache
117
118" XA65 MOS6510 cross assembler
119au BufNewFile,BufRead *.a65			setf a65
120
121" Applescript
122au BufNewFile,BufRead *.scpt			setf applescript
123
124" Applix ELF
125au BufNewFile,BufRead *.am
126	\ if expand("<afile>") !~? 'Makefile.am\>' | setf elf | endif
127
128" ALSA configuration
129au BufNewFile,BufRead .asoundrc,*/usr/share/alsa/alsa.conf,*/etc/asound.conf setf alsaconf
130
131" Arc Macro Language
132au BufNewFile,BufRead *.aml			setf aml
133
134" APT config file
135au BufNewFile,BufRead apt.conf		       setf aptconf
136au BufNewFile,BufRead */.aptitude/config       setf aptconf
137au BufNewFile,BufRead */etc/apt/apt.conf.d/{[-_[:alnum:]]\+,[-_.[:alnum:]]\+.conf} setf aptconf
138
139" Arch Inventory file
140au BufNewFile,BufRead .arch-inventory,=tagging-method	setf arch
141
142" ART*Enterprise (formerly ART-IM)
143au BufNewFile,BufRead *.art			setf art
144
145" AsciiDoc
146au BufNewFile,BufRead *.asciidoc		setf asciidoc
147
148" ASN.1
149au BufNewFile,BufRead *.asn,*.asn1		setf asn
150
151" Active Server Pages (with Visual Basic Script)
152au BufNewFile,BufRead *.asa
153	\ if exists("g:filetype_asa") |
154	\   exe "setf " . g:filetype_asa |
155	\ else |
156	\   setf aspvbs |
157	\ endif
158
159" Active Server Pages (with Perl or Visual Basic Script)
160au BufNewFile,BufRead *.asp
161	\ if exists("g:filetype_asp") |
162	\   exe "setf " . g:filetype_asp |
163	\ elseif getline(1) . getline(2) . getline(3) =~? "perlscript" |
164	\   setf aspperl |
165	\ else |
166	\   setf aspvbs |
167	\ endif
168
169" Grub (must be before catch *.lst)
170au BufNewFile,BufRead */boot/grub/menu.lst,*/boot/grub/grub.conf,*/etc/grub.conf setf grub
171
172" Assembly (all kinds)
173" *.lst is not pure assembly, it has two extra columns (address, byte codes)
174au BufNewFile,BufRead *.asm,*.[sS],*.[aA],*.mac,*.lst	call s:FTasm()
175
176" This function checks for the kind of assembly that is wanted by the user, or
177" can be detected from the first five lines of the file.
178func! s:FTasm()
179  " make sure b:asmsyntax exists
180  if !exists("b:asmsyntax")
181    let b:asmsyntax = ""
182  endif
183
184  if b:asmsyntax == ""
185    call s:FTasmsyntax()
186  endif
187
188  " if b:asmsyntax still isn't set, default to asmsyntax or GNU
189  if b:asmsyntax == ""
190    if exists("g:asmsyntax")
191      let b:asmsyntax = g:asmsyntax
192    else
193      let b:asmsyntax = "asm"
194    endif
195  endif
196
197  exe "setf " . fnameescape(b:asmsyntax)
198endfunc
199
200func! s:FTasmsyntax()
201  " see if file contains any asmsyntax=foo overrides. If so, change
202  " b:asmsyntax appropriately
203  let head = " ".getline(1)." ".getline(2)." ".getline(3)." ".getline(4).
204	\" ".getline(5)." "
205  let match = matchstr(head, '\sasmsyntax=\zs[a-zA-Z0-9]\+\ze\s')
206  if match != ''
207    let b:asmsyntax = match
208  elseif ((head =~? '\.title') || (head =~? '\.ident') || (head =~? '\.macro') || (head =~? '\.subtitle') || (head =~? '\.library'))
209    let b:asmsyntax = "vmasm"
210  endif
211endfunc
212
213" Macro (VAX)
214au BufNewFile,BufRead *.mar			setf vmasm
215
216" Atlas
217au BufNewFile,BufRead *.atl,*.as		setf atlas
218
219" Autoit v3
220au BufNewFile,BufRead *.au3			setf autoit
221
222" Autohotkey
223au BufNewFile,BufRead *.ahk			setf autohotkey
224
225" Automake
226au BufNewFile,BufRead [mM]akefile.am,GNUmakefile.am	setf automake
227
228" Autotest .at files are actually m4
229au BufNewFile,BufRead *.at			setf m4
230
231" Avenue
232au BufNewFile,BufRead *.ave			setf ave
233
234" Awk
235au BufNewFile,BufRead *.awk			setf awk
236
237" B
238au BufNewFile,BufRead *.mch,*.ref,*.imp		setf b
239
240" BASIC or Visual Basic
241au BufNewFile,BufRead *.bas			call s:FTVB("basic")
242
243" Check if one of the first five lines contains "VB_Name".  In that case it is
244" probably a Visual Basic file.  Otherwise it's assumed to be "alt" filetype.
245func! s:FTVB(alt)
246  if getline(1).getline(2).getline(3).getline(4).getline(5) =~? 'VB_Name\|Begin VB\.\(Form\|MDIForm\|UserControl\)'
247    setf vb
248  else
249    exe "setf " . a:alt
250  endif
251endfunc
252
253" Visual Basic Script (close to Visual Basic) or Visual Basic .NET
254au BufNewFile,BufRead *.vb,*.vbs,*.dsm,*.ctl	setf vb
255
256" IBasic file (similar to QBasic)
257au BufNewFile,BufRead *.iba,*.ibi		setf ibasic
258
259" FreeBasic file (similar to QBasic)
260au BufNewFile,BufRead *.fb,*.bi			setf freebasic
261
262" Batch file for MSDOS.
263au BufNewFile,BufRead *.bat,*.sys		setf dosbatch
264" *.cmd is close to a Batch file, but on OS/2 Rexx files also use *.cmd.
265au BufNewFile,BufRead *.cmd
266	\ if getline(1) =~ '^/\*' | setf rexx | else | setf dosbatch | endif
267
268" Batch file for 4DOS
269au BufNewFile,BufRead *.btm			call s:FTbtm()
270func! s:FTbtm()
271  if exists("g:dosbatch_syntax_for_btm") && g:dosbatch_syntax_for_btm
272    setf dosbatch
273  else
274    setf btm
275  endif
276endfunc
277
278" BC calculator
279au BufNewFile,BufRead *.bc			setf bc
280
281" BDF font
282au BufNewFile,BufRead *.bdf			setf bdf
283
284" BibTeX bibliography database file
285au BufNewFile,BufRead *.bib			setf bib
286
287" BibTeX Bibliography Style
288au BufNewFile,BufRead *.bst			setf bst
289
290" BIND configuration
291au BufNewFile,BufRead named.conf,rndc.conf	setf named
292
293" BIND zone
294au BufNewFile,BufRead named.root		setf bindzone
295au BufNewFile,BufRead *.db			call s:BindzoneCheck('')
296
297func! s:BindzoneCheck(default)
298  if getline(1).getline(2).getline(3).getline(4) =~ '^; <<>> DiG [0-9.]\+ <<>>\|BIND.*named\|$ORIGIN\|$TTL\|IN\s\+SOA'
299    setf bindzone
300  elseif a:default != ''
301    exe 'setf ' . a:default
302  endif
303endfunc
304
305" Blank
306au BufNewFile,BufRead *.bl			setf blank
307
308" Blkid cache file
309au BufNewFile,BufRead */etc/blkid.tab,*/etc/blkid.tab.old   setf xml
310
311" C or lpc
312au BufNewFile,BufRead *.c			call s:FTlpc()
313
314func! s:FTlpc()
315  if exists("g:lpc_syntax_for_c")
316    let lnum = 1
317    while lnum <= 12
318      if getline(lnum) =~# '^\(//\|inherit\|private\|protected\|nosave\|string\|object\|mapping\|mixed\)'
319	setf lpc
320	return
321      endif
322      let lnum = lnum + 1
323    endwhile
324  endif
325  setf c
326endfunc
327
328" Calendar
329au BufNewFile,BufRead calendar			setf calendar
330
331" C#
332au BufNewFile,BufRead *.cs			setf cs
333
334" CSDL
335au BufNewFile,BufRead *.csdl			setf csdl
336
337" Cabal
338au BufNewFile,BufRead *.cabal			setf cabal
339
340" Cdrdao TOC
341au BufNewFile,BufRead *.toc			setf cdrtoc
342
343" Cdrdao config
344au BufNewFile,BufRead */etc/cdrdao.conf,*/etc/defaults/cdrdao,*/etc/default/cdrdao,.cdrdao	setf cdrdaoconf
345
346" Cfengine
347au BufNewFile,BufRead cfengine.conf		setf cfengine
348
349" ChaiScript
350au BufRead,BufNewFile *.chai			setf chaiscript
351
352" Comshare Dimension Definition Language
353au BufNewFile,BufRead *.cdl			setf cdl
354
355" Conary Recipe
356au BufNewFile,BufRead *.recipe			setf conaryrecipe
357
358" Controllable Regex Mutilator
359au BufNewFile,BufRead *.crm			setf crm
360
361" Cyn++
362au BufNewFile,BufRead *.cyn			setf cynpp
363
364" Cynlib
365" .cc and .cpp files can be C++ or Cynlib.
366au BufNewFile,BufRead *.cc
367	\ if exists("cynlib_syntax_for_cc")|setf cynlib|else|setf cpp|endif
368au BufNewFile,BufRead *.cpp
369	\ if exists("cynlib_syntax_for_cpp")|setf cynlib|else|setf cpp|endif
370
371" C++
372au BufNewFile,BufRead *.cxx,*.c++,*.hh,*.hxx,*.hpp,*.ipp,*.moc,*.tcc,*.inl setf cpp
373if has("fname_case")
374  au BufNewFile,BufRead *.C,*.H setf cpp
375endif
376
377" .h files can be C, Ch C++, ObjC or ObjC++.
378" Set c_syntax_for_h if you want C, ch_syntax_for_h if you want Ch. ObjC is
379" detected automatically.
380au BufNewFile,BufRead *.h			call s:FTheader()
381
382func! s:FTheader()
383  if match(getline(1, min([line("$"), 200])), '^@\(interface\|end\|class\)') > -1
384    if exists("g:c_syntax_for_h")
385      setf objc
386    else
387      setf objcpp
388    endif
389  elseif exists("g:c_syntax_for_h")
390    setf c
391  elseif exists("g:ch_syntax_for_h")
392    setf ch
393  else
394    setf cpp
395  endif
396endfunc
397
398" Ch (CHscript)
399au BufNewFile,BufRead *.chf			setf ch
400
401" TLH files are C++ headers generated by Visual C++'s #import from typelibs
402au BufNewFile,BufRead *.tlh			setf cpp
403
404" Cascading Style Sheets
405au BufNewFile,BufRead *.css			setf css
406
407" Century Term Command Scripts (*.cmd too)
408au BufNewFile,BufRead *.con			setf cterm
409
410" Changelog
411au BufNewFile,BufRead changelog.Debian,changelog.dch,NEWS.Debian,NEWS.dch
412					\	setf debchangelog
413
414au BufNewFile,BufRead [cC]hange[lL]og
415	\  if getline(1) =~ '; urgency='
416	\|   setf debchangelog
417	\| else
418	\|   setf changelog
419	\| endif
420
421au BufNewFile,BufRead NEWS
422	\  if getline(1) =~ '; urgency='
423	\|   setf debchangelog
424	\| endif
425
426" CHILL
427au BufNewFile,BufRead *..ch			setf chill
428
429" Changes for WEB and CWEB or CHILL
430au BufNewFile,BufRead *.ch			call s:FTchange()
431
432" This function checks if one of the first ten lines start with a '@'.  In
433" that case it is probably a change file.
434" If the first line starts with # or ! it's probably a ch file.
435" If a line has "main", "include", "//" ir "/*" it's probably ch.
436" Otherwise CHILL is assumed.
437func! s:FTchange()
438  let lnum = 1
439  while lnum <= 10
440    if getline(lnum)[0] == '@'
441      setf change
442      return
443    endif
444    if lnum == 1 && (getline(1)[0] == '#' || getline(1)[0] == '!')
445      setf ch
446      return
447    endif
448    if getline(lnum) =~ "MODULE"
449      setf chill
450      return
451    endif
452    if getline(lnum) =~ 'main\s*(\|#\s*include\|//'
453      setf ch
454      return
455    endif
456    let lnum = lnum + 1
457  endwhile
458  setf chill
459endfunc
460
461" ChordPro
462au BufNewFile,BufRead *.chopro,*.crd,*.cho,*.crdpro,*.chordpro	setf chordpro
463
464" Clean
465au BufNewFile,BufRead *.dcl,*.icl		setf clean
466
467" Clever
468au BufNewFile,BufRead *.eni			setf cl
469
470" Clever or dtd
471au BufNewFile,BufRead *.ent			call s:FTent()
472
473func! s:FTent()
474  " This function checks for valid cl syntax in the first five lines.
475  " Look for either an opening comment, '#', or a block start, '{".
476  " If not found, assume SGML.
477  let lnum = 1
478  while lnum < 6
479    let line = getline(lnum)
480    if line =~ '^\s*[#{]'
481      setf cl
482      return
483    elseif line !~ '^\s*$'
484      " Not a blank line, not a comment, and not a block start,
485      " so doesn't look like valid cl code.
486      break
487    endif
488    let lnum = lnum + 1
489  endw
490  setf dtd
491endfunc
492
493" Clipper (or FoxPro; could also be eviews)
494au BufNewFile,BufRead *.prg
495	\ if exists("g:filetype_prg") |
496	\   exe "setf " . g:filetype_prg |
497	\ else |
498	\   setf clipper |
499	\ endif
500
501" Clojure
502au BufNewFile,BufRead *.clj,*.cljs		setf clojure
503
504" Cmake
505au BufNewFile,BufRead CMakeLists.txt,*.cmake,*.cmake.in		setf cmake
506
507" Cmusrc
508au BufNewFile,BufRead */.cmus/{autosave,rc,command-history,*.theme} setf cmusrc
509au BufNewFile,BufRead */cmus/{rc,*.theme}			setf cmusrc
510
511" Cobol
512au BufNewFile,BufRead *.cbl,*.cob,*.lib	setf cobol
513"   cobol or zope form controller python script? (heuristic)
514au BufNewFile,BufRead *.cpy
515	\ if getline(1) =~ '^##' |
516	\   setf python |
517	\ else |
518	\   setf cobol |
519	\ endif
520
521" Coco/R
522au BufNewFile,BufRead *.atg			setf coco
523
524" Cold Fusion
525au BufNewFile,BufRead *.cfm,*.cfi,*.cfc		setf cf
526
527" Configure scripts
528au BufNewFile,BufRead configure.in,configure.ac setf config
529
530" CUDA  Cumpute Unified Device Architecture
531au BufNewFile,BufRead *.cu			setf cuda
532
533" WildPackets EtherPeek Decoder
534au BufNewFile,BufRead *.dcd			setf dcd
535
536" Enlightenment configuration files
537au BufNewFile,BufRead *enlightenment/*.cfg	setf c
538
539" Eterm
540au BufNewFile,BufRead *Eterm/*.cfg		setf eterm
541
542" Euphoria 3 or 4
543au BufNewFile,BufRead *.eu,*.ew,*.ex,*.exu,*.exw  call s:EuphoriaCheck()
544if has("fname_case")
545   au BufNewFile,BufRead *.EU,*.EW,*.EX,*.EXU,*.EXW  call s:EuphoriaCheck()
546endif
547
548func! s:EuphoriaCheck()
549  if exists('g:filetype_euphoria')
550    exe 'setf ' . g:filetype_euphoria
551  else
552    setf euphoria3
553  endif
554endfunc
555
556" Lynx config files
557au BufNewFile,BufRead lynx.cfg			setf lynx
558
559" Quake
560au BufNewFile,BufRead *baseq[2-3]/*.cfg,*id1/*.cfg	setf quake
561au BufNewFile,BufRead *quake[1-3]/*.cfg			setf quake
562
563" Quake C
564au BufNewFile,BufRead *.qc			setf c
565
566" Configure files
567au BufNewFile,BufRead *.cfg			setf cfg
568
569" Cucumber
570au BufNewFile,BufRead *.feature			setf cucumber
571
572" Communicating Sequential Processes
573au BufNewFile,BufRead *.csp,*.fdr		setf csp
574
575" CUPL logic description and simulation
576au BufNewFile,BufRead *.pld			setf cupl
577au BufNewFile,BufRead *.si			setf cuplsim
578
579" Debian Control
580au BufNewFile,BufRead */debian/control		setf debcontrol
581au BufNewFile,BufRead control
582	\  if getline(1) =~ '^Source:'
583	\|   setf debcontrol
584	\| endif
585
586" Debian Sources.list
587au BufNewFile,BufRead */etc/apt/sources.list		setf debsources
588au BufNewFile,BufRead */etc/apt/sources.list.d/*.list	setf debsources
589
590" Deny hosts
591au BufNewFile,BufRead denyhosts.conf		setf denyhosts
592
593" dnsmasq(8) configuration files
594au BufNewFile,BufRead */etc/dnsmasq.conf	setf dnsmasq
595
596" ROCKLinux package description
597au BufNewFile,BufRead *.desc			setf desc
598
599" the D language or dtrace
600au BufNewFile,BufRead *.d			call s:DtraceCheck()
601
602func! s:DtraceCheck()
603  let lines = getline(1, min([line("$"), 100]))
604  if match(lines, '^module\>\|^import\>') > -1
605    " D files often start with a module and/or import statement.
606    setf d
607  elseif match(lines, '^#!\S\+dtrace\|#pragma\s\+D\s\+option\|:\S\{-}:\S\{-}:') > -1
608    setf dtrace
609  else
610    setf d
611  endif
612endfunc
613
614" Desktop files
615au BufNewFile,BufRead *.desktop,.directory	setf desktop
616
617" Dict config
618au BufNewFile,BufRead dict.conf,.dictrc		setf dictconf
619
620" Dictd config
621au BufNewFile,BufRead dictd.conf		setf dictdconf
622
623" Diff files
624au BufNewFile,BufRead *.diff,*.rej,*.patch	setf diff
625
626" Dircolors
627au BufNewFile,BufRead .dir_colors,.dircolors,*/etc/DIR_COLORS	setf dircolors
628
629" Diva (with Skill) or InstallShield
630au BufNewFile,BufRead *.rul
631	\ if getline(1).getline(2).getline(3).getline(4).getline(5).getline(6) =~? 'InstallShield' |
632	\   setf ishd |
633	\ else |
634	\   setf diva |
635	\ endif
636
637" DCL (Digital Command Language - vms) or DNS zone file
638au BufNewFile,BufRead *.com			call s:BindzoneCheck('dcl')
639
640" DOT
641au BufNewFile,BufRead *.dot			setf dot
642
643" Dylan - lid files
644au BufNewFile,BufRead *.lid			setf dylanlid
645
646" Dylan - intr files (melange)
647au BufNewFile,BufRead *.intr			setf dylanintr
648
649" Dylan
650au BufNewFile,BufRead *.dylan			setf dylan
651
652" Microsoft Module Definition
653au BufNewFile,BufRead *.def			setf def
654
655" Dracula
656au BufNewFile,BufRead *.drac,*.drc,*lvs,*lpe	setf dracula
657
658" Datascript
659au BufNewFile,BufRead *.ds			setf datascript
660
661" dsl
662au BufNewFile,BufRead *.dsl			setf dsl
663
664" DTD (Document Type Definition for XML)
665au BufNewFile,BufRead *.dtd			setf dtd
666
667" DTS/DSTI (device tree files)
668au BufNewFile,BufRead *.dts,*.dtsi		setf dts
669
670" EDIF (*.edf,*.edif,*.edn,*.edo)
671au BufNewFile,BufRead *.ed\(f\|if\|n\|o\)	setf edif
672
673" Embedix Component Description
674au BufNewFile,BufRead *.ecd			setf ecd
675
676" Eiffel or Specman or Euphoria
677au BufNewFile,BufRead *.e,*.E			call s:FTe()
678
679" Elinks configuration
680au BufNewFile,BufRead */etc/elinks.conf,*/.elinks/elinks.conf	setf elinks
681
682func! s:FTe()
683  if exists('g:filetype_euphoria')
684    exe 'setf ' . g:filetype_euphoria
685  else
686    let n = 1
687    while n < 100 && n < line("$")
688      if getline(n) =~ "^\\s*\\(<'\\|'>\\)\\s*$"
689        setf specman
690        return
691      endif
692      let n = n + 1
693    endwhile
694    setf eiffel
695  endif
696endfunc
697
698" ERicsson LANGuage; Yaws is erlang too
699au BufNewFile,BufRead *.erl,*.hrl,*.yaws	setf erlang
700
701" Elm Filter Rules file
702au BufNewFile,BufRead filter-rules		setf elmfilt
703
704" ESMTP rc file
705au BufNewFile,BufRead *esmtprc			setf esmtprc
706
707" ESQL-C
708au BufNewFile,BufRead *.ec,*.EC			setf esqlc
709
710" Esterel
711au BufNewFile,BufRead *.strl			setf esterel
712
713" Essbase script
714au BufNewFile,BufRead *.csc			setf csc
715
716" Exim
717au BufNewFile,BufRead exim.conf			setf exim
718
719" Expect
720au BufNewFile,BufRead *.exp			setf expect
721
722" Exports
723au BufNewFile,BufRead exports			setf exports
724
725" Falcon
726au BufNewFile,BufRead *.fal			setf falcon
727
728" Fantom
729au BufNewFile,BufRead *.fan,*.fwt		setf fan
730
731" Factor
732au BufNewFile,BufRead *.factor			setf factor
733
734" Fetchmail RC file
735au BufNewFile,BufRead .fetchmailrc		setf fetchmail
736
737" FlexWiki - disabled, because it has side effects when a .wiki file
738" is not actually FlexWiki
739"au BufNewFile,BufRead *.wiki			setf flexwiki
740
741" Focus Executable
742au BufNewFile,BufRead *.fex,*.focexec		setf focexec
743
744" Focus Master file (but not for auto.master)
745au BufNewFile,BufRead auto.master		setf conf
746au BufNewFile,BufRead *.mas,*.master		setf master
747
748" Forth
749au BufNewFile,BufRead *.fs,*.ft			setf forth
750
751" Reva Forth
752au BufNewFile,BufRead *.frt			setf reva
753
754" Fortran
755if has("fname_case")
756  au BufNewFile,BufRead *.F,*.FOR,*.FPP,*.FTN,*.F77,*.F90,*.F95,*.F03,*.F08	 setf fortran
757endif
758au BufNewFile,BufRead   *.f,*.for,*.fortran,*.fpp,*.ftn,*.f77,*.f90,*.f95,*.f03,*.f08  setf fortran
759
760" Framescript
761au BufNewFile,BufRead *.fsl			setf framescript
762
763" FStab
764au BufNewFile,BufRead fstab,mtab		setf fstab
765
766" GDB command files
767au BufNewFile,BufRead .gdbinit			setf gdb
768
769" GDMO
770au BufNewFile,BufRead *.mo,*.gdmo		setf gdmo
771
772" Gedcom
773au BufNewFile,BufRead *.ged,lltxxxxx.txt	setf gedcom
774
775" Git
776au BufNewFile,BufRead *.git/COMMIT_EDITMSG	setf gitcommit
777au BufNewFile,BufRead *.git/MERGE_MSG		setf gitcommit
778au BufNewFile,BufRead *.git/config,.gitconfig,.gitmodules setf gitconfig
779au BufNewFile,BufRead *.git/modules/*/COMMIT_EDITMSG setf gitcommit
780au BufNewFile,BufRead *.git/modules/*/config	setf gitconfig
781au BufNewFile,BufRead */.config/git/config	setf gitconfig
782au BufNewFile,BufRead git-rebase-todo		setf gitrebase
783au BufNewFile,BufRead .msg.[0-9]*
784      \ if getline(1) =~ '^From.*# This line is ignored.$' |
785      \   setf gitsendemail |
786      \ endif
787au BufNewFile,BufRead *.git/*
788      \ if getline(1) =~ '^\x\{40\}\>\|^ref: ' |
789      \   setf git |
790      \ endif
791
792" Gkrellmrc
793au BufNewFile,BufRead gkrellmrc,gkrellmrc_?	setf gkrellmrc
794
795" GP scripts (2.0 and onward)
796au BufNewFile,BufRead *.gp,.gprc		setf gp
797
798" GPG
799au BufNewFile,BufRead */.gnupg/options		setf gpg
800au BufNewFile,BufRead */.gnupg/gpg.conf		setf gpg
801au BufNewFile,BufRead */usr/*/gnupg/options.skel setf gpg
802
803" gnash(1) configuration files
804au BufNewFile,BufRead gnashrc,.gnashrc,gnashpluginrc,.gnashpluginrc setf gnash
805
806" Gitolite
807au BufNewFile,BufRead gitolite.conf		setf gitolite
808au BufNewFile,BufRead */gitolite-admin/conf/*	call s:StarSetf('gitolite')
809au BufNewFile,BufRead {,.}gitolite.rc,example.gitolite.rc	setf perl
810
811" Gnuplot scripts
812au BufNewFile,BufRead *.gpi			setf gnuplot
813
814" GrADS scripts
815au BufNewFile,BufRead *.gs			setf grads
816
817" Gretl
818au BufNewFile,BufRead *.gretl			setf gretl
819
820" Groovy
821au BufNewFile,BufRead *.groovy			setf groovy
822
823" GNU Server Pages
824au BufNewFile,BufRead *.gsp			setf gsp
825
826" Group file
827au 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
828
829" GTK RC
830au BufNewFile,BufRead .gtkrc,gtkrc		setf gtkrc
831
832" Haml
833au BufNewFile,BufRead *.haml			setf haml
834
835" Hamster Classic | Playground files
836au BufNewFile,BufRead *.hsc,*.hsm		setf hamster
837
838" Haskell
839au BufNewFile,BufRead *.hs,*.hs-boot		setf haskell
840au BufNewFile,BufRead *.lhs			setf lhaskell
841au BufNewFile,BufRead *.chs			setf chaskell
842
843" Haste
844au BufNewFile,BufRead *.ht			setf haste
845au BufNewFile,BufRead *.htpp			setf hastepreproc
846
847" Hercules
848au BufNewFile,BufRead *.vc,*.ev,*.rs,*.sum,*.errsum	setf hercules
849
850" HEX (Intel)
851au BufNewFile,BufRead *.hex,*.h32		setf hex
852
853" Tilde (must be before HTML)
854au BufNewFile,BufRead *.t.html			setf tilde
855
856" HTML (.shtml and .stm for server side)
857au BufNewFile,BufRead *.html,*.htm,*.shtml,*.stm  call s:FThtml()
858
859" Distinguish between HTML, XHTML and Django
860func! s:FThtml()
861  let n = 1
862  while n < 10 && n < line("$")
863    if getline(n) =~ '\<DTD\s\+XHTML\s'
864      setf xhtml
865      return
866    endif
867    if getline(n) =~ '{%\s*\(extends\|block\)\>'
868      setf htmldjango
869      return
870    endif
871    let n = n + 1
872  endwhile
873  setf html
874endfunc
875
876" HTML with Ruby - eRuby
877au BufNewFile,BufRead *.erb,*.rhtml		setf eruby
878
879" HTML with M4
880au BufNewFile,BufRead *.html.m4			setf htmlm4
881
882" HTML Cheetah template
883au BufNewFile,BufRead *.tmpl			setf htmlcheetah
884
885" Host config
886au BufNewFile,BufRead */etc/host.conf		setf hostconf
887
888" Hosts access
889au BufNewFile,BufRead */etc/hosts.allow,*/etc/hosts.deny  setf hostsaccess
890
891" Hyper Builder
892au BufNewFile,BufRead *.hb			setf hb
893
894" Httest
895au BufNewFile,BufRead *.htt,*.htb		setf httest
896
897" Icon
898au BufNewFile,BufRead *.icn			setf icon
899
900" IDL (Interface Description Language)
901au BufNewFile,BufRead *.idl			call s:FTidl()
902
903" Distinguish between standard IDL and MS-IDL
904func! s:FTidl()
905  let n = 1
906  while n < 50 && n < line("$")
907    if getline(n) =~ '^\s*import\s\+"\(unknwn\|objidl\)\.idl"'
908      setf msidl
909      return
910    endif
911    let n = n + 1
912  endwhile
913  setf idl
914endfunc
915
916" Microsoft IDL (Interface Description Language)  Also *.idl
917" MOF = WMI (Windows Management Instrumentation) Managed Object Format
918au BufNewFile,BufRead *.odl,*.mof		setf msidl
919
920" Icewm menu
921au BufNewFile,BufRead */.icewm/menu		setf icemenu
922
923" Indent profile (must come before IDL *.pro!)
924au BufNewFile,BufRead .indent.pro		setf indent
925au BufNewFile,BufRead indent.pro		call s:ProtoCheck('indent')
926
927" IDL (Interactive Data Language)
928au BufNewFile,BufRead *.pro			call s:ProtoCheck('idlang')
929
930" Distinguish between "default" and Cproto prototype file. */
931func! s:ProtoCheck(default)
932  " Cproto files have a comment in the first line and a function prototype in
933  " the second line, it always ends in ";".  Indent files may also have
934  " comments, thus we can't match comments to see the difference.
935  " IDL files can have a single ';' in the second line, require at least one
936  " chacter before the ';'.
937  if getline(2) =~ '.;$'
938    setf cpp
939  else
940    exe 'setf ' . a:default
941  endif
942endfunc
943
944
945" Indent RC
946au BufNewFile,BufRead indentrc			setf indent
947
948" Inform
949au BufNewFile,BufRead *.inf,*.INF		setf inform
950
951" Initng
952au BufNewFile,BufRead */etc/initng/*/*.i,*.ii	setf initng
953
954" Innovation Data Processing
955au BufRead,BufNewFile upstream.dat\c,upstream.*.dat\c,*.upstream.dat\c 	setf upstreamdat
956au BufRead,BufNewFile upstream.log\c,upstream.*.log\c,*.upstream.log\c 	setf upstreamlog
957au BufRead,BufNewFile upstreaminstall.log\c,upstreaminstall.*.log\c,*.upstreaminstall.log\c setf upstreaminstalllog
958au BufRead,BufNewFile usserver.log\c,usserver.*.log\c,*.usserver.log\c 	setf usserverlog
959au BufRead,BufNewFile usw2kagt.log\c,usw2kagt.*.log\c,*.usw2kagt.log\c 	setf usw2kagtlog
960
961" Ipfilter
962au BufNewFile,BufRead ipf.conf,ipf6.conf,ipf.rules	setf ipfilter
963
964" Informix 4GL (source - canonical, include file, I4GL+M4 preproc.)
965au BufNewFile,BufRead *.4gl,*.4gh,*.m4gl	setf fgl
966
967" .INI file for MSDOS
968au BufNewFile,BufRead *.ini			setf dosini
969
970" SysV Inittab
971au BufNewFile,BufRead inittab			setf inittab
972
973" Inno Setup
974au BufNewFile,BufRead *.iss			setf iss
975
976" J
977au BufNewFile,BufRead *.ijs			setf j
978
979" JAL
980au BufNewFile,BufRead *.jal,*.JAL		setf jal
981
982" Jam
983au BufNewFile,BufRead *.jpl,*.jpr		setf jam
984
985" Java
986au BufNewFile,BufRead *.java,*.jav		setf java
987
988" JavaCC
989au BufNewFile,BufRead *.jj,*.jjt		setf javacc
990
991" JavaScript, ECMAScript
992au BufNewFile,BufRead *.js,*.javascript,*.es,*.jsx,*.json   setf javascript
993
994" Java Server Pages
995au BufNewFile,BufRead *.jsp			setf jsp
996
997" Java Properties resource file (note: doesn't catch font.properties.pl)
998au BufNewFile,BufRead *.properties,*.properties_??,*.properties_??_??	setf jproperties
999au BufNewFile,BufRead *.properties_??_??_*	call s:StarSetf('jproperties')
1000
1001" Jess
1002au BufNewFile,BufRead *.clp			setf jess
1003
1004" Jgraph
1005au BufNewFile,BufRead *.jgr			setf jgraph
1006
1007" Jovial
1008au BufNewFile,BufRead *.jov,*.j73,*.jovial	setf jovial
1009
1010" Kixtart
1011au BufNewFile,BufRead *.kix			setf kix
1012
1013" Kimwitu[++]
1014au BufNewFile,BufRead *.k			setf kwt
1015
1016" KDE script
1017au BufNewFile,BufRead *.ks			setf kscript
1018
1019" Kconfig
1020au BufNewFile,BufRead Kconfig,Kconfig.debug	setf kconfig
1021
1022" Lace (ISE)
1023au BufNewFile,BufRead *.ace,*.ACE		setf lace
1024
1025" Latte
1026au BufNewFile,BufRead *.latte,*.lte		setf latte
1027
1028" Limits
1029au BufNewFile,BufRead */etc/limits,*/etc/*limits.conf,*/etc/*limits.d/*.conf	setf limits
1030
1031" LambdaProlog (*.mod too, see Modsim)
1032au BufNewFile,BufRead *.sig			setf lprolog
1033
1034" LDAP LDIF
1035au BufNewFile,BufRead *.ldif			setf ldif
1036
1037" Ld loader
1038au BufNewFile,BufRead *.ld			setf ld
1039
1040" Lex
1041au BufNewFile,BufRead *.lex,*.l,*.lxx,*.l++	setf lex
1042
1043" Libao
1044au BufNewFile,BufRead */etc/libao.conf,*/.libao	setf libao
1045
1046" Libsensors
1047au BufNewFile,BufRead */etc/sensors.conf,*/etc/sensors3.conf	setf sensors
1048
1049" LFTP
1050au BufNewFile,BufRead lftp.conf,.lftprc,*lftp/rc	setf lftp
1051
1052" Lifelines (or Lex for C++!)
1053au BufNewFile,BufRead *.ll			setf lifelines
1054
1055" Lilo: Linux loader
1056au BufNewFile,BufRead lilo.conf			setf lilo
1057
1058" Lisp (*.el = ELisp, *.cl = Common Lisp, *.jl = librep Lisp)
1059if has("fname_case")
1060  au BufNewFile,BufRead *.lsp,*.lisp,*.el,*.cl,*.jl,*.L,.emacs,.sawfishrc setf lisp
1061else
1062  au BufNewFile,BufRead *.lsp,*.lisp,*.el,*.cl,*.jl,.emacs,.sawfishrc setf lisp
1063endif
1064
1065" SBCL implementation of Common Lisp
1066au BufNewFile,BufRead sbclrc,.sbclrc		setf lisp
1067
1068" Liquid
1069au BufNewFile,BufRead *.liquid			setf liquid
1070
1071" Lite
1072au BufNewFile,BufRead *.lite,*.lt		setf lite
1073
1074" LiteStep RC files
1075au BufNewFile,BufRead */LiteStep/*/*.rc		setf litestep
1076
1077" Login access
1078au BufNewFile,BufRead */etc/login.access	setf loginaccess
1079
1080" Login defs
1081au BufNewFile,BufRead */etc/login.defs		setf logindefs
1082
1083" Logtalk
1084au BufNewFile,BufRead *.lgt			setf logtalk
1085
1086" LOTOS
1087au BufNewFile,BufRead *.lot,*.lotos		setf lotos
1088
1089" Lout (also: *.lt)
1090au BufNewFile,BufRead *.lou,*.lout		setf lout
1091
1092" Lua
1093au BufNewFile,BufRead *.lua			setf lua
1094
1095" Linden Scripting Language (Second Life)
1096au BufNewFile,BufRead *.lsl			setf lsl
1097
1098" Lynx style file (or LotusScript!)
1099au BufNewFile,BufRead *.lss			setf lss
1100
1101" M4
1102au BufNewFile,BufRead *.m4
1103	\ if expand("<afile>") !~? 'html.m4$\|fvwm2rc' | setf m4 | endif
1104
1105" MaGic Point
1106au BufNewFile,BufRead *.mgp			setf mgp
1107
1108" Mail (for Elm, trn, mutt, muttng, rn, slrn)
1109au 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
1110
1111" Mail aliases
1112au BufNewFile,BufRead */etc/mail/aliases,*/etc/aliases	setf mailaliases
1113
1114" Mailcap configuration file
1115au BufNewFile,BufRead .mailcap,mailcap		setf mailcap
1116
1117" Makefile
1118au BufNewFile,BufRead *[mM]akefile,*.mk,*.mak,*.dsp setf make
1119
1120" MakeIndex
1121au BufNewFile,BufRead *.ist,*.mst		setf ist
1122
1123" Mallard
1124au BufNewFile,BufRead *.page			setf mallard
1125
1126" Manpage
1127au BufNewFile,BufRead *.man			setf man
1128
1129" Man config
1130au BufNewFile,BufRead */etc/man.conf,man.config	setf manconf
1131
1132" Maple V
1133au BufNewFile,BufRead *.mv,*.mpl,*.mws		setf maple
1134
1135" Map (UMN mapserver config file)
1136au BufNewFile,BufRead *.map			setf map
1137
1138" Markdown
1139au BufNewFile,BufRead *.markdown,*.mdown,*.mkd,*.mkdn,*.mdwn,README.md  setf markdown
1140
1141" Mason
1142au BufNewFile,BufRead *.mason,*.mhtml		setf mason
1143
1144" Matlab or Objective C
1145au BufNewFile,BufRead *.m			call s:FTm()
1146
1147func! s:FTm()
1148  let n = 1
1149  while n < 10
1150    let line = getline(n)
1151    if line =~ '^\s*\(#\s*\(include\|import\)\>\|/\*\|//\)'
1152      setf objc
1153      return
1154    endif
1155    if line =~ '^\s*%'
1156      setf matlab
1157      return
1158    endif
1159    if line =~ '^\s*(\*'
1160      setf mma
1161      return
1162    endif
1163    let n = n + 1
1164  endwhile
1165  if exists("g:filetype_m")
1166    exe "setf " . g:filetype_m
1167  else
1168    setf matlab
1169  endif
1170endfunc
1171
1172" Mathematica notebook
1173au BufNewFile,BufRead *.nb			setf mma
1174
1175" Maya Extension Language
1176au BufNewFile,BufRead *.mel			setf mel
1177
1178" Mercurial (hg) commit file
1179au BufNewFile,BufRead hg-editor-*.txt		setf hgcommit
1180
1181" Mercurial config (looks like generic config file)
1182au BufNewFile,BufRead *.hgrc,*hgrc		setf cfg
1183
1184" Messages (logs mostly)
1185au 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
1186
1187" Metafont
1188au BufNewFile,BufRead *.mf			setf mf
1189
1190" MetaPost
1191au BufNewFile,BufRead *.mp			setf mp
1192
1193" MGL
1194au BufNewFile,BufRead *.mgl			setf mgl
1195
1196" MIX - Knuth assembly
1197au BufNewFile,BufRead *.mix,*.mixal		setf mix
1198
1199" MMIX or VMS makefile
1200au BufNewFile,BufRead *.mms			call s:FTmms()
1201
1202" Symbian meta-makefile definition (MMP)
1203au BufNewFile,BufRead *.mmp			setf mmp
1204
1205func! s:FTmms()
1206  let n = 1
1207  while n < 10
1208    let line = getline(n)
1209    if line =~ '^\s*\(%\|//\)' || line =~ '^\*'
1210      setf mmix
1211      return
1212    endif
1213    if line =~ '^\s*#'
1214      setf make
1215      return
1216    endif
1217    let n = n + 1
1218  endwhile
1219  setf mmix
1220endfunc
1221
1222
1223" Modsim III (or LambdaProlog)
1224au BufNewFile,BufRead *.mod
1225	\ if getline(1) =~ '\<module\>' |
1226	\   setf lprolog |
1227	\ else |
1228	\   setf modsim3 |
1229	\ endif
1230
1231" Modula 2
1232au BufNewFile,BufRead *.m2,*.DEF,*.MOD,*.md,*.mi setf modula2
1233
1234" Modula 3 (.m3, .i3, .mg, .ig)
1235au BufNewFile,BufRead *.[mi][3g]		setf modula3
1236
1237" Monk
1238au BufNewFile,BufRead *.isc,*.monk,*.ssc,*.tsc	setf monk
1239
1240" MOO
1241au BufNewFile,BufRead *.moo			setf moo
1242
1243" Modconf
1244au BufNewFile,BufRead */etc/modules.conf,*/etc/modules,*/etc/conf.modules setf modconf
1245
1246" Mplayer config
1247au BufNewFile,BufRead mplayer.conf,*/.mplayer/config	setf mplayerconf
1248
1249" Moterola S record
1250au BufNewFile,BufRead *.s19,*.s28,*.s37		setf srec
1251
1252" Mrxvtrc
1253au BufNewFile,BufRead mrxvtrc,.mrxvtrc		setf mrxvtrc
1254
1255" Msql
1256au BufNewFile,BufRead *.msql			setf msql
1257
1258" Mysql
1259au BufNewFile,BufRead *.mysql			setf mysql
1260
1261" Mutt setup files (must be before catch *.rc)
1262au BufNewFile,BufRead */etc/Muttrc.d/*		call s:StarSetf('muttrc')
1263
1264" M$ Resource files
1265au BufNewFile,BufRead *.rc,*.rch		setf rc
1266
1267" MuPAD source
1268au BufRead,BufNewFile *.mu			setf mupad
1269
1270" Mush
1271au BufNewFile,BufRead *.mush			setf mush
1272
1273" Mutt setup file (also for Muttng)
1274au BufNewFile,BufRead Mutt{ng,}rc		setf muttrc
1275
1276" Nano
1277au BufNewFile,BufRead */etc/nanorc,.nanorc	setf nanorc
1278
1279" Nastran input/DMAP
1280"au BufNewFile,BufRead *.dat			setf nastran
1281
1282" Natural
1283au BufNewFile,BufRead *.NS[ACGLMNPS]		setf natural
1284
1285" Netrc
1286au BufNewFile,BufRead .netrc			setf netrc
1287
1288" Ninja file
1289au BufNewFile,BufRead *.ninja			setf ninja
1290
1291" Novell netware batch files
1292au BufNewFile,BufRead *.ncf			setf ncf
1293
1294" Nroff/Troff (*.ms and *.t are checked below)
1295au BufNewFile,BufRead *.me
1296	\ if expand("<afile>") != "read.me" && expand("<afile>") != "click.me" |
1297	\   setf nroff |
1298	\ endif
1299au BufNewFile,BufRead *.tr,*.nr,*.roff,*.tmac,*.mom	setf nroff
1300au BufNewFile,BufRead *.[1-9]			call s:FTnroff()
1301
1302" This function checks if one of the first five lines start with a dot.  In
1303" that case it is probably an nroff file: 'filetype' is set and 1 is returned.
1304func! s:FTnroff()
1305  if getline(1)[0] . getline(2)[0] . getline(3)[0] . getline(4)[0] . getline(5)[0] =~ '\.'
1306    setf nroff
1307    return 1
1308  endif
1309  return 0
1310endfunc
1311
1312" Nroff or Objective C++
1313au BufNewFile,BufRead *.mm			call s:FTmm()
1314
1315func! s:FTmm()
1316  let n = 1
1317  while n < 10
1318    let line = getline(n)
1319    if line =~ '^\s*\(#\s*\(include\|import\)\>\|/\*\)'
1320      setf objcpp
1321      return
1322    endif
1323    let n = n + 1
1324  endwhile
1325  setf nroff
1326endfunc
1327
1328" Not Quite C
1329au BufNewFile,BufRead *.nqc			setf nqc
1330
1331" NSIS
1332au BufNewFile,BufRead *.nsi,*.nsh		setf nsis
1333
1334" OCAML
1335au BufNewFile,BufRead *.ml,*.mli,*.mll,*.mly,.ocamlinit	setf ocaml
1336
1337" Occam
1338au BufNewFile,BufRead *.occ			setf occam
1339
1340" Omnimark
1341au BufNewFile,BufRead *.xom,*.xin		setf omnimark
1342
1343" OpenROAD
1344au BufNewFile,BufRead *.or			setf openroad
1345
1346" OPL
1347au BufNewFile,BufRead *.[Oo][Pp][Ll]		setf opl
1348
1349" Oracle config file
1350au BufNewFile,BufRead *.ora			setf ora
1351
1352" Packet filter conf
1353au BufNewFile,BufRead pf.conf			setf pf
1354
1355" Pam conf
1356au BufNewFile,BufRead */etc/pam.conf		setf pamconf
1357
1358" PApp
1359au BufNewFile,BufRead *.papp,*.pxml,*.pxsl	setf papp
1360
1361" Password file
1362au 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
1363
1364" Pascal (also *.p)
1365au BufNewFile,BufRead *.pas			setf pascal
1366
1367" Delphi project file
1368au BufNewFile,BufRead *.dpr			setf pascal
1369
1370" PDF
1371au BufNewFile,BufRead *.pdf			setf pdf
1372
1373" Perl
1374if has("fname_case")
1375  au BufNewFile,BufRead *.pl,*.PL		call s:FTpl()
1376else
1377  au BufNewFile,BufRead *.pl			call s:FTpl()
1378endif
1379au BufNewFile,BufRead *.plx,*.al		setf perl
1380au BufNewFile,BufRead *.p6,*.pm6		setf perl6
1381
1382func! s:FTpl()
1383  if exists("g:filetype_pl")
1384    exe "setf " . g:filetype_pl
1385  else
1386    " recognize Prolog by specific text in the first non-empty line
1387    " require a blank after the '%' because Perl uses "%list" and "%translate"
1388    let l = getline(nextnonblank(1))
1389    if l =~ '\<prolog\>' || l =~ '^\s*\(%\+\(\s\|$\)\|/\*\)' || l =~ ':-'
1390      setf prolog
1391    else
1392      setf perl
1393    endif
1394  endif
1395endfunc
1396
1397" Perl, XPM or XPM2
1398au BufNewFile,BufRead *.pm
1399	\ if getline(1) =~ "XPM2" |
1400	\   setf xpm2 |
1401	\ elseif getline(1) =~ "XPM" |
1402	\   setf xpm |
1403	\ else |
1404	\   setf perl |
1405	\ endif
1406
1407" Perl POD
1408au BufNewFile,BufRead *.pod			setf pod
1409
1410" Php, php3, php4, etc.
1411" Also Phtml (was used for PHP 2 in the past)
1412" Also .ctp for Cake template file
1413au BufNewFile,BufRead *.php,*.php\d,*.phtml,*.ctp	setf php
1414
1415" Pike
1416au BufNewFile,BufRead *.pike,*.lpc,*.ulpc,*.pmod setf pike
1417
1418" Pinfo config
1419au BufNewFile,BufRead */etc/pinforc,*/.pinforc	setf pinfo
1420
1421" Palm Resource compiler
1422au BufNewFile,BufRead *.rcp			setf pilrc
1423
1424" Pine config
1425au BufNewFile,BufRead .pinerc,pinerc,.pinercex,pinercex		setf pine
1426
1427" PL/1, PL/I
1428au BufNewFile,BufRead *.pli,*.pl1		setf pli
1429
1430" PL/M (also: *.inp)
1431au BufNewFile,BufRead *.plm,*.p36,*.pac		setf plm
1432
1433" PL/SQL
1434au BufNewFile,BufRead *.pls,*.plsql		setf plsql
1435
1436" PLP
1437au BufNewFile,BufRead *.plp			setf plp
1438
1439" PO and PO template (GNU gettext)
1440au BufNewFile,BufRead *.po,*.pot		setf po
1441
1442" Postfix main config
1443au BufNewFile,BufRead main.cf			setf pfmain
1444
1445" PostScript (+ font files, encapsulated PostScript, Adobe Illustrator)
1446au BufNewFile,BufRead *.ps,*.pfa,*.afm,*.eps,*.epsf,*.epsi,*.ai	  setf postscr
1447
1448" PostScript Printer Description
1449au BufNewFile,BufRead *.ppd			setf ppd
1450
1451" Povray
1452au BufNewFile,BufRead *.pov			setf pov
1453
1454" Povray configuration
1455au BufNewFile,BufRead .povrayrc			setf povini
1456
1457" Povray, PHP or assembly
1458au BufNewFile,BufRead *.inc			call s:FTinc()
1459
1460func! s:FTinc()
1461  if exists("g:filetype_inc")
1462    exe "setf " . g:filetype_inc
1463  else
1464    let lines = getline(1).getline(2).getline(3)
1465    if lines =~? "perlscript"
1466      setf aspperl
1467    elseif lines =~ "<%"
1468      setf aspvbs
1469    elseif lines =~ "<?"
1470      setf php
1471    else
1472      call s:FTasmsyntax()
1473      if exists("b:asmsyntax")
1474	exe "setf " . fnameescape(b:asmsyntax)
1475      else
1476	setf pov
1477      endif
1478    endif
1479  endif
1480endfunc
1481
1482" Printcap and Termcap
1483au BufNewFile,BufRead *printcap
1484	\ let b:ptcap_type = "print" | setf ptcap
1485au BufNewFile,BufRead *termcap
1486	\ let b:ptcap_type = "term" | setf ptcap
1487
1488" PCCTS / ANTRL
1489"au BufNewFile,BufRead *.g			setf antrl
1490au BufNewFile,BufRead *.g			setf pccts
1491
1492" PPWizard
1493au BufNewFile,BufRead *.it,*.ih			setf ppwiz
1494
1495" Obj 3D file format
1496" TODO: is there a way to avoid MS-Windows Object files?
1497au BufNewFile,BufRead *.obj			setf obj
1498
1499" Oracle Pro*C/C++
1500au BufNewFile,BufRead *.pc			setf proc
1501
1502" Privoxy actions file
1503au BufNewFile,BufRead *.action			setf privoxy
1504
1505" Procmail
1506au BufNewFile,BufRead .procmail,.procmailrc	setf procmail
1507
1508" Progress or CWEB
1509au BufNewFile,BufRead *.w			call s:FTprogress_cweb()
1510
1511func! s:FTprogress_cweb()
1512  if exists("g:filetype_w")
1513    exe "setf " . g:filetype_w
1514    return
1515  endif
1516  if getline(1) =~ '&ANALYZE' || getline(3) =~ '&GLOBAL-DEFINE'
1517    setf progress
1518  else
1519    setf cweb
1520  endif
1521endfunc
1522
1523" Progress or assembly
1524au BufNewFile,BufRead *.i			call s:FTprogress_asm()
1525
1526func! s:FTprogress_asm()
1527  if exists("g:filetype_i")
1528    exe "setf " . g:filetype_i
1529    return
1530  endif
1531  " This function checks for an assembly comment the first ten lines.
1532  " If not found, assume Progress.
1533  let lnum = 1
1534  while lnum <= 10 && lnum < line('$')
1535    let line = getline(lnum)
1536    if line =~ '^\s*;' || line =~ '^\*'
1537      call s:FTasm()
1538      return
1539    elseif line !~ '^\s*$' || line =~ '^/\*'
1540      " Not an empty line: Doesn't look like valid assembly code.
1541      " Or it looks like a Progress /* comment
1542      break
1543    endif
1544    let lnum = lnum + 1
1545  endw
1546  setf progress
1547endfunc
1548
1549" Progress or Pascal
1550au BufNewFile,BufRead *.p			call s:FTprogress_pascal()
1551
1552func! s:FTprogress_pascal()
1553  if exists("g:filetype_p")
1554    exe "setf " . g:filetype_p
1555    return
1556  endif
1557  " This function checks for valid Pascal syntax in the first ten lines.
1558  " Look for either an opening comment or a program start.
1559  " If not found, assume Progress.
1560  let lnum = 1
1561  while lnum <= 10 && lnum < line('$')
1562    let line = getline(lnum)
1563    if line =~ '^\s*\(program\|unit\|procedure\|function\|const\|type\|var\)\>'
1564	\ || line =~ '^\s*{' || line =~ '^\s*(\*'
1565      setf pascal
1566      return
1567    elseif line !~ '^\s*$' || line =~ '^/\*'
1568      " Not an empty line: Doesn't look like valid Pascal code.
1569      " Or it looks like a Progress /* comment
1570      break
1571    endif
1572    let lnum = lnum + 1
1573  endw
1574  setf progress
1575endfunc
1576
1577
1578" Software Distributor Product Specification File (POSIX 1387.2-1995)
1579au BufNewFile,BufRead *.psf			setf psf
1580au BufNewFile,BufRead INDEX,INFO
1581	\ if getline(1) =~ '^\s*\(distribution\|installed_software\|root\|bundle\|product\)\s*$' |
1582	\   setf psf |
1583	\ endif
1584
1585" Prolog
1586au BufNewFile,BufRead *.pdb			setf prolog
1587
1588" Promela
1589au BufNewFile,BufRead *.pml			setf promela
1590
1591" Google protocol buffers
1592au BufNewFile,BufRead *.proto			setf proto
1593
1594" Protocols
1595au BufNewFile,BufRead */etc/protocols		setf protocols
1596
1597" Pyrex
1598au BufNewFile,BufRead *.pyx,*.pxd		setf pyrex
1599
1600" Python
1601au BufNewFile,BufRead *.py,*.pyw		setf python
1602
1603" Quixote (Python-based web framework)
1604au BufNewFile,BufRead *.ptl			setf python
1605
1606" Radiance
1607au BufNewFile,BufRead *.rad,*.mat		setf radiance
1608
1609" Ratpoison config/command files
1610au BufNewFile,BufRead .ratpoisonrc,ratpoisonrc	setf ratpoison
1611
1612" RCS file
1613au BufNewFile,BufRead *\,v			setf rcs
1614
1615" Readline
1616au BufNewFile,BufRead .inputrc,inputrc		setf readline
1617
1618" Registry for MS-Windows
1619au BufNewFile,BufRead *.reg
1620	\ if getline(1) =~? '^REGEDIT[0-9]*\s*$\|^Windows Registry Editor Version \d*\.\d*\s*$' | setf registry | endif
1621
1622" Renderman Interface Bytestream
1623au BufNewFile,BufRead *.rib			setf rib
1624
1625" Rexx
1626au BufNewFile,BufRead *.rex,*.orx,*.rxo,*.rxj,*.jrexx,*.rexxj,*.rexx,*.testGroup,*.testUnit	setf rexx
1627
1628" R (Splus)
1629if has("fname_case")
1630  au BufNewFile,BufRead *.s,*.S			setf r
1631else
1632  au BufNewFile,BufRead *.s			setf r
1633endif
1634
1635" R Help file
1636if has("fname_case")
1637  au BufNewFile,BufRead *.rd,*.Rd		setf rhelp
1638else
1639  au BufNewFile,BufRead *.rd			setf rhelp
1640endif
1641
1642" R noweb file
1643if has("fname_case")
1644  au BufNewFile,BufRead *.Rnw,*.rnw,*.Snw,*.snw		setf rnoweb
1645else
1646  au BufNewFile,BufRead *.rnw,*.snw			setf rnoweb
1647endif
1648
1649" Rexx, Rebol or R
1650au BufNewFile,BufRead *.r,*.R			call s:FTr()
1651
1652func! s:FTr()
1653  let max = line("$") > 50 ? 50 : line("$")
1654
1655  for n in range(1, max)
1656    " Rebol is easy to recognize, check for that first
1657    if getline(n) =~? '\<REBOL\>'
1658      setf rebol
1659      return
1660    endif
1661  endfor
1662
1663  for n in range(1, max)
1664    " R has # comments
1665    if getline(n) =~ '^\s*#'
1666      setf r
1667      return
1668    endif
1669    " Rexx has /* comments */
1670    if getline(n) =~ '^\s*/\*'
1671      setf rexx
1672      return
1673    endif
1674  endfor
1675
1676  " Nothing recognized, use user default or assume Rexx
1677  if exists("g:filetype_r")
1678    exe "setf " . g:filetype_r
1679  else
1680    " Rexx used to be the default, but R appears to be much more popular.
1681    setf r
1682  endif
1683endfunc
1684
1685" Remind
1686au BufNewFile,BufRead .reminders,*.remind,*.rem		setf remind
1687
1688" Resolv.conf
1689au BufNewFile,BufRead resolv.conf		setf resolv
1690
1691" Relax NG Compact
1692au BufNewFile,BufRead *.rnc			setf rnc
1693
1694" Relax NG XML
1695au BufNewFile,BufRead *.rng			setf rng
1696
1697" RPL/2
1698au BufNewFile,BufRead *.rpl			setf rpl
1699
1700" Robots.txt
1701au BufNewFile,BufRead robots.txt		setf robots
1702
1703" Rpcgen
1704au BufNewFile,BufRead *.x			setf rpcgen
1705
1706" reStructuredText Documentation Format
1707au BufNewFile,BufRead *.rst			setf rst
1708
1709" RTF
1710au BufNewFile,BufRead *.rtf			setf rtf
1711
1712" Interactive Ruby shell
1713au BufNewFile,BufRead .irbrc,irbrc		setf ruby
1714
1715" Ruby
1716au BufNewFile,BufRead *.rb,*.rbw		setf ruby
1717
1718" RubyGems
1719au BufNewFile,BufRead *.gemspec			setf ruby
1720
1721" Rackup
1722au BufNewFile,BufRead *.ru			setf ruby
1723
1724" Bundler
1725au BufNewFile,BufRead Gemfile			setf ruby
1726
1727" Ruby on Rails
1728au BufNewFile,BufRead *.builder,*.rxml,*.rjs	setf ruby
1729
1730" Rantfile and Rakefile is like Ruby
1731au BufNewFile,BufRead [rR]antfile,*.rant,[rR]akefile,*.rake	setf ruby
1732
1733" S-lang (or shader language, or SmallLisp)
1734au BufNewFile,BufRead *.sl			setf slang
1735
1736" Samba config
1737au BufNewFile,BufRead smb.conf			setf samba
1738
1739" SAS script
1740au BufNewFile,BufRead *.sas			setf sas
1741
1742" Sass
1743au BufNewFile,BufRead *.sass			setf sass
1744
1745" Sather
1746au BufNewFile,BufRead *.sa			setf sather
1747
1748" Scilab
1749au BufNewFile,BufRead *.sci,*.sce		setf scilab
1750
1751" SCSS
1752au BufNewFile,BufRead *.scss			setf scss
1753
1754" SD: Streaming Descriptors
1755au BufNewFile,BufRead *.sd			setf sd
1756
1757" SDL
1758au BufNewFile,BufRead *.sdl,*.pr		setf sdl
1759
1760" sed
1761au BufNewFile,BufRead *.sed			setf sed
1762
1763" Sieve (RFC 3028)
1764au BufNewFile,BufRead *.siv			setf sieve
1765
1766" Sendmail
1767au BufNewFile,BufRead sendmail.cf		setf sm
1768
1769" Sendmail .mc files are actually m4.  Could also be MS Message text file.
1770au BufNewFile,BufRead *.mc			call s:McSetf()
1771
1772func! s:McSetf()
1773  " Rely on the file to start with a comment.
1774  " MS message text files use ';', Sendmail files use '#' or 'dnl'
1775  for lnum in range(1, min([line("$"), 20]))
1776    let line = getline(lnum)
1777    if line =~ '^\s*\(#\|dnl\)'
1778      setf m4  " Sendmail .mc file
1779      return
1780    elseif line =~ '^\s*;'
1781      setf msmessages  " MS Message text file
1782      return
1783    endif
1784  endfor
1785  setf m4  " Default: Sendmail .mc file
1786endfunc
1787
1788" Services
1789au BufNewFile,BufRead */etc/services		setf services
1790
1791" Service Location config
1792au BufNewFile,BufRead */etc/slp.conf		setf slpconf
1793
1794" Service Location registration
1795au BufNewFile,BufRead */etc/slp.reg		setf slpreg
1796
1797" Service Location SPI
1798au BufNewFile,BufRead */etc/slp.spi		setf slpspi
1799
1800" Setserial config
1801au BufNewFile,BufRead */etc/serial.conf		setf setserial
1802
1803" SGML
1804au BufNewFile,BufRead *.sgm,*.sgml
1805	\ if getline(1).getline(2).getline(3).getline(4).getline(5) =~? 'linuxdoc' |
1806	\   setf sgmllnx |
1807	\ elseif getline(1) =~ '<!DOCTYPE.*DocBook' || getline(2) =~ '<!DOCTYPE.*DocBook' |
1808	\   let b:docbk_type = "sgml" |
1809	\   let b:docbk_ver = 4 |
1810	\   setf docbk |
1811	\ else |
1812	\   setf sgml |
1813	\ endif
1814
1815" SGMLDECL
1816au BufNewFile,BufRead *.decl,*.dcl,*.dec
1817	\ if getline(1).getline(2).getline(3) =~? '^<!SGML' |
1818	\    setf sgmldecl |
1819	\ endif
1820
1821" SGML catalog file
1822au BufNewFile,BufRead catalog			setf catalog
1823au BufNewFile,BufRead sgml.catalog*		call s:StarSetf('catalog')
1824
1825" Shell scripts (sh, ksh, bash, bash2, csh); Allow .profile_foo etc.
1826" Gentoo ebuilds are actually bash scripts
1827au BufNewFile,BufRead .bashrc*,bashrc,bash.bashrc,.bash_profile*,.bash_logout*,*.bash,*.ebuild call SetFileTypeSH("bash")
1828au BufNewFile,BufRead .kshrc*,*.ksh call SetFileTypeSH("ksh")
1829au BufNewFile,BufRead */etc/profile,.profile*,*.sh,*.env call SetFileTypeSH(getline(1))
1830
1831" Also called from scripts.vim.
1832func! SetFileTypeSH(name)
1833  if expand("<amatch>") =~ g:ft_ignore_pat
1834    return
1835  endif
1836  if a:name =~ '\<csh\>'
1837    " Some .sh scripts contain #!/bin/csh.
1838    call SetFileTypeShell("csh")
1839    return
1840  elseif a:name =~ '\<tcsh\>'
1841    " Some .sh scripts contain #!/bin/tcsh.
1842    call SetFileTypeShell("tcsh")
1843    return
1844  elseif a:name =~ '\<zsh\>'
1845    " Some .sh scripts contain #!/bin/zsh.
1846    call SetFileTypeShell("zsh")
1847    return
1848  elseif a:name =~ '\<ksh\>'
1849    let b:is_kornshell = 1
1850    if exists("b:is_bash")
1851      unlet b:is_bash
1852    endif
1853    if exists("b:is_sh")
1854      unlet b:is_sh
1855    endif
1856  elseif exists("g:bash_is_sh") || a:name =~ '\<bash\>' || a:name =~ '\<bash2\>'
1857    let b:is_bash = 1
1858    if exists("b:is_kornshell")
1859      unlet b:is_kornshell
1860    endif
1861    if exists("b:is_sh")
1862      unlet b:is_sh
1863    endif
1864  elseif a:name =~ '\<sh\>'
1865    let b:is_sh = 1
1866    if exists("b:is_kornshell")
1867      unlet b:is_kornshell
1868    endif
1869    if exists("b:is_bash")
1870      unlet b:is_bash
1871    endif
1872  endif
1873  call SetFileTypeShell("sh")
1874endfunc
1875
1876" For shell-like file types, check for an "exec" command hidden in a comment,
1877" as used for Tcl.
1878" Also called from scripts.vim, thus can't be local to this script.
1879func! SetFileTypeShell(name)
1880  if expand("<amatch>") =~ g:ft_ignore_pat
1881    return
1882  endif
1883  let l = 2
1884  while l < 20 && l < line("$") && getline(l) =~ '^\s*\(#\|$\)'
1885    " Skip empty and comment lines.
1886    let l = l + 1
1887  endwhile
1888  if l < line("$") && getline(l) =~ '\s*exec\s' && getline(l - 1) =~ '^\s*#.*\\$'
1889    " Found an "exec" line after a comment with continuation
1890    let n = substitute(getline(l),'\s*exec\s\+\([^ ]*/\)\=', '', '')
1891    if n =~ '\<tclsh\|\<wish'
1892      setf tcl
1893      return
1894    endif
1895  endif
1896  exe "setf " . a:name
1897endfunc
1898
1899" tcsh scripts
1900au BufNewFile,BufRead .tcshrc*,*.tcsh,tcsh.tcshrc,tcsh.login	call SetFileTypeShell("tcsh")
1901
1902" csh scripts, but might also be tcsh scripts (on some systems csh is tcsh)
1903au BufNewFile,BufRead .login*,.cshrc*,csh.cshrc,csh.login,csh.logout,*.csh,.alias  call s:CSH()
1904
1905func! s:CSH()
1906  if exists("g:filetype_csh")
1907    call SetFileTypeShell(g:filetype_csh)
1908  elseif &shell =~ "tcsh"
1909    call SetFileTypeShell("tcsh")
1910  else
1911    call SetFileTypeShell("csh")
1912  endif
1913endfunc
1914
1915" Z-Shell script
1916au BufNewFile,BufRead .zprofile,*/etc/zprofile,.zfbfmarks  setf zsh
1917au BufNewFile,BufRead .zsh*,.zlog*,.zcompdump*  call s:StarSetf('zsh')
1918au BufNewFile,BufRead *.zsh			setf zsh
1919
1920" Scheme
1921au BufNewFile,BufRead *.scm,*.ss,*.rkt		setf scheme
1922
1923" Screen RC
1924au BufNewFile,BufRead .screenrc,screenrc	setf screen
1925
1926" Simula
1927au BufNewFile,BufRead *.sim			setf simula
1928
1929" SINDA
1930au BufNewFile,BufRead *.sin,*.s85		setf sinda
1931
1932" SiSU
1933au BufNewFile,BufRead *.sst,*.ssm,*.ssi,*.-sst,*._sst setf sisu
1934au BufNewFile,BufRead *.sst.meta,*.-sst.meta,*._sst.meta setf sisu
1935
1936" SKILL
1937au BufNewFile,BufRead *.il,*.ils,*.cdf		setf skill
1938
1939" SLRN
1940au BufNewFile,BufRead .slrnrc			setf slrnrc
1941au BufNewFile,BufRead *.score			setf slrnsc
1942
1943" Smalltalk (and TeX)
1944au BufNewFile,BufRead *.st			setf st
1945au BufNewFile,BufRead *.cls
1946	\ if getline(1) =~ '^%' |
1947	\  setf tex |
1948	\ elseif getline(1)[0] == '#' && getline(1) =~ 'rexx' |
1949	\  setf rexx |
1950	\ else |
1951	\  setf st |
1952	\ endif
1953
1954" Smarty templates
1955au BufNewFile,BufRead *.tpl			setf smarty
1956
1957" SMIL or XML
1958au BufNewFile,BufRead *.smil
1959	\ if getline(1) =~ '<?\s*xml.*?>' |
1960	\   setf xml |
1961	\ else |
1962	\   setf smil |
1963	\ endif
1964
1965" SMIL or SNMP MIB file
1966au BufNewFile,BufRead *.smi
1967	\ if getline(1) =~ '\<smil\>' |
1968	\   setf smil |
1969	\ else |
1970	\   setf mib |
1971	\ endif
1972
1973" SMITH
1974au BufNewFile,BufRead *.smt,*.smith		setf smith
1975
1976" Snobol4 and spitbol
1977au BufNewFile,BufRead *.sno,*.spt		setf snobol4
1978
1979" SNMP MIB files
1980au BufNewFile,BufRead *.mib,*.my		setf mib
1981
1982" Snort Configuration
1983au BufNewFile,BufRead *.hog,snort.conf,vision.conf	setf hog
1984au BufNewFile,BufRead *.rules			call s:FTRules()
1985
1986let s:ft_rules_udev_rules_pattern = '^\s*\cudev_rules\s*=\s*"\([^"]\{-1,}\)/*".*'
1987func! s:FTRules()
1988  let path = expand('<amatch>:p')
1989  if path =~ '^/\(etc/udev/\%(rules\.d/\)\=.*\.rules\|lib/udev/\%(rules\.d/\)\=.*\.rules\)$'
1990    setf udevrules
1991    return
1992  endif
1993  if path =~ '^/etc/ufw/'
1994    setf conf  " Better than hog
1995    return
1996  endif
1997  try
1998    let config_lines = readfile('/etc/udev/udev.conf')
1999  catch /^Vim\%((\a\+)\)\=:E484/
2000    setf hog
2001    return
2002  endtry
2003  let dir = expand('<amatch>:p:h')
2004  for line in config_lines
2005    if line =~ s:ft_rules_udev_rules_pattern
2006      let udev_rules = substitute(line, s:ft_rules_udev_rules_pattern, '\1', "")
2007      if dir == udev_rules
2008        setf udevrules
2009      endif
2010      break
2011    endif
2012  endfor
2013  setf hog
2014endfunc
2015
2016
2017" Spec (Linux RPM)
2018au BufNewFile,BufRead *.spec			setf spec
2019
2020" Speedup (AspenTech plant simulator)
2021au BufNewFile,BufRead *.speedup,*.spdata,*.spd	setf spup
2022
2023" Slice
2024au BufNewFile,BufRead *.ice			setf slice
2025
2026" Spice
2027au BufNewFile,BufRead *.sp,*.spice		setf spice
2028
2029" Spyce
2030au BufNewFile,BufRead *.spy,*.spi		setf spyce
2031
2032" Squid
2033au BufNewFile,BufRead squid.conf		setf squid
2034
2035" SQL for Oracle Designer
2036au BufNewFile,BufRead *.tyb,*.typ,*.tyc,*.pkb,*.pks	setf sql
2037
2038" SQL
2039au BufNewFile,BufRead *.sql			call s:SQL()
2040
2041func! s:SQL()
2042  if exists("g:filetype_sql")
2043    exe "setf " . g:filetype_sql
2044  else
2045    setf sql
2046  endif
2047endfunc
2048
2049" SQLJ
2050au BufNewFile,BufRead *.sqlj			setf sqlj
2051
2052" SQR
2053au BufNewFile,BufRead *.sqr,*.sqi		setf sqr
2054
2055" OpenSSH configuration
2056au BufNewFile,BufRead ssh_config,*/.ssh/config	setf sshconfig
2057
2058" OpenSSH server configuration
2059au BufNewFile,BufRead sshd_config		setf sshdconfig
2060
2061" Stata
2062au BufNewFile,BufRead *.ado,*.class,*.do,*.imata,*.mata   setf stata
2063
2064" SMCL
2065au BufNewFile,BufRead *.hlp,*.ihlp,*.smcl	setf smcl
2066
2067" Stored Procedures
2068au BufNewFile,BufRead *.stp			setf stp
2069
2070" Standard ML
2071au BufNewFile,BufRead *.sml			setf sml
2072
2073" Sratus VOS command macro
2074au BufNewFile,BufRead *.cm			setf voscm
2075
2076" Sysctl
2077au BufNewFile,BufRead */etc/sysctl.conf,*/etc/sysctl.d/*.conf	setf sysctl
2078
2079" Synopsys Design Constraints
2080au BufNewFile,BufRead *.sdc			setf sdc
2081
2082" Sudoers
2083au BufNewFile,BufRead */etc/sudoers,sudoers.tmp	setf sudoers
2084
2085" SVG (Scalable Vector Graphics)
2086au BufNewFile,BufRead *.svg			setf svg
2087
2088" If the file has an extension of 't' and is in a directory 't' or 'xt' then
2089" it is almost certainly a Perl test file.
2090" If the first line starts with '#' and contains 'perl' it's probably a Perl
2091" file.
2092" (Slow test) If a file contains a 'use' statement then it is almost certainly
2093" a Perl file.
2094func! s:FTperl()
2095  let dirname = expand("%:p:h:t")
2096  if expand("%:e") == 't' && (dirname == 't' || dirname == 'xt')
2097    setf perl
2098    return 1
2099  endif
2100  if getline(1)[0] == '#' && getline(1) =~ 'perl'
2101    setf perl
2102    return 1
2103  endif
2104  if search('^use\s\s*\k', 'nc', 30)
2105    setf perl
2106    return 1
2107  endif
2108  return 0
2109endfunc
2110
2111" Tads (or Nroff or Perl test file)
2112au BufNewFile,BufRead *.t
2113	\ if !s:FTnroff() && !s:FTperl() | setf tads | endif
2114
2115" Tags
2116au BufNewFile,BufRead tags			setf tags
2117
2118" TAK
2119au BufNewFile,BufRead *.tak			setf tak
2120
2121" Task
2122au BufRead,BufNewFile {pending,completed,undo}.data  setf taskdata
2123au BufRead,BufNewFile *.task			setf taskedit
2124
2125" Tcl (JACL too)
2126au BufNewFile,BufRead *.tcl,*.tk,*.itcl,*.itk,*.jacl	setf tcl
2127
2128" TealInfo
2129au BufNewFile,BufRead *.tli			setf tli
2130
2131" Telix Salt
2132au BufNewFile,BufRead *.slt			setf tsalt
2133
2134" Terminfo
2135au BufNewFile,BufRead *.ti			setf terminfo
2136
2137" TeX
2138au BufNewFile,BufRead *.latex,*.sty,*.dtx,*.ltx,*.bbl	setf tex
2139au BufNewFile,BufRead *.tex			call s:FTtex()
2140
2141" Choose context, plaintex, or tex (LaTeX) based on these rules:
2142" 1. Check the first line of the file for "%&<format>".
2143" 2. Check the first 1000 non-comment lines for LaTeX or ConTeXt keywords.
2144" 3. Default to "latex" or to g:tex_flavor, can be set in user's vimrc.
2145func! s:FTtex()
2146  let firstline = getline(1)
2147  if firstline =~ '^%&\s*\a\+'
2148    let format = tolower(matchstr(firstline, '\a\+'))
2149    let format = substitute(format, 'pdf', '', '')
2150    if format == 'tex'
2151      let format = 'plain'
2152    endif
2153  else
2154    " Default value, may be changed later:
2155    let format = exists("g:tex_flavor") ? g:tex_flavor : 'plain'
2156    " Save position, go to the top of the file, find first non-comment line.
2157    let save_cursor = getpos('.')
2158    call cursor(1,1)
2159    let firstNC = search('^\s*[^[:space:]%]', 'c', 1000)
2160    if firstNC " Check the next thousand lines for a LaTeX or ConTeXt keyword.
2161      let lpat = 'documentclass\>\|usepackage\>\|begin{\|newcommand\>\|renewcommand\>'
2162      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\>'
2163      let kwline = search('^\s*\\\%(' . lpat . '\)\|^\s*\\\(' . cpat . '\)',
2164			      \ 'cnp', firstNC + 1000)
2165      if kwline == 1	" lpat matched
2166	let format = 'latex'
2167      elseif kwline == 2	" cpat matched
2168	let format = 'context'
2169      endif		" If neither matched, keep default set above.
2170      " let lline = search('^\s*\\\%(' . lpat . '\)', 'cn', firstNC + 1000)
2171      " let cline = search('^\s*\\\%(' . cpat . '\)', 'cn', firstNC + 1000)
2172      " if cline > 0
2173      "   let format = 'context'
2174      " endif
2175      " if lline > 0 && (cline == 0 || cline > lline)
2176      "   let format = 'tex'
2177      " endif
2178    endif " firstNC
2179    call setpos('.', save_cursor)
2180  endif " firstline =~ '^%&\s*\a\+'
2181
2182  " Translation from formats to file types.  TODO:  add AMSTeX, RevTex, others?
2183  if format == 'plain'
2184    setf plaintex
2185  elseif format == 'context'
2186    setf context
2187  else " probably LaTeX
2188    setf tex
2189  endif
2190  return
2191endfunc
2192
2193" ConTeXt
2194au BufNewFile,BufRead tex/context/*/*.tex,*.mkii,*.mkiv   setf context
2195
2196" Texinfo
2197au BufNewFile,BufRead *.texinfo,*.texi,*.txi	setf texinfo
2198
2199" TeX configuration
2200au BufNewFile,BufRead texmf.cnf			setf texmf
2201
2202" Tidy config
2203au BufNewFile,BufRead .tidyrc,tidyrc		setf tidy
2204
2205" TF mud client
2206au BufNewFile,BufRead *.tf,.tfrc,tfrc		setf tf
2207
2208" TPP - Text Presentation Program
2209au BufNewFile,BufReadPost *.tpp			setf tpp
2210
2211" Treetop
2212au BufRead,BufNewFile *.treetop			setf treetop
2213
2214" Trustees
2215au BufNewFile,BufRead trustees.conf		setf trustees
2216
2217" TSS - Geometry
2218au BufNewFile,BufReadPost *.tssgm		setf tssgm
2219
2220" TSS - Optics
2221au BufNewFile,BufReadPost *.tssop		setf tssop
2222
2223" TSS - Command Line (temporary)
2224au BufNewFile,BufReadPost *.tsscl		setf tsscl
2225
2226" TWIG files
2227au BufNewFile,BufReadPost *.twig		setf twig
2228
2229" Motif UIT/UIL files
2230au BufNewFile,BufRead *.uit,*.uil		setf uil
2231
2232" Udev conf
2233au BufNewFile,BufRead */etc/udev/udev.conf	setf udevconf
2234
2235" Udev permissions
2236au BufNewFile,BufRead */etc/udev/permissions.d/*.permissions setf udevperm
2237"
2238" Udev symlinks config
2239au BufNewFile,BufRead */etc/udev/cdsymlinks.conf	setf sh
2240
2241" UnrealScript
2242au BufNewFile,BufRead *.uc			setf uc
2243
2244" Updatedb
2245au BufNewFile,BufRead */etc/updatedb.conf	setf updatedb
2246
2247" Upstart (init(8)) config files
2248au BufNewFile,BufRead */usr/share/upstart/*.conf	       setf upstart
2249au BufNewFile,BufRead */usr/share/upstart/*.override	       setf upstart
2250au BufNewFile,BufRead */etc/init/*.conf,*/etc/init/*.override  setf upstart
2251au BufNewFile,BufRead */.init/*.conf,*/.init/*.override        setf upstart
2252au BufNewFile,BufRead */.config/upstart/*.conf		       setf upstart
2253au BufNewFile,BufRead */.config/upstart/*.override	       setf upstart
2254
2255" Vera
2256au BufNewFile,BufRead *.vr,*.vri,*.vrh		setf vera
2257
2258" Verilog HDL
2259au BufNewFile,BufRead *.v			setf verilog
2260
2261" Verilog-AMS HDL
2262au BufNewFile,BufRead *.va,*.vams		setf verilogams
2263
2264" SystemVerilog
2265au BufNewFile,BufRead *.sv,*.svh		setf systemverilog
2266
2267" VHDL
2268au BufNewFile,BufRead *.hdl,*.vhd,*.vhdl,*.vbe,*.vst  setf vhdl
2269au BufNewFile,BufRead *.vhdl_[0-9]*		call s:StarSetf('vhdl')
2270
2271" Vim script
2272au BufNewFile,BufRead *.vim,*.vba,.exrc,_exrc	setf vim
2273
2274" Viminfo file
2275au BufNewFile,BufRead .viminfo,_viminfo		setf viminfo
2276
2277" Virata Config Script File or Drupal module
2278au BufRead,BufNewFile *.hw,*.module,*.pkg
2279	\ if getline(1) =~ '<?php' |
2280	\   setf php |
2281	\ else |
2282	\   setf virata |
2283	\ endif
2284
2285" Visual Basic (also uses *.bas) or FORM
2286au BufNewFile,BufRead *.frm			call s:FTVB("form")
2287
2288" SaxBasic is close to Visual Basic
2289au BufNewFile,BufRead *.sba			setf vb
2290
2291" Vgrindefs file
2292au BufNewFile,BufRead vgrindefs			setf vgrindefs
2293
2294" VRML V1.0c
2295au BufNewFile,BufRead *.wrl			setf vrml
2296
2297" Webmacro
2298au BufNewFile,BufRead *.wm			setf webmacro
2299
2300" Wget config
2301au BufNewFile,BufRead .wgetrc,wgetrc		setf wget
2302
2303" Website MetaLanguage
2304au BufNewFile,BufRead *.wml			setf wml
2305
2306" Winbatch
2307au BufNewFile,BufRead *.wbt			setf winbatch
2308
2309" WSML
2310au BufNewFile,BufRead *.wsml			setf wsml
2311
2312" WvDial
2313au BufNewFile,BufRead wvdial.conf,.wvdialrc	setf wvdial
2314
2315" CVS RC file
2316au BufNewFile,BufRead .cvsrc			setf cvsrc
2317
2318" CVS commit file
2319au BufNewFile,BufRead cvs\d\+			setf cvs
2320
2321" WEB (*.web is also used for Winbatch: Guess, based on expecting "%" comment
2322" lines in a WEB file).
2323au BufNewFile,BufRead *.web
2324	\ if getline(1)[0].getline(2)[0].getline(3)[0].getline(4)[0].getline(5)[0] =~ "%" |
2325	\   setf web |
2326	\ else |
2327	\   setf winbatch |
2328	\ endif
2329
2330" Windows Scripting Host and Windows Script Component
2331au BufNewFile,BufRead *.ws[fc]			setf wsh
2332
2333" XHTML
2334au BufNewFile,BufRead *.xhtml,*.xht		setf xhtml
2335
2336" X Pixmap (dynamically sets colors, use BufEnter to make it work better)
2337au BufEnter *.xpm
2338	\ if getline(1) =~ "XPM2" |
2339	\   setf xpm2 |
2340	\ else |
2341	\   setf xpm |
2342	\ endif
2343au BufEnter *.xpm2				setf xpm2
2344
2345" XFree86 config
2346au BufNewFile,BufRead XF86Config
2347	\ if getline(1) =~ '\<XConfigurator\>' |
2348	\   let b:xf86conf_xfree86_version = 3 |
2349	\ endif |
2350	\ setf xf86conf
2351au BufNewFile,BufRead */xorg.conf.d/*.conf
2352	\ let b:xf86conf_xfree86_version = 4 |
2353	\ setf xf86conf
2354
2355" Xorg config
2356au BufNewFile,BufRead xorg.conf,xorg.conf-4	let b:xf86conf_xfree86_version = 4 | setf xf86conf
2357
2358" Xinetd conf
2359au BufNewFile,BufRead */etc/xinetd.conf		setf xinetd
2360
2361" XS Perl extension interface language
2362au BufNewFile,BufRead *.xs			setf xs
2363
2364" X resources file
2365au BufNewFile,BufRead .Xdefaults,.Xpdefaults,.Xresources,xdm-config,*.ad setf xdefaults
2366
2367" Xmath
2368au BufNewFile,BufRead *.msc,*.msf		setf xmath
2369au BufNewFile,BufRead *.ms
2370	\ if !s:FTnroff() | setf xmath | endif
2371
2372" XML  specific variants: docbk and xbl
2373au BufNewFile,BufRead *.xml			call s:FTxml()
2374
2375func! s:FTxml()
2376  let n = 1
2377  while n < 100 && n < line("$")
2378    let line = getline(n)
2379    " DocBook 4 or DocBook 5.
2380    let is_docbook4 = line =~ '<!DOCTYPE.*DocBook'
2381    let is_docbook5 = line =~ ' xmlns="http://docbook.org/ns/docbook"'
2382    if is_docbook4 || is_docbook5
2383      let b:docbk_type = "xml"
2384      if is_docbook5
2385	let b:docbk_ver = 5
2386      else
2387	let b:docbk_ver = 4
2388      endif
2389      setf docbk
2390      return
2391    endif
2392    if line =~ 'xmlns:xbl="http://www.mozilla.org/xbl"'
2393      setf xbl
2394      return
2395    endif
2396    let n += 1
2397  endwhile
2398  setf xml
2399endfunc
2400
2401" XMI (holding UML models) is also XML
2402au BufNewFile,BufRead *.xmi			setf xml
2403
2404" CSPROJ files are Visual Studio.NET's XML-based project config files
2405au BufNewFile,BufRead *.csproj,*.csproj.user	setf xml
2406
2407" Qt Linguist translation source and Qt User Interface Files are XML
2408au BufNewFile,BufRead *.ts,*.ui			setf xml
2409
2410" TPM's are RDF-based descriptions of TeX packages (Nikolai Weibull)
2411au BufNewFile,BufRead *.tpm			setf xml
2412
2413" Xdg menus
2414au BufNewFile,BufRead */etc/xdg/menus/*.menu	setf xml
2415
2416" ATI graphics driver configuration
2417au BufNewFile,BufRead fglrxrc			setf xml
2418
2419" XLIFF (XML Localisation Interchange File Format) is also XML
2420au BufNewFile,BufRead *.xlf			setf xml
2421au BufNewFile,BufRead *.xliff			setf xml
2422
2423" XML User Interface Language
2424au BufNewFile,BufRead *.xul			setf xml
2425
2426" X11 xmodmap (also see below)
2427au BufNewFile,BufRead *Xmodmap			setf xmodmap
2428
2429" Xquery
2430au BufNewFile,BufRead *.xq,*.xql,*.xqm,*.xquery,*.xqy	setf xquery
2431
2432" XSD
2433au BufNewFile,BufRead *.xsd			setf xsd
2434
2435" Xslt
2436au BufNewFile,BufRead *.xsl,*.xslt		setf xslt
2437
2438" Yacc
2439au BufNewFile,BufRead *.yy,*.yxx,*.y++		setf yacc
2440
2441" Yacc or racc
2442au BufNewFile,BufRead *.y			call s:FTy()
2443
2444func! s:FTy()
2445  let n = 1
2446  while n < 100 && n < line("$")
2447    let line = getline(n)
2448    if line =~ '^\s*%'
2449      setf yacc
2450      return
2451    endif
2452    if getline(n) =~ '^\s*\(#\|class\>\)' && getline(n) !~ '^\s*#\s*include'
2453      setf racc
2454      return
2455    endif
2456    let n = n + 1
2457  endwhile
2458  setf yacc
2459endfunc
2460
2461
2462" Yaml
2463au BufNewFile,BufRead *.yaml,*.yml		setf yaml
2464
2465" yum conf (close enough to dosini)
2466au BufNewFile,BufRead */etc/yum.conf		setf dosini
2467
2468" Zimbu
2469au BufNewFile,BufRead *.zu			setf zimbu
2470
2471" Zope
2472"   dtml (zope dynamic template markup language), pt (zope page template),
2473"   cpt (zope form controller page template)
2474au BufNewFile,BufRead *.dtml,*.pt,*.cpt		call s:FThtml()
2475"   zsql (zope sql method)
2476au BufNewFile,BufRead *.zsql			call s:SQL()
2477
2478" Z80 assembler asz80
2479au BufNewFile,BufRead *.z8a			setf z8a
2480
2481augroup END
2482
2483
2484" Source the user-specified filetype file, for backwards compatibility with
2485" Vim 5.x.
2486if exists("myfiletypefile") && filereadable(expand(myfiletypefile))
2487  execute "source " . myfiletypefile
2488endif
2489
2490
2491" Check for "*" after loading myfiletypefile, so that scripts.vim is only used
2492" when there are no matching file name extensions.
2493" Don't do this for compressed files.
2494augroup filetypedetect
2495au BufNewFile,BufRead *
2496	\ if !did_filetype() && expand("<amatch>") !~ g:ft_ignore_pat
2497	\ | runtime! scripts.vim | endif
2498au StdinReadPost * if !did_filetype() | runtime! scripts.vim | endif
2499
2500
2501" Extra checks for when no filetype has been detected now.  Mostly used for
2502" patterns that end in "*".  E.g., "zsh*" matches "zsh.vim", but that's a Vim
2503" script file.
2504" Most of these should call s:StarSetf() to avoid names ending in .gz and the
2505" like are used.
2506
2507" More Apache config files
2508au BufNewFile,BufRead access.conf*,apache.conf*,apache2.conf*,httpd.conf*,srm.conf*	call s:StarSetf('apache')
2509au BufNewFile,BufRead */etc/apache2/*.conf*,*/etc/apache2/conf.*/*,*/etc/apache2/mods-*/*,*/etc/apache2/sites-*/*,*/etc/httpd/conf.d/*.conf*		call s:StarSetf('apache')
2510
2511" Asterisk config file
2512au BufNewFile,BufRead *asterisk/*.conf*		call s:StarSetf('asterisk')
2513au BufNewFile,BufRead *asterisk*/*voicemail.conf* call s:StarSetf('asteriskvm')
2514
2515" Bazaar version control
2516au BufNewFile,BufRead bzr_log.*			setf bzr
2517
2518" BIND zone
2519au BufNewFile,BufRead */named/db.*,*/bind/db.*	call s:StarSetf('bindzone')
2520
2521" Calendar
2522au BufNewFile,BufRead */.calendar/*,
2523	\*/share/calendar/*/calendar.*,*/share/calendar/calendar.*
2524	\					call s:StarSetf('calendar')
2525
2526" Changelog
2527au BufNewFile,BufRead [cC]hange[lL]og*
2528	\ if getline(1) =~ '; urgency='
2529	\|  call s:StarSetf('debchangelog')
2530	\|else
2531	\|  call s:StarSetf('changelog')
2532	\|endif
2533
2534" Crontab
2535au BufNewFile,BufRead crontab,crontab.*,*/etc/cron.d/*		call s:StarSetf('crontab')
2536
2537" dnsmasq(8) configuration
2538au BufNewFile,BufRead */etc/dnsmasq.d/*		call s:StarSetf('dnsmasq')
2539
2540" Dracula
2541au BufNewFile,BufRead drac.*			call s:StarSetf('dracula')
2542
2543" Fvwm
2544au BufNewFile,BufRead */.fvwm/*			call s:StarSetf('fvwm')
2545au BufNewFile,BufRead *fvwmrc*,*fvwm95*.hook
2546	\ let b:fvwm_version = 1 | call s:StarSetf('fvwm')
2547au BufNewFile,BufRead *fvwm2rc*
2548	\ if expand("<afile>:e") == "m4"
2549	\|  call s:StarSetf('fvwm2m4')
2550	\|else
2551	\|  let b:fvwm_version = 2 | call s:StarSetf('fvwm')
2552	\|endif
2553
2554" Gedcom
2555au BufNewFile,BufRead */tmp/lltmp*		call s:StarSetf('gedcom')
2556
2557" GTK RC
2558au BufNewFile,BufRead .gtkrc*,gtkrc*		call s:StarSetf('gtkrc')
2559
2560" Jam
2561au BufNewFile,BufRead Prl*.*,JAM*.*		call s:StarSetf('jam')
2562
2563" Jargon
2564au! BufNewFile,BufRead *jarg*
2565	\ if getline(1).getline(2).getline(3).getline(4).getline(5) =~? 'THIS IS THE JARGON FILE'
2566	\|  call s:StarSetf('jargon')
2567	\|endif
2568
2569" Kconfig
2570au BufNewFile,BufRead Kconfig.*			call s:StarSetf('kconfig')
2571
2572" Lilo: Linux loader
2573au BufNewFile,BufRead lilo.conf*		call s:StarSetf('lilo')
2574
2575" Logcheck
2576au BufNewFile,BufRead */etc/logcheck/*.d*/*	call s:StarSetf('logcheck')
2577
2578" Makefile
2579au BufNewFile,BufRead [mM]akefile*		call s:StarSetf('make')
2580
2581" Ruby Makefile
2582au BufNewFile,BufRead [rR]akefile*		call s:StarSetf('ruby')
2583
2584" Mail (also matches muttrc.vim, so this is below the other checks)
2585au BufNewFile,BufRead mutt[[:alnum:]._-]\\\{6\}	setf mail
2586
2587" Modconf
2588au BufNewFile,BufRead */etc/modutils/*
2589	\ if executable(expand("<afile>")) != 1
2590	\|  call s:StarSetf('modconf')
2591	\|endif
2592au BufNewFile,BufRead */etc/modprobe.*		call s:StarSetf('modconf')
2593
2594" Mutt setup file
2595au BufNewFile,BufRead .mutt{ng,}rc*,*/.mutt{ng,}/mutt{ng,}rc*	call s:StarSetf('muttrc')
2596au BufNewFile,BufRead mutt{ng,}rc*,Mutt{ng,}rc*		call s:StarSetf('muttrc')
2597
2598" Nroff macros
2599au BufNewFile,BufRead tmac.*			call s:StarSetf('nroff')
2600
2601" Pam conf
2602au BufNewFile,BufRead */etc/pam.d/*		call s:StarSetf('pamconf')
2603
2604" Printcap and Termcap
2605au BufNewFile,BufRead *printcap*
2606	\ if !did_filetype()
2607	\|  let b:ptcap_type = "print" | call s:StarSetf('ptcap')
2608	\|endif
2609au BufNewFile,BufRead *termcap*
2610	\ if !did_filetype()
2611	\|  let b:ptcap_type = "term" | call s:StarSetf('ptcap')
2612	\|endif
2613
2614" ReDIF
2615" Only used when the .rdf file was not detected to be XML.
2616au BufRead,BufNewFile *.rdf			call s:Redif()
2617func! s:Redif()
2618  let lnum = 1
2619  while lnum <= 5 && lnum < line('$')
2620    if getline(lnum) =~ "^\ctemplate-type:"
2621      setf redif
2622      return
2623    endif
2624    let lnum = lnum + 1
2625  endwhile
2626endfunc
2627
2628" Remind
2629au BufNewFile,BufRead .reminders*		call s:StarSetf('remind')
2630
2631" Vim script
2632au BufNewFile,BufRead *vimrc*			call s:StarSetf('vim')
2633
2634" Subversion commit file
2635au BufNewFile,BufRead svn-commit*.tmp		setf svn
2636
2637" X resources file
2638au BufNewFile,BufRead Xresources*,*/app-defaults/*,*/Xresources/* call s:StarSetf('xdefaults')
2639
2640" XFree86 config
2641au BufNewFile,BufRead XF86Config-4*
2642	\ let b:xf86conf_xfree86_version = 4 | call s:StarSetf('xf86conf')
2643au BufNewFile,BufRead XF86Config*
2644	\ if getline(1) =~ '\<XConfigurator\>'
2645	\|  let b:xf86conf_xfree86_version = 3
2646	\|endif
2647	\|call s:StarSetf('xf86conf')
2648
2649" X11 xmodmap
2650au BufNewFile,BufRead *xmodmap*			call s:StarSetf('xmodmap')
2651
2652" Xinetd conf
2653au BufNewFile,BufRead */etc/xinetd.d/*		call s:StarSetf('xinetd')
2654
2655" yum conf (close enough to dosini)
2656au BufNewFile,BufRead */etc/yum.repos.d/*	call s:StarSetf('dosini')
2657
2658" Z-Shell script
2659au BufNewFile,BufRead zsh*,zlog*		call s:StarSetf('zsh')
2660
2661
2662" Plain text files, needs to be far down to not override others.  This avoids
2663" the "conf" type being used if there is a line starting with '#'.
2664au BufNewFile,BufRead *.txt,*.text		setf text
2665
2666
2667" Use the filetype detect plugins.  They may overrule any of the previously
2668" detected filetypes.
2669runtime! ftdetect/*.vim
2670
2671" NOTE: The above command could have ended the filetypedetect autocmd group
2672" and started another one. Let's make sure it has ended to get to a consistent
2673" state.
2674augroup END
2675
2676" Generic configuration file (check this last, it's just guessing!)
2677au filetypedetect BufNewFile,BufRead,StdinReadPost *
2678	\ if !did_filetype() && expand("<amatch>") !~ g:ft_ignore_pat
2679	\    && (getline(1) =~ '^#' || getline(2) =~ '^#' || getline(3) =~ '^#'
2680	\	|| getline(4) =~ '^#' || getline(5) =~ '^#') |
2681	\   setf conf |
2682	\ endif
2683
2684
2685" If the GUI is already running, may still need to install the Syntax menu.
2686" Don't do it when the 'M' flag is included in 'guioptions'.
2687if has("menu") && has("gui_running")
2688      \ && !exists("did_install_syntax_menu") && &guioptions !~# "M"
2689  source <sfile>:p:h/menu.vim
2690endif
2691
2692" Function called for testing all functions defined here.  These are
2693" script-local, thus need to be executed here.
2694" Returns a string with error messages (hopefully empty).
2695func! TestFiletypeFuncs(testlist)
2696  let output = ''
2697  for f in a:testlist
2698    try
2699      exe f
2700    catch
2701      let output = output . "\n" . f . ": " . v:exception
2702    endtry
2703  endfor
2704  return output
2705endfunc
2706
2707" Restore 'cpoptions'
2708let &cpo = s:cpo_save
2709unlet s:cpo_save
2710