xref: /vim-8.2.3635/runtime/filetype.vim (revision 57657d85)
1" Vim support file to detect file types
2"
3" Maintainer:	Bram Moolenaar <[email protected]>
4" Last Change:	2006 Apr 21
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
19au BufNewFile,BufRead ?\+.orig,?\+.bak,?\+.old,?\+.new,?\+.rpmsave,?\+.rpmnew
20	\ exe "doau filetypedetect BufRead " . expand("<afile>:r")
21au BufNewFile,BufRead *~
22	\ let s:name = expand("<afile>") |
23	\ let s:short = substitute(s:name, '\~$', '', '') |
24	\ if s:name != s:short && s:short != "" |
25	\   exe "doau filetypedetect BufRead " . s:short |
26	\ endif |
27	\ unlet s:name |
28	\ unlet s:short
29au BufNewFile,BufRead ?\+.in
30	\ if expand("<afile>:t") != "configure.in" |
31	\   exe "doau filetypedetect BufRead " . expand("<afile>:r") |
32	\ endif
33
34" Pattern used to match file names which should not be inspected.
35" Currently finds compressed files.
36if !exists("g:ft_ignore_pat")
37  let g:ft_ignore_pat = '\.\(Z\|gz\|bz2\|zip\|tgz\)$'
38endif
39
40" Function used for patterns that end in a star: don't set the filetype if the
41" file name matches ft_ignore_pat.
42fun! s:StarSetf(ft)
43  if expand("<amatch>") !~ g:ft_ignore_pat
44    exe 'setf ' . a:ft
45  endif
46endfun
47
48" Abaqus or Trasys
49au BufNewFile,BufRead *.inp			call s:Check_inp()
50
51fun! s:Check_inp()
52  if getline(1) =~ '^\*'
53    setf abaqus
54  else
55    let n = 1
56    if line("$") > 500
57      let nmax = 500
58    else
59      let nmax = line("$")
60    endif
61    while n <= nmax
62      if getline(n) =~? "^header surface data"
63	setf trasys
64	break
65      endif
66      let n = n + 1
67    endwhile
68  endif
69endfun
70
71" A-A-P recipe
72au BufNewFile,BufRead *.aap			setf aap
73
74" A2ps printing utility
75au BufNewFile,BufRead etc/a2ps.cfg,etc/a2ps/*.cfg,a2psrc,.a2psrc setf a2ps
76
77" ABAB/4
78au BufNewFile,BufRead *.abap			setf abap
79
80" ABC music notation
81au BufNewFile,BufRead *.abc			setf abc
82
83" ABEL
84au BufNewFile,BufRead *.abl			setf abel
85
86" AceDB
87au BufNewFile,BufRead *.wrm			setf acedb
88
89" Ada (83, 9X, 95)
90au BufNewFile,BufRead *.adb,*.ads,*.ada		setf ada
91
92" AHDL
93au BufNewFile,BufRead *.tdf			setf ahdl
94
95" AMPL
96au BufNewFile,BufRead *.run			setf ampl
97
98" Ant
99au BufNewFile,BufRead build.xml			setf ant
100
101" Apache style config file
102au BufNewFile,BufRead proftpd.conf*		call s:StarSetf('apachestyle')
103
104" Apache config file
105au BufNewFile,BufRead .htaccess			 setf apache
106au BufNewFile,BufRead httpd.conf*,srm.conf*,access.conf*,apache.conf*,apache2.conf*,/etc/apache2/*.conf* call s:StarSetf('apache')
107
108" XA65 MOS6510 cross assembler
109au BufNewFile,BufRead *.a65			setf a65
110
111" Applix ELF
112au BufNewFile,BufRead *.am
113	\ if expand("<afile>") !~? 'Makefile.am\>' | setf elf | endif
114
115" ALSA configuration
116au BufNewFile,BufRead ~/.asoundrc,/usr/share/alsa/alsa.conf,/etc/asound.conf	setf alsaconf
117
118" Arc Macro Language
119au BufNewFile,BufRead *.aml			setf aml
120
121" Arch Inventory file
122au BufNewFile,BufRead .arch-inventory,=tagging-method	setf arch
123
124" ART*Enterprise (formerly ART-IM)
125au BufNewFile,BufRead *.art			setf art
126
127" ASN.1
128au BufNewFile,BufRead *.asn,*.asn1		setf asn
129
130" Active Server Pages (with Visual Basic Script)
131au BufNewFile,BufRead *.asa
132	\ if exists("g:filetype_asa") |
133	\   exe "setf " . g:filetype_asa |
134	\ else |
135	\   setf aspvbs |
136	\ endif
137
138" Active Server Pages (with Perl or Visual Basic Script)
139au BufNewFile,BufRead *.asp
140	\ if exists("g:filetype_asp") |
141	\   exe "setf " . g:filetype_asp |
142	\ elseif getline(1) . getline(2) . getline(3) =~? "perlscript" |
143	\   setf aspperl |
144	\ else |
145	\   setf aspvbs |
146	\ endif
147
148" Grub (must be before catch *.lst)
149au BufNewFile,BufRead /boot/grub/menu.lst,/boot/grub/grub.conf,/etc/grub.conf	setf grub
150
151" Assembly (all kinds)
152" *.lst is not pure assembly, it has two extra columns (address, byte codes)
153au BufNewFile,BufRead *.asm,*.[sS],*.[aA],*.mac,*.lst	call s:FTasm()
154
155" This function checks for the kind of assembly that is wanted by the user, or
156" can be detected from the first five lines of the file.
157fun! s:FTasm()
158  " make sure b:asmsyntax exists
159  if !exists("b:asmsyntax")
160    let b:asmsyntax = ""
161  endif
162
163  if b:asmsyntax == ""
164    call s:FTasmsyntax()
165  endif
166
167  " if b:asmsyntax still isn't set, default to asmsyntax or GNU
168  if b:asmsyntax == ""
169    if exists("g:asmsyntax")
170      let b:asmsyntax = g:asmsyntax
171    else
172      let b:asmsyntax = "asm"
173    endif
174  endif
175
176  exe "setf " . b:asmsyntax
177endfun
178
179fun! s:FTasmsyntax()
180  " see if file contains any asmsyntax=foo overrides. If so, change
181  " b:asmsyntax appropriately
182  let head = " ".getline(1)." ".getline(2)." ".getline(3)." ".getline(4).
183	\" ".getline(5)." "
184  if head =~ '\sasmsyntax=\S\+\s'
185    let b:asmsyntax = substitute(head, '.*\sasmsyntax=\(\S\+\)\s.*','\1', "")
186  elseif ((head =~? '\.title') || (head =~? '\.ident') || (head =~? '\.macro') || (head =~? '\.subtitle') || (head =~? '\.library'))
187    let b:asmsyntax = "vmasm"
188  endif
189endfun
190
191" Macro (VAX)
192au BufNewFile,BufRead *.mar			setf vmasm
193
194" Atlas
195au BufNewFile,BufRead *.atl,*.as		setf atlas
196
197" Automake
198au BufNewFile,BufRead [mM]akefile.am,GNUmakefile.am	setf automake
199
200" Autotest .at files are actually m4
201au BufNewFile,BufRead *.at			setf m4
202
203" Avenue
204au BufNewFile,BufRead *.ave			setf ave
205
206" Awk
207au BufNewFile,BufRead *.awk			setf awk
208
209" B
210au BufNewFile,BufRead *.mch,*.ref,*.imp		setf b
211
212" BASIC or Visual Basic
213au BufNewFile,BufRead *.bas			call s:FTVB("basic")
214
215" Check if one of the first five lines contains "VB_Name".  In that case it is
216" probably a Visual Basic file.  Otherwise it's assumed to be "alt" filetype.
217fun! s:FTVB(alt)
218  if getline(1).getline(2).getline(3).getline(4).getline(5) =~? 'VB_Name\|Begin VB\.\(Form\|MDIForm\|UserControl\)'
219    setf vb
220  else
221    exe "setf " . a:alt
222  endif
223endfun
224
225" Visual Basic Script (close to Visual Basic)
226au BufNewFile,BufRead *.vbs,*.dsm,*.ctl		setf vb
227
228" Batch file for MSDOS.
229au BufNewFile,BufRead *.bat,*.sys		setf dosbatch
230" *.cmd is close to a Batch file, but on OS/2 Rexx files also use *.cmd.
231au BufNewFile,BufRead *.cmd
232	\ if getline(1) =~ '^/\*' | setf rexx | else | setf dosbatch | endif
233
234" Batch file for 4DOS
235au BufNewFile,BufRead *.btm			call s:FTbtm()
236fun! s:FTbtm()
237  if exists("g:dosbatch_syntax_for_btm") && g:dosbatch_syntax_for_btm
238    setf dosbatch
239  else
240    setf btm
241  endif
242endfun
243
244" BC calculator
245au BufNewFile,BufRead *.bc			setf bc
246
247" BDF font
248au BufNewFile,BufRead *.bdf			setf bdf
249
250" BibTeX bibliography database file
251au BufNewFile,BufRead *.bib			setf bib
252
253" BIND configuration
254au BufNewFile,BufRead named.conf,rndc.conf	setf named
255
256" BIND zone
257au BufNewFile,BufRead named.root		setf bindzone
258au BufNewFile,BufRead *.db			call s:BindzoneCheck('')
259
260func! s:BindzoneCheck(default)
261  if getline(1).getline(2).getline(3).getline(4) =~ '^; <<>> DiG [0-9.]\+ <<>>\|BIND.*named\|$ORIGIN\|$TTL\|IN\s\+SOA'
262    setf bindzone
263  elseif a:default != ''
264    exe 'setf ' . a:default
265  endif
266endfunc
267
268" Blank
269au BufNewFile,BufRead *.bl			setf blank
270
271" C or lpc
272au BufNewFile,BufRead *.c			call s:FTlpc()
273
274fun! s:FTlpc()
275  if exists("g:lpc_syntax_for_c")
276    let lnum = 1
277    while lnum <= 12
278      if getline(lnum) =~# '^\(//\|inherit\|private\|protected\|nosave\|string\|object\|mapping\|mixed\)'
279	setf lpc
280	return
281      endif
282      let lnum = lnum + 1
283    endwhile
284  endif
285  setf c
286endfun
287
288" Calendar
289au BufNewFile,BufRead calendar			setf calendar
290au BufNewFile,BufRead */.calendar/*,
291	\*/share/calendar/*/calendar.*,*/share/calendar/calendar.*
292	\					call s:StarSetf('calendar')
293
294" C#
295au BufNewFile,BufRead *.cs			setf cs
296
297" Cfengine
298au BufNewFile,BufRead cfengine.conf		setf cfengine
299
300" Comshare Dimension Definition Language
301au BufNewFile,BufRead *.cdl			setf cdl
302
303" Controllable Regex Mutilator
304au BufNewFile,BufRead *.crm			setf crm
305
306" Cyn++
307au BufNewFile,BufRead *.cyn			setf cynpp
308
309" Cynlib
310" .cc and .cpp files can be C++ or Cynlib.
311au BufNewFile,BufRead *.cc
312	\ if exists("cynlib_syntax_for_cc")|setf cynlib|else|setf cpp|endif
313au BufNewFile,BufRead *.cpp
314	\ if exists("cynlib_syntax_for_cpp")|setf cynlib|else|setf cpp|endif
315
316" C++
317if has("fname_case")
318  au BufNewFile,BufRead *.cxx,*.c++,*.C,*.H,*.hh,*.hxx,*.hpp,*.moc,*.tcc,*.inl setf cpp
319else
320  au BufNewFile,BufRead *.cxx,*.c++,*.hh,*.hxx,*.hpp,*.moc,*.tcc,*.inl setf cpp
321endif
322
323" .h files can be C, Ch or C++, set c_syntax_for_h if you want C,
324" ch_syntax_for_h if you want Ch.
325au BufNewFile,BufRead *.h
326	\ if exists("c_syntax_for_h") | setf c |
327	\ elseif exists("ch_syntax_for_h") | setf ch |
328	\ else | setf cpp | endif
329
330" Ch (CHscript)
331au BufNewFile,BufRead *.chf			setf ch
332
333" TLH files are C++ headers generated by Visual C++'s #import from typelibs
334au BufNewFile,BufRead *.tlh			setf cpp
335
336" Cascading Style Sheets
337au BufNewFile,BufRead *.css			setf css
338
339" Century Term Command Scripts (*.cmd too)
340au BufNewFile,BufRead *.con			setf cterm
341
342" Changelog
343au BufNewFile,BufRead changelog.Debian,changelog.dch,NEWS.Debian,NEWS.dch
344					\	setf debchangelog
345
346au BufNewFile,BufRead [cC]hange[lL]og
347	\  if getline(1) =~ '; urgency='
348	\|   setf debchangelog
349	\| else
350	\|   setf changelog
351	\| endif
352
353au BufNewFile,BufRead NEWS
354	\  if getline(1) =~ '; urgency='
355	\|   setf debchangelog
356	\| endif
357
358" CHILL
359au BufNewFile,BufRead *..ch			setf chill
360
361" Changes for WEB and CWEB or CHILL
362au BufNewFile,BufRead *.ch			call s:FTchange()
363
364" This function checks if one of the first ten lines start with a '@'.  In
365" that case it is probably a change file.
366" If the first line starts with # or ! it's probably a ch file.
367" If a line has "main", "include", "//" ir "/*" it's probably ch.
368" Otherwise CHILL is assumed.
369fun! s:FTchange()
370  let lnum = 1
371  while lnum <= 10
372    if getline(lnum)[0] == '@'
373      setf change
374      return
375    endif
376    if lnum == 1 && (getline(1)[0] == '#' || getline(1)[0] == '!')
377      setf ch
378      return
379    endif
380    if getline(lnum) =~ "MODULE"
381      setf chill
382      return
383    endif
384    if getline(lnum) =~ 'main\s*(\|#\s*include\|//'
385      setf ch
386      return
387    endif
388    let lnum = lnum + 1
389  endwhile
390  setf chill
391endfun
392
393" ChordPro
394au BufNewFile,BufRead *.chopro,*.crd,*.cho,*.crdpro,*.chordpro	setf chordpro
395
396" Clean
397au BufNewFile,BufRead *.dcl,*.icl		setf clean
398
399" Clever
400au BufNewFile,BufRead *.eni			setf cl
401
402" Clever or dtd
403au BufNewFile,BufRead *.ent			call s:FTent()
404
405fun! s:FTent()
406  " This function checks for valid cl syntax in the first five lines.
407  " Look for either an opening comment, '#', or a block start, '{".
408  " If not found, assume SGML.
409  let lnum = 1
410  while lnum < 6
411    let line = getline(lnum)
412    if line =~ '^\s*[#{]'
413      setf cl
414      return
415    elseif line !~ '^\s*$'
416      " Not a blank line, not a comment, and not a block start,
417      " so doesn't look like valid cl code.
418      break
419    endif
420    let lnum = lnum + 1
421  endw
422  setf dtd
423endfun
424
425" Clipper (or FoxPro; could also be eviews)
426au BufNewFile,BufRead *.prg
427	\ if exists("g:filetype_prg") |
428	\   exe "setf " . g:filetype_prg |
429	\ else |
430	\   setf clipper |
431	\ endif
432
433" Cmake
434au BufNewFile,BufRead CMakeLists.txt,*.cmake,*.cmake.in		setf cmake
435
436" Cobol
437au BufNewFile,BufRead *.cbl,*.cob,*.lib	setf cobol
438"   cobol or zope form controller python script? (heuristic)
439au BufNewFile,BufRead *.cpy
440	\ if getline(1) =~ '^##' |
441	\   setf python |
442	\ else |
443	\   setf cobol |
444	\ endif
445
446" Cold Fusion
447au BufNewFile,BufRead *.cfm,*.cfi,*.cfc		setf cf
448
449" Configure scripts
450au BufNewFile,BufRead configure.in,configure.ac setf config
451
452" WildPackets EtherPeek Decoder
453au BufNewFile,BufRead *.dcd			setf dcd
454
455" Enlightenment configuration files
456au BufNewFile,BufRead *enlightenment/*.cfg	setf c
457
458" Eterm
459au BufNewFile,BufRead *Eterm/*.cfg		setf eterm
460
461" Lynx config files
462au BufNewFile,BufRead lynx.cfg			setf lynx
463
464" Quake
465au BufNewFile,BufRead *baseq[2-3]/*.cfg,*id1/*.cfg	setf quake
466au BufNewFile,BufRead *quake[1-3]/*.cfg			setf quake
467
468" Quake C
469au BufNewFile,BufRead *.qc			setf c
470
471" Configure files
472au BufNewFile,BufRead *.cfg			setf cfg
473
474" Communicating Sequential Processes
475au BufNewFile,BufRead *.csp,*.fdr		setf csp
476
477" CUPL logic description and simulation
478au BufNewFile,BufRead *.pld			setf cupl
479au BufNewFile,BufRead *.si			setf cuplsim
480
481" Debian Control
482au BufNewFile,BufRead */debian/control		setf debcontrol
483
484" Debian Sources.list
485au BufNewFile,BufRead /etc/apt/sources.list	setf debsources
486
487" ROCKLinux package description
488au BufNewFile,BufRead *.desc			setf desc
489
490" the D language
491au BufNewFile,BufRead *.d			setf d
492
493" Desktop files
494au BufNewFile,BufRead *.desktop,.directory	setf desktop
495
496" Dict config
497au BufNewFile,BufRead dict.conf,.dictrc		setf dictconf
498
499" Dictd config
500au BufNewFile,BufRead dictd.conf		setf dictdconf
501
502" Diff files
503au BufNewFile,BufRead *.diff,*.rej,*.patch	setf diff
504
505" Dircolors
506au BufNewFile,BufRead .dir_colors,/etc/DIR_COLORS	setf dircolors
507
508" Diva (with Skill) or InstallShield
509au BufNewFile,BufRead *.rul
510	\ if getline(1).getline(2).getline(3).getline(4).getline(5).getline(6) =~? 'InstallShield' |
511	\   setf ishd |
512	\ else |
513	\   setf diva |
514	\ endif
515
516" DCL (Digital Command Language - vms) or DNS zone file
517au BufNewFile,BufRead *.com			call s:BindzoneCheck('dcl')
518
519" DOT
520au BufNewFile,BufRead *.dot			setf dot
521
522" Dylan - lid files
523au BufNewFile,BufRead *.lid			setf dylanlid
524
525" Dylan - intr files (melange)
526au BufNewFile,BufRead *.intr			setf dylanintr
527
528" Dylan
529au BufNewFile,BufRead *.dylan			setf dylan
530
531" Microsoft Module Definition
532au BufNewFile,BufRead *.def			setf def
533
534" Dracula
535au BufNewFile,BufRead *.drac,*.drc,*lvs,*lpe	setf dracula
536
537" dsl
538au BufNewFile,BufRead *.dsl			setf dsl
539
540" DTD (Document Type Definition for XML)
541au BufNewFile,BufRead *.dtd			setf dtd
542
543" EDIF (*.edf,*.edif,*.edn,*.edo)
544au BufNewFile,BufRead *.ed\(f\|if\|n\|o\)	setf edif
545
546" Embedix Component Description
547au BufNewFile,BufRead *.ecd			setf ecd
548
549" Eiffel or Specman
550au BufNewFile,BufRead *.e,*.E			call s:FTe()
551
552" Elinks configuration
553au BufNewFile,BufRead */etc/elinks.conf,*/.elinks/elinks.conf	setf elinks
554
555fun! s:FTe()
556  let n = 1
557  while n < 100 && n < line("$")
558    if getline(n) =~ "^\\s*\\(<'\\|'>\\)\\s*$"
559      setf specman
560      return
561    endif
562    let n = n + 1
563  endwhile
564  setf eiffel
565endfun
566
567" ERicsson LANGuage
568au BufNewFile,BufRead *.erl			setf erlang
569
570" Elm Filter Rules file
571au BufNewFile,BufRead filter-rules		setf elmfilt
572
573" ESMTP rc file
574au BufNewFile,BufRead *esmtprc			setf esmtprc
575
576" ESQL-C
577au BufNewFile,BufRead *.ec,*.EC			setf esqlc
578
579" Esterel
580au BufNewFile,BufRead *.strl			setf esterel
581
582" Essbase script
583au BufNewFile,BufRead *.csc			setf csc
584
585" Exim
586au BufNewFile,BufRead exim.conf			setf exim
587
588" Expect
589au BufNewFile,BufRead *.exp			setf expect
590
591" Exports
592au BufNewFile,BufRead exports			setf exports
593
594" Factor
595au BufNewFile,BufRead *.factor			setf factor
596
597" Fetchmail RC file
598au BufNewFile,BufRead .fetchmailrc		setf fetchmail
599
600" Focus Executable
601au BufNewFile,BufRead *.fex,*.focexec		setf focexec
602
603" Focus Master file (but not for auto.master)
604au BufNewFile,BufRead auto.master		setf conf
605au BufNewFile,BufRead *.mas,*.master		setf master
606
607" Forth
608au BufNewFile,BufRead *.fs,*.ft			setf forth
609
610" Fortran
611au BufNewFile,BufRead *.f,*.F,*.for,*.fpp,*.FPP,*.ftn,*.f77,*.F77,*.f90,*.F90,*.f95,*.F95	setf fortran
612
613" FStab
614au BufNewFile,BufRead fstab,mtab		setf fstab
615
616" GDB command files
617au BufNewFile,BufRead .gdbinit			setf gdb
618
619" GDMO
620au BufNewFile,BufRead *.mo,*.gdmo		setf gdmo
621
622" Gedcom
623au BufNewFile,BufRead *.ged			setf gedcom
624
625" Gkrellmrc
626au BufNewFile,BufRead gkrellmrc,gkrellmrc_?	setf gkrellmrc
627
628" GP scripts (2.0 and onward)
629au BufNewFile,BufRead *.gp,.gprc		setf gp
630
631" GPG
632au BufNewFile,BufRead */.gnupg/options		setf gpg
633au BufNewFile,BufRead */.gnupg/gpg.conf		setf gpg
634au BufNewFile,BufRead /usr/**/gnupg/options.skel setf gpg
635
636" Gnuplot scripts
637au BufNewFile,BufRead *.gpi			setf gnuplot
638
639" GrADS scripts
640au BufNewFile,BufRead *.gs			setf grads
641
642" Gretl
643au BufNewFile,BufRead *.gretl			setf gretl
644
645" Groovy
646au BufNewFile,BufRead *.groovy			setf groovy
647
648" GNU Server Pages
649au BufNewFile,BufRead *.gsp			setf gsp
650
651" Group file
652au BufNewFile,BufRead /etc/group		setf group
653
654" GTK RC
655au BufNewFile,BufRead .gtkrc,gtkrc		setf gtkrc
656
657" Haskell
658au BufNewFile,BufRead *.hs			setf haskell
659au BufNewFile,BufRead *.lhs			setf lhaskell
660au BufNewFile,BufRead *.chs			setf chaskell
661
662" Hercules
663au BufNewFile,BufRead *.vc,*.ev,*.rs,*.sum,*.errsum	setf hercules
664
665" HEX (Intel)
666au BufNewFile,BufRead *.hex,*.h32		setf hex
667
668" Tilde (must be before HTML)
669au BufNewFile,BufRead *.t.html			setf tilde
670
671" HTML (.shtml and .stm for server side)
672au BufNewFile,BufRead *.html,*.htm,*.shtml,*.stm  call s:FThtml()
673
674" Distinguish between HTML, XHTML and Django
675fun! s:FThtml()
676  let n = 1
677  while n < 10 && n < line("$")
678    if getline(n) =~ '\<DTD\s\+XHTML\s'
679      setf xhtml
680      return
681    endif
682    if getline(n) =~ '{%\s*\(extends\|block\)\>'
683      setf htmldjango
684      return
685    endif
686    let n = n + 1
687  endwhile
688  setf html
689endfun
690
691" HTML with Ruby - eRuby
692au BufNewFile,BufRead *.rhtml			setf eruby
693
694" HTML with M4
695au BufNewFile,BufRead *.html.m4			setf htmlm4
696
697" HTML Cheetah template
698au BufNewFile,BufRead *.tmpl			setf htmlcheetah
699
700" Hyper Builder
701au BufNewFile,BufRead *.hb			setf hb
702
703" Icon
704au BufNewFile,BufRead *.icn			setf icon
705
706" IDL (Interface Description Language)
707au BufNewFile,BufRead *.idl			call s:FTidl()
708
709" Distinguish between standard IDL and MS-IDL
710fun! s:FTidl()
711  let n = 1
712  while n < 50 && n < line("$")
713    if getline(n) =~ '^\s*import\s\+"\(unknwn\|objidl\)\.idl"'
714      setf msidl
715      return
716    endif
717    let n = n + 1
718  endwhile
719  setf idl
720endfun
721
722" Microsoft IDL (Interface Description Language)  Also *.idl
723" MOF = WMI (Windows Management Instrumentation) Managed Object Format
724au BufNewFile,BufRead *.odl,*.mof		setf msidl
725
726" Icewm menu
727au BufNewFile,BufRead */.icewm/menu		setf icemenu
728
729" IDL (Interactive Data Language)
730au BufNewFile,BufRead *.pro			setf idlang
731
732" Indent RC
733au BufNewFile,BufRead indentrc			setf indentrc
734
735" Inform
736au BufNewFile,BufRead .indent.pro		setf indent
737
738" Inform
739au BufNewFile,BufRead *.inf,*.INF		setf inform
740
741" Ipfilter
742au BufNewFile,BufRead ipf.conf,ipf.rules	setf ipfilter
743
744" Informix 4GL (source - canonical, include file, I4GL+M4 preproc.)
745au BufNewFile,BufRead *.4gl,*.4gh,*.m4gl	setf fgl
746
747" .INI file for MSDOS
748au BufNewFile,BufRead *.ini			setf dosini
749
750" SysV Inittab
751au BufNewFile,BufRead inittab			setf inittab
752
753" Inno Setup
754au BufNewFile,BufRead *.iss			setf iss
755
756" JAL
757au BufNewFile,BufRead *.jal,*.JAL		setf jal
758
759" Jam
760au BufNewFile,BufRead *.jpl,*.jpr		setf jam
761
762" Java
763au BufNewFile,BufRead *.java,*.jav		setf java
764
765" JavaCC
766au BufNewFile,BufRead *.jj,*.jjt		setf javacc
767
768" JavaScript
769au BufNewFile,BufRead *.js,*.javascript		setf javascript
770
771" Java Server Pages
772au BufNewFile,BufRead *.jsp			setf jsp
773
774" Java Properties resource file (note: doesn't catch font.properties.pl)
775au BufNewFile,BufRead *.properties,*.properties_??,*.properties_??_??	setf jproperties
776au BufNewFile,BufRead *.properties_??_??_*	call s:StarSetf('jproperties')
777
778" Jess
779au BufNewFile,BufRead *.clp			setf jess
780
781" Jgraph
782au BufNewFile,BufRead *.jgr			setf jgraph
783
784" Kixtart
785au BufNewFile,BufRead *.kix			setf kix
786
787" Kimwitu[++]
788au BufNewFile,BufRead *.k			setf kwt
789
790" KDE script
791au BufNewFile,BufRead *.ks			setf kscript
792
793" Kconfig
794au BufNewFile,BufRead Kconfig,Kconfig.debug	setf kconfig
795
796" Lace (ISE)
797au BufNewFile,BufRead *.ace,*.ACE		setf lace
798
799" Latte
800au BufNewFile,BufRead *.latte,*.lte		setf latte
801
802" Limits
803au BufNewFile,BufRead /etc/limits		setf limits
804
805" LambdaProlog (*.mod too, see Modsim)
806au BufNewFile,BufRead *.sig			setf lprolog
807
808" LDAP LDIF
809au BufNewFile,BufRead *.ldif			setf ldif
810
811" Ld loader
812au BufNewFile,BufRead *.ld			setf ld
813
814" Lex
815au BufNewFile,BufRead *.lex,*.l			setf lex
816
817" Libao
818au BufNewFile,BufRead /etc/libao.conf,*/.libao	setf libao
819
820" Libsensors
821au BufNewFile,BufRead /etc/sensors.conf		setf sensors
822
823" LFTP
824au BufNewFile,BufRead lftp.conf,.lftprc,*lftp/rc	setf lftp
825
826" Lifelines (or Lex for C++!)
827au BufNewFile,BufRead *.ll			setf lifelines
828
829" Lilo: Linux loader
830au BufNewFile,BufRead lilo.conf*		call s:StarSetf('lilo')
831
832" Lisp (*.el = ELisp, *.cl = Common Lisp, *.jl = librep Lisp)
833if has("fname_case")
834  au BufNewFile,BufRead *.lsp,*.lisp,*.el,*.cl,*.jl,*.L,.emacs,.sawfishrc setf lisp
835else
836  au BufNewFile,BufRead *.lsp,*.lisp,*.el,*.cl,*.jl,.emacs,.sawfishrc setf lisp
837endif
838
839" SBCL implementation of Common Lisp
840au BufNewFile,BufRead sbclrc,.sbclrc		setf lisp
841
842" Lite
843au BufNewFile,BufRead *.lite,*.lt		setf lite
844
845" Login access
846au BufNewFile,BufRead /etc/login.access		setf loginaccess
847
848" Login defs
849au BufNewFile,BufRead /etc/login.defs		setf logindefs
850
851" Logtalk
852au BufNewFile,BufRead *.lgt			setf logtalk
853
854" LOTOS
855au BufNewFile,BufRead *.lot,*.lotos		setf lotos
856
857" Lout (also: *.lt)
858au BufNewFile,BufRead *.lou,*.lout		setf lout
859
860" Lua
861au BufNewFile,BufRead *.lua			setf lua
862
863" Lynx style file (or LotusScript!)
864au BufNewFile,BufRead *.lss			setf lss
865
866" M4
867au BufNewFile,BufRead *.m4
868	\ if expand("<afile>") !~? 'html.m4$\|fvwm2rc' | setf m4 | endif
869
870" MaGic Point
871au BufNewFile,BufRead *.mgp			setf mgp
872
873" Mail (for Elm, trn, mutt, rn, slrn)
874au BufNewFile,BufRead snd.\d\+,.letter,.letter.\d\+,.followup,.article,.article.\d\+,pico.\d\+,mutt{ng,}-*-\w\+,mutt\w\{6\},ae\d\+.txt,/tmp/SLRN[0-9A-Z.]\+,*.eml setf mail
875
876" Mail aliases
877au BufNewFile,BufRead /etc/mail/aliases,/etc/aliases	setf mailaliases
878
879" Mailcap configuration file
880au BufNewFile,BufRead .mailcap,mailcap		setf mailcap
881
882" Makefile
883au BufNewFile,BufRead *[mM]akefile,*.mk,*.mak,*.dsp setf make
884
885" MakeIndex
886au BufNewFile,BufRead *.ist,*.mst		setf ist
887
888" Manpage
889au BufNewFile,BufRead *.man			setf man
890
891" Man config
892au BufNewFile,BufRead /etc/man.conf,man.config	setf manconf
893
894" Maple V
895au BufNewFile,BufRead *.mv,*.mpl,*.mws		setf maple
896
897" Mason
898au BufNewFile,BufRead *.mason,*.mhtml		setf mason
899
900" Matlab or Objective C
901au BufNewFile,BufRead *.m			call s:FTm()
902
903fun! s:FTm()
904  let n = 1
905  while n < 10
906    let line = getline(n)
907    if line =~ '^\s*\(#\s*\(include\|import\)\>\|/\*\)'
908      setf objc
909      return
910    endif
911    if line =~ '^\s*%'
912      setf matlab
913      return
914    endif
915    if line =~ '^\s*(\*'
916      setf mma
917      return
918    endif
919    let n = n + 1
920  endwhile
921  if exists("g:filetype_m")
922    exe "setf " . g:filetype_m
923  else
924    setf matlab
925  endif
926endfun
927
928" Maya Extension Language
929au BufNewFile,BufRead *.mel			setf mel
930
931" Metafont
932au BufNewFile,BufRead *.mf			setf mf
933
934" MetaPost
935au BufNewFile,BufRead *.mp			setf mp
936
937" MGL
938au BufNewFile,BufRead *.mgl			setf mgl
939
940" MMIX or VMS makefile
941au BufNewFile,BufRead *.mms			call s:FTmms()
942
943fun! s:FTmms()
944  let n = 1
945  while n < 10
946    let line = getline(n)
947    if line =~ '^\s*\(%\|//\)' || line =~ '^\*'
948      setf mmix
949      return
950    endif
951    if line =~ '^\s*#'
952      setf make
953      return
954    endif
955    let n = n + 1
956  endwhile
957  setf mmix
958endfun
959
960
961" Modsim III (or LambdaProlog)
962au BufNewFile,BufRead *.mod
963	\ if getline(1) =~ '\<module\>' |
964	\   setf lprolog |
965	\ else |
966	\   setf modsim3 |
967	\ endif
968
969" Modula 2
970au BufNewFile,BufRead *.m2,*.DEF,*.MOD,*.md,*.mi setf modula2
971
972" Modula 3 (.m3, .i3, .mg, .ig)
973au BufNewFile,BufRead *.[mi][3g]		setf modula3
974
975" Monk
976au BufNewFile,BufRead *.isc,*.monk,*.ssc,*.tsc	setf monk
977
978" MOO
979au BufNewFile,BufRead *.moo			setf moo
980
981" Modconf
982au BufNewFile,BufRead /etc/modules.conf,/etc/conf.modules	setf modconf
983au BufNewFile,BufRead /etc/modutils/*
984	\ if executable(expand("<afile>")) != 1
985	\|  call s:StarSetf('modconf')
986	\|endif
987
988" Mplayer config
989au BufNewFile,BufRead mplayer.conf,*/.mplayer/config	setf mplayerconf
990
991" Moterola S record
992au BufNewFile,BufRead *.s19,*.s28,*.s37		setf srec
993
994" Msql
995au BufNewFile,BufRead *.msql			setf msql
996
997" Mysql
998au BufNewFile,BufRead *.mysql			setf mysql
999
1000" M$ Resource files
1001au BufNewFile,BufRead *.rc			setf rc
1002
1003" MuPAD source
1004au BufRead,BufNewFile *.mu			setf mupad
1005
1006" Mush
1007au BufNewFile,BufRead *.mush			setf mush
1008
1009" Mutt setup file
1010au BufNewFile,BufRead Mutt{ng,}rc			setf muttrc
1011au BufNewFile,BufRead .mutt{ng,}rc*,*/.mutt{ng,}/mutt{ng,}rc*	call s:StarSetf('muttrc')
1012
1013" Nano
1014au BufNewFile,BufRead /etc/nanorc,.nanorc	setf nanorc
1015
1016" Nastran input/DMAP
1017"au BufNewFile,BufRead *.dat			setf nastran
1018
1019" Natural
1020au BufNewFile,BufRead *.NS[ACGLMNPS]		setf natural
1021
1022" Netrc
1023au BufNewFile,BufRead .netrc			setf netrc
1024
1025" Novell netware batch files
1026au BufNewFile,BufRead *.ncf			setf ncf
1027
1028" Nroff/Troff (*.ms and *.t are checked below)
1029au BufNewFile,BufRead *.me
1030	\ if expand("<afile>") != "read.me" && expand("<afile>") != "click.me" |
1031	\   setf nroff |
1032	\ endif
1033au BufNewFile,BufRead *.tr,*.nr,*.roff,*.tmac,*.mom	setf nroff
1034au BufNewFile,BufRead *.[1-9]			call s:FTnroff()
1035
1036" This function checks if one of the first five lines start with a dot.  In
1037" that case it is probably an nroff file: 'filetype' is set and 1 is returned.
1038fun! s:FTnroff()
1039  if getline(1)[0] . getline(2)[0] . getline(3)[0] . getline(4)[0] . getline(5)[0] =~ '\.'
1040    setf nroff
1041    return 1
1042  endif
1043  return 0
1044endfun
1045
1046" Nroff or Objective C++
1047au BufNewFile,BufRead *.mm			call s:FTmm()
1048
1049fun! s:FTmm()
1050  let n = 1
1051  while n < 10
1052    let line = getline(n)
1053    if line =~ '^\s*\(#\s*\(include\|import\)\>\|/\*\)'
1054      setf objcpp
1055      return
1056    endif
1057    let n = n + 1
1058  endwhile
1059  setf nroff
1060endfun
1061
1062" Not Quite C
1063au BufNewFile,BufRead *.nqc			setf nqc
1064
1065" NSIS
1066au BufNewFile,BufRead *.nsi			setf nsis
1067
1068" OCAML
1069au BufNewFile,BufRead *.ml,*.mli,*.mll,*.mly	setf ocaml
1070
1071" Occam
1072au BufNewFile,BufRead *.occ			setf occam
1073
1074" Omnimark
1075au BufNewFile,BufRead *.xom,*.xin		setf omnimark
1076
1077" OpenROAD
1078au BufNewFile,BufRead *.or			setf openroad
1079
1080" OPL
1081au BufNewFile,BufRead *.[Oo][Pp][Ll]		setf opl
1082
1083" Oracle config file
1084au BufNewFile,BufRead *.ora			setf ora
1085
1086" Packet filter conf
1087au BufNewFile,BufRead pf.conf			setf pf
1088
1089" Pam conf
1090au BufNewFile,BufRead /etc/pam.conf		setf pamconf
1091
1092" PApp
1093au BufNewFile,BufRead *.papp,*.pxml,*.pxsl	setf papp
1094
1095" Password file
1096au BufNewFile,BufRead /etc/passwd,/etc/shadow,/etc/shadow- setf passwd
1097
1098" Pascal (also *.p)
1099au BufNewFile,BufRead *.pas			setf pascal
1100
1101" Delphi project file
1102au BufNewFile,BufRead *.dpr			setf pascal
1103
1104" Perl
1105if has("fname_case")
1106  au BufNewFile,BufRead *.pl,*.PL		call s:FTpl()
1107else
1108  au BufNewFile,BufRead *.pl			call s:FTpl()
1109endif
1110au BufNewFile,BufRead *.plx			setf perl
1111
1112fun! s:FTpl()
1113  if exists("g:filetype_pl")
1114    exe "setf " . g:filetype_pl
1115  else
1116    " recognize Prolog by specific text in the first non-empty line
1117    " require a blank after the '%' because Perl uses "%list" and "%translate"
1118    let l = getline(nextnonblank(1))
1119    if l =~ '\<prolog\>' || l =~ '^\s*\(%\+\(\s\|$\)\|/\*\)' || l =~ ':-'
1120      setf prolog
1121    else
1122      setf perl
1123    endif
1124  endif
1125endfun
1126
1127" Perl, XPM or XPM2
1128au BufNewFile,BufRead *.pm
1129	\ if getline(1) =~ "XPM2" |
1130	\   setf xpm2 |
1131	\ elseif getline(1) =~ "XPM" |
1132	\   setf xpm |
1133	\ else |
1134	\   setf perl |
1135	\ endif
1136
1137" Perl POD
1138au BufNewFile,BufRead *.pod			setf pod
1139
1140" Php3
1141au BufNewFile,BufRead *.php,*.php3		setf php
1142
1143" Phtml
1144au BufNewFile,BufRead *.phtml			setf phtml
1145
1146" Pike
1147au BufNewFile,BufRead *.pike,*.lpc,*.ulpc,*.pmod setf pike
1148
1149" Pinfo config
1150au BufNewFile,BufRead */etc/pinforc,*/.pinforc	setf pinfo
1151
1152" Palm Resource compiler
1153au BufNewFile,BufRead *.rcp			setf pilrc
1154
1155" Pine config
1156au BufNewFile,BufRead .pinerc,pinerc,.pinercex,pinercex		setf pine
1157
1158" PL/M (also: *.inp)
1159au BufNewFile,BufRead *.plm,*.p36,*.pac		setf plm
1160
1161" PL/SQL
1162au BufNewFile,BufRead *.pls,*.plsql		setf plsql
1163
1164" PLP
1165au BufNewFile,BufRead *.plp			setf plp
1166
1167" PO and PO template (GNU gettext)
1168au BufNewFile,BufRead *.po,*.pot		setf po
1169
1170" Postfix main config
1171au BufNewFile,BufRead main.cf			setf pfmain
1172
1173" PostScript (+ font files, encapsulated PostScript, Adobe Illustrator)
1174au BufNewFile,BufRead *.ps,*.pfa,*.afm,*.eps,*.epsf,*.epsi,*.ai	  setf postscr
1175
1176" PostScript Printer Description
1177au BufNewFile,BufRead *.ppd			setf ppd
1178
1179" Povray
1180au BufNewFile,BufRead *.pov			setf pov
1181
1182" Povray configuration
1183au BufNewFile,BufRead .povrayrc			setf povini
1184
1185" Povray, PHP or assembly
1186au BufNewFile,BufRead *.inc			call s:FTinc()
1187
1188fun! s:FTinc()
1189  if exists("g:filetype_inc")
1190    exe "setf " . g:filetype_inc
1191  else
1192    let lines = getline(1).getline(2).getline(3)
1193    if lines =~? "perlscript"
1194      setf aspperl
1195    elseif lines =~ "<%"
1196      setf aspvbs
1197    elseif lines =~ "<?"
1198      setf php
1199    else
1200      call s:FTasmsyntax()
1201      if exists("b:asmsyntax")
1202	exe "setf " . b:asmsyntax
1203      else
1204	setf pov
1205      endif
1206    endif
1207  endif
1208endfun
1209
1210" Printcap and Termcap
1211au BufNewFile,BufRead *printcap
1212	\ let b:ptcap_type = "print" | setf ptcap
1213au BufNewFile,BufRead *termcap
1214	\ let b:ptcap_type = "term" | setf ptcap
1215
1216" PCCTS / ANTRL
1217"au BufNewFile,BufRead *.g			setf antrl
1218au BufNewFile,BufRead *.g			setf pccts
1219
1220" PPWizard
1221au BufNewFile,BufRead *.it,*.ih			setf ppwiz
1222
1223" Oracle Pro*C/C++
1224au BufNewFile,BufRead .pc			setf proc
1225
1226" Procmail
1227au BufNewFile,BufRead .procmail,.procmailrc	setf procmail
1228
1229" Progress or CWEB
1230au BufNewFile,BufRead *.w			call s:FTprogress_cweb()
1231
1232function! s:FTprogress_cweb()
1233  if exists("g:filetype_w")
1234    exe "setf " . g:filetype_w
1235    return
1236  endif
1237  if getline(1) =~ '&ANALYZE' || getline(3) =~ '&GLOBAL-DEFINE'
1238    setf progress
1239  else
1240    setf cweb
1241  endif
1242endfun
1243
1244" Progress or assembly
1245au BufNewFile,BufRead *.i			call s:FTprogress_asm()
1246
1247function! s:FTprogress_asm()
1248  if exists("g:filetype_i")
1249    exe "setf " . g:filetype_i
1250    return
1251  endif
1252  " This function checks for an assembly comment the first ten lines.
1253  " If not found, assume Progress.
1254  let lnum = 1
1255  while lnum <= 10 && lnum < line('$')
1256    let line = getline(lnum)
1257    if line =~ '^\s*;' || line =~ '^\*'
1258      call s:FTasm()
1259      return
1260    elseif line !~ '^\s*$' || line =~ '^/\*'
1261      " Not an empty line: Doesn't look like valid assembly code.
1262      " Or it looks like a Progress /* comment
1263      break
1264    endif
1265    let lnum = lnum + 1
1266  endw
1267  setf progress
1268endfun
1269
1270" Progress or Pascal
1271au BufNewFile,BufRead *.p			call s:FTprogress_pascal()
1272
1273function! s:FTprogress_pascal()
1274  if exists("g:filetype_p")
1275    exe "setf " . g:filetype_p
1276    return
1277  endif
1278  " This function checks for valid Pascal syntax in the first ten lines.
1279  " Look for either an opening comment or a program start.
1280  " If not found, assume Progress.
1281  let lnum = 1
1282  while lnum <= 10 && lnum < line('$')
1283    let line = getline(lnum)
1284    if line =~ '^\s*\(program\|unit\|procedure\|function\|const\|type\|var\)\>'
1285	\ || line =~ '^\s*{' || line =~ '^\s*(\*'
1286      setf pascal
1287      return
1288    elseif line !~ '^\s*$' || line =~ '^/\*'
1289      " Not an empty line: Doesn't look like valid Pascal code.
1290      " Or it looks like a Progress /* comment
1291      break
1292    endif
1293    let lnum = lnum + 1
1294  endw
1295  setf progress
1296endfun
1297
1298
1299" Software Distributor Product Specification File (POSIX 1387.2-1995)
1300au BufNewFile,BufRead *.psf			setf psf
1301au BufNewFile,BufRead INDEX,INFO
1302	\ if getline(1) =~ '^\s*\(distribution\|installed_software\|root\|bundle\|product\)\s*$' |
1303	\   setf psf |
1304	\ endif
1305
1306" Prolog
1307au BufNewFile,BufRead *.pdb			setf prolog
1308
1309" Protocols
1310au BufNewFile,BufRead /etc/protocols		setf protocols
1311
1312" Pyrex
1313au BufNewFile,BufRead *.pyx,*.pxd		setf pyrex
1314
1315" Python
1316au BufNewFile,BufRead *.py,*.pyw		setf python
1317
1318" Radiance
1319au BufNewFile,BufRead *.rad,*.mat		setf radiance
1320
1321" Ratpoison config/command files
1322au BufNewFile,BufRead .ratpoisonrc,ratpoisonrc	setf ratpoison
1323
1324" RCS file
1325au BufNewFile,BufRead *\,v			setf rcs
1326
1327" Readline
1328au BufNewFile,BufRead .inputrc,inputrc		setf readline
1329
1330" Registry for MS-Windows
1331au BufNewFile,BufRead *.reg
1332	\ if getline(1) =~? '^REGEDIT[0-9]*\s*$\|^Windows Registry Editor Version \d*\.\d*\s*$' | setf registry | endif
1333
1334" Renderman Interface Bytestream
1335au BufNewFile,BufRead *.rib			setf rib
1336
1337" Rexx
1338au BufNewFile,BufRead *.rexx,*.rex		setf rexx
1339
1340" R (Splus)
1341if has("fname_case")
1342  au BufNewFile,BufRead *.s,*.S			setf r
1343else
1344  au BufNewFile,BufRead *.s			setf r
1345endif
1346
1347" R Help file
1348if has("fname_case")
1349  au BufNewFile,BufRead *.rd,*.Rd		setf rhelp
1350else
1351  au BufNewFile,BufRead *.rd			setf rhelp
1352endif
1353
1354" R noweb file
1355if has("fname_case")
1356  au BufNewFile,BufRead *.Rnw,*.rnw,*.Snw,*.snw		setf rnoweb
1357else
1358  au BufNewFile,BufRead *.rnw,*.snw			setf rnoweb
1359endif
1360
1361" Rexx, Rebol or R
1362au BufNewFile,BufRead *.r,*.R			call s:FTr()
1363
1364fun! s:FTr()
1365  if getline(1) =~ '^REBOL'
1366    setf rebol
1367  else
1368    let n = 1
1369    let max = line("$")
1370    if max > 50
1371      let max = 50
1372    endif
1373    while n < max
1374      " R has # comments
1375      if getline(n) =~ '^\s*#'
1376	setf r
1377	break
1378      endif
1379      " Rexx has /* comments */
1380      if getline(n) =~ '^\s*/\*'
1381	setf rexx
1382	break
1383      endif
1384      let n = n + 1
1385    endwhile
1386    if n >= max
1387      setf rexx
1388    endif
1389  endif
1390endfun
1391
1392" Remind
1393au BufNewFile,BufRead .reminders*		call s:StarSetf('remind')
1394
1395" Resolv.conf
1396au BufNewFile,BufRead resolv.conf		setf resolv
1397
1398" Relax NG Compact
1399au BufNewFile,BufRead *.rnc			setf rnc
1400
1401" RPL/2
1402au BufNewFile,BufRead *.rpl			setf rpl
1403
1404" Robots.txt
1405au BufNewFile,BufRead robots.txt		setf robots
1406
1407" Rpcgen
1408au BufNewFile,BufRead *.x			setf rpcgen
1409
1410" reStructuredText Documentation Format
1411au BufNewFile,BufRead *.rst			setf rst
1412
1413" RTF
1414au BufNewFile,BufRead *.rtf			setf rtf
1415
1416" Ruby
1417au BufNewFile,BufRead *.rb,*.rbw,*.gem,*.gemspec	setf ruby
1418
1419" Rantfile is like Ruby
1420au BufNewFile,BufRead [rR]antfile,*.rant	setf ruby
1421
1422" S-lang (or shader language!)
1423au BufNewFile,BufRead *.sl			setf slang
1424
1425" Samba config
1426au BufNewFile,BufRead smb.conf			setf samba
1427
1428" SAS script
1429au BufNewFile,BufRead *.sas			setf sas
1430
1431" Sather
1432au BufNewFile,BufRead *.sa			setf sather
1433
1434" Scilab
1435au BufNewFile,BufRead *.sci,*.sce		setf scilab
1436
1437" SDL
1438au BufNewFile,BufRead *.sdl,*.pr		setf sdl
1439
1440" sed
1441au BufNewFile,BufRead *.sed			setf sed
1442
1443" Sieve (RFC 3028)
1444au BufNewFile,BufRead *.siv			setf sieve
1445
1446" Sendmail
1447au BufNewFile,BufRead sendmail.cf		setf sm
1448
1449" Sendmail .mc files are actually m4
1450au BufNewFile,BufRead *.mc			setf m4
1451
1452" Services
1453au BufNewFile,BufRead /etc/services		setf services
1454
1455" Service Location config
1456au BufNewFile,BufRead /etc/slp.conf		setf slpconf
1457
1458" Service Location registration
1459au BufNewFile,BufRead /etc/slp.reg		setf slpreg
1460
1461" Service Location SPI
1462au BufNewFile,BufRead /etc/slp.spi		setf slpspi
1463
1464" Setserial config
1465au BufNewFile,BufRead /etc/serial.conf		setf setserial
1466
1467" SGML
1468au BufNewFile,BufRead *.sgm,*.sgml
1469	\ if getline(1).getline(2).getline(3).getline(4).getline(5) =~? 'linuxdoc' |
1470	\   setf sgmllnx |
1471	\ elseif getline(1) =~ '<!DOCTYPE.*DocBook' || getline(2) =~ '<!DOCTYPE.*DocBook' |
1472	\   let b:docbk_type="sgml" |
1473	\   setf docbk |
1474	\ else |
1475	\   setf sgml |
1476	\ endif
1477
1478" SGMLDECL
1479au BufNewFile,BufRead *.decl,*.dcl,*.dec
1480	\ if getline(1).getline(2).getline(3) =~? '^<!SGML' |
1481	\    setf sgmldecl |
1482	\ endif
1483
1484" SGML catalog file
1485au BufNewFile,BufRead catalog			setf catalog
1486au BufNewFile,BufRead sgml.catalog*		call s:StarSetf('catalog')
1487
1488" Shell scripts (sh, ksh, bash, bash2, csh); Allow .profile_foo etc.
1489" Gentoo ebuilds are actually bash scripts
1490au BufNewFile,BufRead .bashrc*,bashrc,bash.bashrc,.bash_profile*,.bash_logout*,*.bash,*.ebuild call SetFileTypeSH("bash")
1491au BufNewFile,BufRead .kshrc*,*.ksh call SetFileTypeSH("ksh")
1492au BufNewFile,BufRead /etc/profile,.profile*,*.sh,*.env call SetFileTypeSH(getline(1))
1493
1494" Also called from scripts.vim.
1495fun! SetFileTypeSH(name)
1496  if expand("<amatch>") =~ g:ft_ignore_pat
1497    return
1498  endif
1499  if a:name =~ '\<ksh\>'
1500    let b:is_kornshell = 1
1501    if exists("b:is_bash")
1502      unlet b:is_bash
1503    endif
1504    if exists("b:is_sh")
1505      unlet b:is_sh
1506    endif
1507  elseif exists("g:bash_is_sh") || a:name =~ '\<bash\>' || a:name =~ '\<bash2\>'
1508    let b:is_bash = 1
1509    if exists("b:is_kornshell")
1510      unlet b:is_kornshell
1511    endif
1512    if exists("b:is_sh")
1513      unlet b:is_sh
1514    endif
1515  elseif a:name =~ '\<sh\>'
1516    let b:is_sh = 1
1517    if exists("b:is_kornshell")
1518      unlet b:is_kornshell
1519    endif
1520    if exists("b:is_bash")
1521      unlet b:is_bash
1522    endif
1523  endif
1524  call SetFileTypeShell("sh")
1525endfun
1526
1527" For shell-like file types, check for an "exec" command hidden in a comment,
1528" as used for Tcl.
1529" Also called from scripts.vim, thus can't be local to this script.
1530fun! SetFileTypeShell(name)
1531  if expand("<amatch>") =~ g:ft_ignore_pat
1532    return
1533  endif
1534  let l = 2
1535  while l < 20 && l < line("$") && getline(l) =~ '^\s*\(#\|$\)'
1536    " Skip empty and comment lines.
1537    let l = l + 1
1538  endwhile
1539  if l < line("$") && getline(l) =~ '\s*exec\s' && getline(l - 1) =~ '^\s*#.*\\$'
1540    " Found an "exec" line after a comment with continuation
1541    let n = substitute(getline(l),'\s*exec\s\+\([^ ]*/\)\=', '', '')
1542    if n =~ '\<tclsh\|\<wish'
1543      setf tcl
1544      return
1545    endif
1546  endif
1547  exe "setf " . a:name
1548endfun
1549
1550" tcsh scripts
1551au BufNewFile,BufRead .tcshrc*,*.tcsh,tcsh.tcshrc,tcsh.login	call SetFileTypeShell("tcsh")
1552
1553" csh scripts, but might also be tcsh scripts (on some systems csh is tcsh)
1554au BufNewFile,BufRead .login*,.cshrc*,csh.cshrc,csh.login,csh.logout,*.csh,.alias  call s:CSH()
1555
1556fun! s:CSH()
1557  if exists("g:filetype_csh")
1558    call SetFileTypeShell(g:filetype_csh)
1559  elseif &shell =~ "tcsh"
1560    call SetFileTypeShell("tcsh")
1561  else
1562    call SetFileTypeShell("csh")
1563  endif
1564endfun
1565
1566" Z-Shell script
1567au BufNewFile,BufRead .zprofile,/etc/zprofile,.zfbfmarks  setf zsh
1568au BufNewFile,BufRead .zsh*,.zlog*,.zcompdump*  call s:StarSetf('zsh')
1569
1570" Scheme
1571au BufNewFile,BufRead *.scm,*.ss		setf scheme
1572
1573" Screen RC
1574au BufNewFile,BufRead .screenrc,screenrc	setf screen
1575
1576" Simula
1577au BufNewFile,BufRead *.sim			setf simula
1578
1579" SINDA
1580au BufNewFile,BufRead *.sin,*.s85		setf sinda
1581
1582" SiSU
1583au BufNewFile,BufRead *.sst,*.ssm,*.ssi,*.-sst,*._ssi setf sisu
1584au BufNewFile,BufRead *.sst.meta,*.-sst.meta,*._sst.meta setf sisu
1585
1586" SKILL
1587au BufNewFile,BufRead *.il,*.ils,*.cdf		setf skill
1588
1589" SLRN
1590au BufNewFile,BufRead .slrnrc			setf slrnrc
1591au BufNewFile,BufRead *.score			setf slrnsc
1592
1593" Smalltalk (and TeX)
1594au BufNewFile,BufRead *.st			setf st
1595au BufNewFile,BufRead *.cls
1596	\ if getline(1) =~ '^%' |
1597	\  setf tex |
1598	\ else |
1599	\  setf st |
1600	\ endif
1601
1602" Smarty templates
1603au BufNewFile,BufRead *.tpl			setf smarty
1604
1605" SMIL or XML
1606au BufNewFile,BufRead *.smil
1607	\ if getline(1) =~ '<?\s*xml.*?>' |
1608	\   setf xml |
1609	\ else |
1610	\   setf smil |
1611	\ endif
1612
1613" SMIL or SNMP MIB file
1614au BufNewFile,BufRead *.smi
1615	\ if getline(1) =~ '\<smil\>' |
1616	\   setf smil |
1617	\ else |
1618	\   setf mib |
1619	\ endif
1620
1621" SMITH
1622au BufNewFile,BufRead *.smt,*.smith		setf smith
1623
1624" Snobol4
1625au BufNewFile,BufRead *.sno			setf snobol4
1626
1627" SNMP MIB files
1628au BufNewFile,BufRead *.mib,*.my		setf mib
1629
1630" Snort Configuration
1631au BufNewFile,BufRead *.hog,snort.conf,vision.conf,*.rules	setf hog
1632
1633" Spec (Linux RPM)
1634au BufNewFile,BufRead *.spec			setf spec
1635
1636" Speedup (AspenTech plant simulator)
1637au BufNewFile,BufRead *.speedup,*.spdata,*.spd	setf spup
1638
1639" Slice
1640au BufNewFile,BufRead *.ice			setf slice
1641
1642" Spice
1643au BufNewFile,BufRead *.sp,*.spice		setf spice
1644
1645" Spyce
1646au BufNewFile,BufRead *.spy,*.spi		setf spyce
1647
1648" Squid
1649au BufNewFile,BufRead squid.conf		setf squid
1650
1651" SQL for Oracle Designer
1652au BufNewFile,BufRead *.tyb,*.typ,*.tyc,*.pkb,*.pks	setf sql
1653
1654" SQL
1655au BufNewFile,BufRead *.sql			call s:SQL()
1656
1657fun! s:SQL()
1658  if exists("g:filetype_sql")
1659    exe "setf " . g:filetype_sql
1660  else
1661    setf sql
1662  endif
1663endfun
1664
1665" SQLJ
1666au BufNewFile,BufRead *.sqlj			setf sqlj
1667
1668" SQR
1669au BufNewFile,BufRead *.sqr,*.sqi		setf sqr
1670
1671" OpenSSH configuration
1672au BufNewFile,BufRead ssh_config,*/.ssh/config	setf sshconfig
1673
1674" OpenSSH server configuration
1675au BufNewFile,BufRead sshd_config		setf sshdconfig
1676
1677" Stata
1678au BufNewFile,BufRead *.ado,*.class,*.do,*.imata,*.mata   setf stata
1679
1680" SMCL
1681au BufNewFile,BufRead *.hlp,*.ihlp,*.smcl	setf smcl
1682
1683" Stored Procedures
1684au BufNewFile,BufRead *.stp			setf stp
1685
1686" Standard ML
1687au BufNewFile,BufRead *.sml			setf sml
1688
1689" Sysctl
1690au BufNewFile,BufRead /etc/sysctl.conf		setf sysctl
1691
1692" Sudoers
1693au BufNewFile,BufRead /etc/sudoers,sudoers.tmp	setf sudoers
1694
1695" If the file has an extension of 't' and is in a directory 't' then it is
1696" almost certainly a Perl test file.
1697" If the first line starts with '#' and contains 'perl' it's probably a Perl
1698" file.
1699" (Slow test) If a file contains a 'use' statement then it is almost certainly
1700" a Perl file.
1701fun! s:FTperl()
1702  if expand("%:e") == 't' && expand("%:p:h:t") == 't'
1703    setf perl
1704    return 1
1705  endif
1706  if getline(1)[0] == '#' && getline(1) =~ 'perl'
1707    setf perl
1708    return 1
1709  endif
1710  if search('^use\s\s*\k', 'nc', 30)
1711    setf perl
1712    return 1
1713  endif
1714  return 0
1715endfun
1716
1717" Tads (or Nroff or Perl test file)
1718au BufNewFile,BufRead *.t
1719	\ if !s:FTnroff() && !s:FTperl() | setf tads | endif
1720
1721" Tags
1722au BufNewFile,BufRead tags			setf tags
1723
1724" TAK
1725au BufNewFile,BufRead *.tak			setf tak
1726
1727" Tcl (JACL too)
1728au BufNewFile,BufRead *.tcl,*.tk,*.itcl,*.itk,*.jacl	setf tcl
1729
1730" TealInfo
1731au BufNewFile,BufRead *.tli			setf tli
1732
1733" Telix Salt
1734au BufNewFile,BufRead *.slt			setf tsalt
1735
1736" Terminfo
1737au BufNewFile,BufRead *.ti			setf terminfo
1738
1739" TeX
1740au BufNewFile,BufRead *.latex,*.sty,*.dtx,*.ltx,*.bbl	setf tex
1741au BufNewFile,BufRead *.tex			call s:FTtex()
1742
1743" Choose context, plaintex, or tex (LaTeX) based on these rules:
1744" 1. Check the first line of the file for "%&<format>".
1745" 2. Check the first 1000 non-comment lines for LaTeX or ConTeXt keywords.
1746" 3. Default to "latex" or to g:tex_flavor, can be set in user's vimrc.
1747fun! s:FTtex()
1748  let firstline = getline(1)
1749  if firstline =~ '^%&\s*\a\+'
1750    let format = tolower(matchstr(firstline, '\a\+'))
1751    let format = substitute(format, 'pdf', '', '')
1752    if format == 'tex'
1753      let format = 'plain'
1754    endif
1755  else
1756    " Default value, may be changed later:
1757    let format = exists("g:tex_flavor") ? g:tex_flavor : 'plain'
1758    " Save position, go to the top of the file, find first non-comment line.
1759    let save_cursor = getpos('.')
1760    call cursor(1,1)
1761    let firstNC = search('^\s*[^[:space:]%]', 'c', 1000)
1762    if firstNC " Check the next thousand lines for a LaTeX or ConTeXt keyword.
1763      let lpat = 'documentclass\>\|usepackage\>\|begin{\|newcommand\>\|renewcommand\>'
1764      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\>'
1765      let kwline = search('^\s*\\\%(' . lpat . '\)\|^\s*\\\(' . cpat . '\)',
1766			      \ 'cnp', firstNC + 1000)
1767      if kwline == 1	" lpat matched
1768	let format = 'latex'
1769      elseif kwline == 2	" cpat matched
1770	let format = 'context'
1771      endif		" If neither matched, keep default set above.
1772      " let lline = search('^\s*\\\%(' . lpat . '\)', 'cn', firstNC + 1000)
1773      " let cline = search('^\s*\\\%(' . cpat . '\)', 'cn', firstNC + 1000)
1774      " if cline > 0
1775      "   let format = 'context'
1776      " endif
1777      " if lline > 0 && (cline == 0 || cline > lline)
1778      "   let format = 'tex'
1779      " endif
1780    endif " firstNC
1781    call setpos('.', save_cursor)
1782  endif " firstline =~ '^%&\s*\a\+'
1783
1784  " Translation from formats to file types.  TODO:  add AMSTeX, RevTex, others?
1785  if format == 'plain'
1786    setf plaintex
1787  elseif format == 'context'
1788    setf context
1789  else " probably LaTeX
1790    setf tex
1791  endif
1792  return
1793endfun
1794
1795" Context
1796au BufNewFile,BufRead tex/context/*/*.tex	setf context
1797
1798" Texinfo
1799au BufNewFile,BufRead *.texinfo,*.texi,*.txi	setf texinfo
1800
1801" TeX configuration
1802au BufNewFile,BufRead texmf.cnf			setf texmf
1803
1804" Tidy config
1805au BufNewFile,BufRead .tidyrc,tidyrc		setf tidy
1806
1807" TF mud client
1808au BufNewFile,BufRead *.tf,.tfrc,tfrc		setf tf
1809
1810" TPP - Text Presentation Program
1811au BufNewFile,BufReadPost *.tpp			setf tpp
1812
1813" Trustees
1814au BufNewFile,BufRead trustees.conf		setf trustees
1815
1816" TSS - Geometry
1817au BufNewFile,BufReadPost *.tssgm		setf tssgm
1818
1819" TSS - Optics
1820au BufNewFile,BufReadPost *.tssop		setf tssop
1821
1822" TSS - Command Line (temporary)
1823au BufNewFile,BufReadPost *.tsscl		setf tsscl
1824
1825" Motif UIT/UIL files
1826au BufNewFile,BufRead *.uit,*.uil		setf uil
1827
1828" Udev conf
1829au BufNewFile,BufRead /etc/udev/udev.conf	setf udevconf
1830
1831" Udev rules
1832au BufNewFile,BufRead /etc/udev/rules.d/*.rules setf udevrules
1833
1834" Udev permissions
1835au BufNewFile,BufRead /etc/udev/permissions.d/*.permissions setf udevperm
1836"
1837" Udev symlinks config
1838au BufNewFile,BufRead /etc/udev/cdsymlinks.conf	setf sh
1839
1840" UnrealScript
1841au BufNewFile,BufRead *.uc			setf uc
1842
1843" Updatedb
1844au BufNewFile,BufRead /etc/updatedb.conf	setf updatedb
1845
1846" Vera
1847au BufNewFile,BufRead *.vr,*.vri,*.vrh		setf vera
1848
1849" Verilog HDL
1850au BufNewFile,BufRead *.v			setf verilog
1851
1852" Verilog-AMS HDL
1853au BufNewFile,BufRead *.va,*.vams		setf verilogams
1854
1855" VHDL
1856au BufNewFile,BufRead *.hdl,*.vhd,*.vhdl,*.vbe,*.vst  setf vhdl
1857au BufNewFile,BufRead *.vhdl_[0-9]*		call s:StarSetf('vhdl')
1858
1859" Vim script
1860au BufNewFile,BufRead *.vim,*.vba,.exrc,_exrc	setf vim
1861
1862" Viminfo file
1863au BufNewFile,BufRead .viminfo,_viminfo		setf viminfo
1864
1865" Virata Config Script File
1866au BufRead,BufNewFile *.hw,*.module,*.pkg	setf virata
1867
1868" Visual Basic (also uses *.bas) or FORM
1869au BufNewFile,BufRead *.frm			call s:FTVB("form")
1870
1871" SaxBasic is close to Visual Basic
1872au BufNewFile,BufRead *.sba			setf vb
1873
1874" Vgrindefs file
1875au BufNewFile,BufRead vgrindefs			setf vgrindefs
1876
1877" VRML V1.0c
1878au BufNewFile,BufRead *.wrl			setf vrml
1879
1880" Webmacro
1881au BufNewFile,BufRead *.wm			setf webmacro
1882
1883" Wget config
1884au BufNewFile,BufRead .wgetrc,wgetrc		setf wget
1885
1886" Website MetaLanguage
1887au BufNewFile,BufRead *.wml			setf wml
1888
1889" Winbatch
1890au BufNewFile,BufRead *.wbt			setf winbatch
1891
1892" WSML
1893au BufNewFile,BufRead *.wsml			setf wsml
1894
1895" WvDial
1896au BufNewFile,BufRead wvdial.conf,.wvdialrc	setf wvdial
1897
1898" CVS RC file
1899au BufNewFile,BufRead .cvsrc			setf cvsrc
1900
1901" CVS commit file
1902au BufNewFile,BufRead cvs\d\+			setf cvs
1903
1904" WEB (*.web is also used for Winbatch: Guess, based on expecting "%" comment
1905" lines in a WEB file).
1906au BufNewFile,BufRead *.web
1907	\ if getline(1)[0].getline(2)[0].getline(3)[0].getline(4)[0].getline(5)[0] =~ "%" |
1908	\   setf web |
1909	\ else |
1910	\   setf winbatch |
1911	\ endif
1912
1913" Windows Scripting Host and Windows Script Component
1914au BufNewFile,BufRead *.ws[fc]			setf wsh
1915
1916" X Pixmap (dynamically sets colors, use BufEnter to make it work better)
1917au BufEnter *.xpm
1918	\ if getline(1) =~ "XPM2" |
1919	\   setf xpm2 |
1920	\ else |
1921	\   setf xpm |
1922	\ endif
1923au BufEnter *.xpm2				setf xpm2
1924
1925" XFree86 config
1926au BufNewFile,BufRead XF86Config
1927	\ if getline(1) =~ '\<XConfigurator\>' |
1928	\   let b:xf86c_xfree86_version = 3 |
1929	\ endif |
1930	\ setf xf86conf
1931
1932" Xorg config
1933au BufNewFile,BufRead xorg.conf,xorg.conf-4	let b:xf86c_xfree86_version = 4 | setf xf86conf
1934
1935" Xinetd conf
1936au BufNewFile,BufRead /etc/xinetd.conf		setf xinetd
1937
1938" XS Perl extension interface language
1939au BufNewFile,BufRead *.xs			setf xs
1940
1941" X resources file
1942au BufNewFile,BufRead .Xdefaults,.Xpdefaults,.Xresources,xdm-config,*.ad setf xdefaults
1943
1944" Xmath
1945au BufNewFile,BufRead *.msc,*.msf		setf xmath
1946au BufNewFile,BufRead *.ms
1947	\ if !s:FTnroff() | setf xmath | endif
1948
1949" XML
1950au BufNewFile,BufRead *.xml
1951	\ if getline(1) . getline(2) . getline(3) =~ '<!DOCTYPE.*DocBook' |
1952	\   let b:docbk_type="xml" |
1953	\   setf docbk |
1954	\ else |
1955	\   setf xml |
1956	\ endif
1957
1958" XMI (holding UML models) is also XML
1959au BufNewFile,BufRead *.xmi			setf xml
1960
1961" CSPROJ files are Visual Studio.NET's XML-based project config files
1962au BufNewFile,BufRead *.csproj,*.csproj.user	setf xml
1963
1964" Qt Linguist translation source and Qt User Interface Files are XML
1965au BufNewFile,BufRead *.ts,*.ui			setf xml
1966
1967" Xdg menus
1968au BufNewFile,BufRead /etc/xdg/menus/*.menu	setf xml
1969
1970" Xquery
1971au BufNewFile,BufRead *.xq,*.xql,*.xqm,*.xquery,*.xqy	setf xquery
1972
1973" XSD
1974au BufNewFile,BufRead *.xsd			setf xsd
1975
1976" Xslt
1977au BufNewFile,BufRead *.xsl,*.xslt		setf xslt
1978
1979" Yacc
1980au BufNewFile,BufRead *.yy			setf yacc
1981
1982" Yacc or racc
1983au BufNewFile,BufRead *.y			call s:FTy()
1984
1985fun! s:FTy()
1986  let n = 1
1987  while n < 100 && n < line("$")
1988    let line = getline(n)
1989    if line =~ '^\s*%'
1990      setf yacc
1991      return
1992    endif
1993    if getline(n) =~ '^\s*\(#\|class\>\)' && getline(n) !~ '^\s*#\s*include'
1994      setf racc
1995      return
1996    endif
1997    let n = n + 1
1998  endwhile
1999  setf yacc
2000endfun
2001
2002
2003" Yaml
2004au BufNewFile,BufRead *.yaml,*.yml		setf yaml
2005
2006" Zope
2007"   dtml (zope dynamic template markup language), pt (zope page template),
2008"   cpt (zope form controller page template)
2009au BufNewFile,BufRead *.dtml,*.pt,*.cpt		call s:FThtml()
2010"   zsql (zope sql method)
2011au BufNewFile,BufRead *.zsql			call s:SQL()
2012
2013" Z80 assembler asz80
2014au BufNewFile,BufRead *.z8a			setf z8a
2015
2016augroup END
2017
2018
2019" Source the user-specified filetype file, for backwards compatibility with
2020" Vim 5.x.
2021if exists("myfiletypefile") && filereadable(expand(myfiletypefile))
2022  execute "source " . myfiletypefile
2023endif
2024
2025
2026" Check for "*" after loading myfiletypefile, so that scripts.vim is only used
2027" when there are no matching file name extensions.
2028" Don't do this for compressed files.
2029augroup filetypedetect
2030au BufNewFile,BufRead *
2031	\ if !did_filetype() && expand("<amatch>") !~ g:ft_ignore_pat
2032	\ | runtime! scripts.vim | endif
2033au StdinReadPost * if !did_filetype() | runtime! scripts.vim | endif
2034
2035
2036" Extra checks for when no filetype has been detected now.  Mostly used for
2037" patterns that end in "*".  E.g., "zsh*" matches "zsh.vim", but that's a Vim
2038" script file.
2039" Most of these should call s:StarSetf() to avoid names ending in .gz and the
2040" like are used.
2041
2042" Asterisk config file
2043au BufNewFile,BufRead *asterisk/*.conf*         call s:StarSetf('asterisk')
2044au BufNewFile,BufRead *asterisk*/*voicemail.conf* call s:StarSetf('asteriskvm')
2045
2046" BIND zone
2047au BufNewFile,BufRead */named/db.*,*/bind/db.*	call s:StarSetf('bindzone')
2048
2049" Changelog
2050au BufNewFile,BufRead [cC]hange[lL]og*
2051	\ if getline(1) =~ '; urgency='
2052	\|  call s:StarSetf('debchangelog')
2053	\|else
2054	\|  call s:StarSetf('changelog')
2055	\|endif
2056
2057" Crontab
2058au BufNewFile,BufRead crontab,crontab.*		call s:StarSetf('crontab')
2059
2060" Debian Sources.list
2061au BufNewFile,BufRead /etc/apt/sources.list.d/*	call s:StarSetf('debsources')
2062
2063" Dracula
2064au BufNewFile,BufRead drac.*			call s:StarSetf('dracula')
2065
2066" Fvwm
2067au BufNewFile,BufRead *fvwmrc*,*fvwm95*.hook
2068	\ let b:fvwm_version = 1 | call s:StarSetf('fvwm')
2069au BufNewFile,BufRead *fvwm2rc*
2070	\ if expand("<afile>:e") == "m4"
2071	\|  call s:StarSetf('fvwm2m4')
2072	\|else
2073	\|  let b:fvwm_version = 2 | call s:StarSetf('fvwm')
2074	\|endif
2075
2076" GTK RC
2077au BufNewFile,BufRead .gtkrc*,gtkrc*		call s:StarSetf('gtkrc')
2078
2079" Jam
2080au BufNewFile,BufRead Prl*.*,JAM*.*		call s:StarSetf('jam')
2081
2082" Jargon
2083au! BufNewFile,BufRead *jarg*
2084	\ if getline(1).getline(2).getline(3).getline(4).getline(5) =~? 'THIS IS THE JARGON FILE'
2085	\|  call s:StarSetf('jargon')
2086	\|endif
2087
2088" Kconfig
2089au BufNewFile,BufRead Kconfig.*			call s:StarSetf('kconfig')
2090
2091" Makefile
2092au BufNewFile,BufRead [mM]akefile*		call s:StarSetf('make')
2093
2094" Modconf
2095au BufNewFile,BufRead /etc/modprobe.*		call s:StarSetf('modconf')
2096
2097" Ruby Makefile
2098au BufNewFile,BufRead [rR]akefile*		call s:StarSetf('ruby')
2099
2100" Mutt setup file
2101au BufNewFile,BufRead mutt{ng,}rc*,Mutt{ng,}rc*		call s:StarSetf('muttrc')
2102
2103" Nroff macros
2104au BufNewFile,BufRead tmac.*			call s:StarSetf('nroff')
2105
2106" Pam conf
2107au BufNewFile,BufRead /etc/pam.d/*		call s:StarSetf('pamconf')
2108
2109" Printcap and Termcap
2110au BufNewFile,BufRead *printcap*
2111	\ if !did_filetype()
2112	\|  let b:ptcap_type = "print" | call s:StarSetf('ptcap')
2113	\|endif
2114au BufNewFile,BufRead *termcap*
2115	\ if !did_filetype()
2116	\|  let b:ptcap_type = "term" | call s:StarSetf('ptcap')
2117	\|endif
2118
2119" Vim script
2120au BufNewFile,BufRead *vimrc*			call s:StarSetf('vim')
2121
2122" Subversion commit file
2123au BufNewFile,BufRead svn-commit*.tmp		setf svn
2124
2125" X resources file
2126au BufNewFile,BufRead Xresources*,*/app-defaults/*,*/Xresources/* call s:StarSetf('xdefaults')
2127
2128" XFree86 config
2129au BufNewFile,BufRead XF86Config-4*
2130	\ let b:xf86c_xfree86_version = 4 | call s:StarSetf('xf86conf')
2131au BufNewFile,BufRead XF86Config*
2132	\ if getline(1) =~ '\<XConfigurator\>'
2133	\|  let b:xf86c_xfree86_version = 3
2134	\|endif
2135	\|call s:StarSetf('xf86conf')
2136
2137" X11 xmodmap
2138au BufNewFile,BufRead *xmodmap*			call s:StarSetf('xmodmap')
2139
2140" Xinetd conf
2141au BufNewFile,BufRead /etc/xinetd.d/*		call s:StarSetf('xinetd')
2142
2143" Z-Shell script
2144au BufNewFile,BufRead zsh*,zlog*		call s:StarSetf('zsh')
2145
2146
2147" Generic configuration file (check this last, it's just guessing!)
2148au BufNewFile,BufRead,StdinReadPost *
2149	\ if !did_filetype() && expand("<amatch>") !~ g:ft_ignore_pat
2150	\    && (getline(1) =~ '^#' || getline(2) =~ '^#' || getline(3) =~ '^#'
2151	\	|| getline(4) =~ '^#' || getline(5) =~ '^#') |
2152	\   setf conf |
2153	\ endif
2154
2155" Use the plugin-filetype checks last, they may overrule any of the previously
2156" detected filetypes.
2157runtime! ftdetect/*.vim
2158
2159augroup END
2160
2161
2162" If the GUI is already running, may still need to install the Syntax menu.
2163" Don't do it when the 'M' flag is included in 'guioptions'.
2164if has("menu") && has("gui_running")
2165      \ && !exists("did_install_syntax_menu") && &guioptions !~# "M"
2166  source <sfile>:p:h/menu.vim
2167endif
2168
2169" Restore 'cpoptions'
2170let &cpo = s:cpo_save
2171unlet s:cpo_save
2172