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