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