xref: /vim-8.2.3635/runtime/filetype.vim (revision 7571d55f)
1" Vim support file to detect file types
2"
3" Maintainer:	Bram Moolenaar <[email protected]>
4" Last Change:	2016 Aug 18
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" Embedix Component Description
680au BufNewFile,BufRead *.ecd			setf ecd
681
682" Eiffel or Specman or Euphoria
683au BufNewFile,BufRead *.e,*.E			call s:FTe()
684
685" Elinks configuration
686au BufNewFile,BufRead */etc/elinks.conf,*/.elinks/elinks.conf	setf elinks
687
688func! s:FTe()
689  if exists('g:filetype_euphoria')
690    exe 'setf ' . g:filetype_euphoria
691  else
692    let n = 1
693    while n < 100 && n < line("$")
694      if getline(n) =~ "^\\s*\\(<'\\|'>\\)\\s*$"
695        setf specman
696        return
697      endif
698      let n = n + 1
699    endwhile
700    setf eiffel
701  endif
702endfunc
703
704" ERicsson LANGuage; Yaws is erlang too
705au BufNewFile,BufRead *.erl,*.hrl,*.yaws	setf erlang
706
707" Elm Filter Rules file
708au BufNewFile,BufRead filter-rules		setf elmfilt
709
710" ESMTP rc file
711au BufNewFile,BufRead *esmtprc			setf esmtprc
712
713" ESQL-C
714au BufNewFile,BufRead *.ec,*.EC			setf esqlc
715
716" Esterel
717au BufNewFile,BufRead *.strl			setf esterel
718
719" Essbase script
720au BufNewFile,BufRead *.csc			setf csc
721
722" Exim
723au BufNewFile,BufRead exim.conf			setf exim
724
725" Expect
726au BufNewFile,BufRead *.exp			setf expect
727
728" Exports
729au BufNewFile,BufRead exports			setf exports
730
731" Falcon
732au BufNewFile,BufRead *.fal			setf falcon
733
734" Fantom
735au BufNewFile,BufRead *.fan,*.fwt		setf fan
736
737" Factor
738au BufNewFile,BufRead *.factor			setf factor
739
740" Fetchmail RC file
741au BufNewFile,BufRead .fetchmailrc		setf fetchmail
742
743" FlexWiki - disabled, because it has side effects when a .wiki file
744" is not actually FlexWiki
745"au BufNewFile,BufRead *.wiki			setf flexwiki
746
747" Focus Executable
748au BufNewFile,BufRead *.fex,*.focexec		setf focexec
749
750" Focus Master file (but not for auto.master)
751au BufNewFile,BufRead auto.master		setf conf
752au BufNewFile,BufRead *.mas,*.master		setf master
753
754" Forth
755au BufNewFile,BufRead *.fs,*.ft			setf forth
756
757" Reva Forth
758au BufNewFile,BufRead *.frt			setf reva
759
760" Fortran
761if has("fname_case")
762  au BufNewFile,BufRead *.F,*.FOR,*.FPP,*.FTN,*.F77,*.F90,*.F95,*.F03,*.F08	 setf fortran
763endif
764au BufNewFile,BufRead   *.f,*.for,*.fortran,*.fpp,*.ftn,*.f77,*.f90,*.f95,*.f03,*.f08  setf fortran
765
766" Framescript
767au BufNewFile,BufRead *.fsl			setf framescript
768
769" FStab
770au BufNewFile,BufRead fstab,mtab		setf fstab
771
772" GDB command files
773au BufNewFile,BufRead .gdbinit			setf gdb
774
775" GDMO
776au BufNewFile,BufRead *.mo,*.gdmo		setf gdmo
777
778" Gedcom
779au BufNewFile,BufRead *.ged,lltxxxxx.txt	setf gedcom
780
781" Git
782au BufNewFile,BufRead COMMIT_EDITMSG,MERGE_MSG,TAG_EDITMSG setf gitcommit
783au BufNewFile,BufRead *.git/config,.gitconfig,.gitmodules setf gitconfig
784au BufNewFile,BufRead *.git/modules/*/config	setf gitconfig
785au BufNewFile,BufRead */.config/git/config	setf gitconfig
786if !empty($XDG_CONFIG_HOME)
787  au BufNewFile,BufRead $XDG_CONFIG_HOME/git/config	setf gitconfig
788endif
789au BufNewFile,BufRead git-rebase-todo		setf gitrebase
790au BufNewFile,BufRead .msg.[0-9]*
791      \ if getline(1) =~ '^From.*# This line is ignored.$' |
792      \   setf gitsendemail |
793      \ endif
794au BufNewFile,BufRead *.git/*
795      \ if getline(1) =~ '^\x\{40\}\>\|^ref: ' |
796      \   setf git |
797      \ endif
798
799" Gkrellmrc
800au BufNewFile,BufRead gkrellmrc,gkrellmrc_?	setf gkrellmrc
801
802" GP scripts (2.0 and onward)
803au BufNewFile,BufRead *.gp,.gprc		setf gp
804
805" GPG
806au BufNewFile,BufRead */.gnupg/options		setf gpg
807au BufNewFile,BufRead */.gnupg/gpg.conf		setf gpg
808au BufNewFile,BufRead */usr/*/gnupg/options.skel setf gpg
809
810" gnash(1) configuration files
811au BufNewFile,BufRead gnashrc,.gnashrc,gnashpluginrc,.gnashpluginrc setf gnash
812
813" Gitolite
814au BufNewFile,BufRead gitolite.conf		setf gitolite
815au BufNewFile,BufRead */gitolite-admin/conf/*	call s:StarSetf('gitolite')
816au BufNewFile,BufRead {,.}gitolite.rc,example.gitolite.rc	setf perl
817
818" Gnuplot scripts
819au BufNewFile,BufRead *.gpi			setf gnuplot
820
821" Go (Google)
822au BufNewFile,BufRead *.go			setf go
823
824" GrADS scripts
825au BufNewFile,BufRead *.gs			setf grads
826
827" Gretl
828au BufNewFile,BufRead *.gretl			setf gretl
829
830" Groovy
831au BufNewFile,BufRead *.gradle,*.groovy		setf groovy
832
833" GNU Server Pages
834au BufNewFile,BufRead *.gsp			setf gsp
835
836" Group file
837au 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
838
839" GTK RC
840au BufNewFile,BufRead .gtkrc,gtkrc		setf gtkrc
841
842" Haml
843au BufNewFile,BufRead *.haml			setf haml
844
845" Hamster Classic | Playground files
846au BufNewFile,BufRead *.hsc,*.hsm		setf hamster
847
848" Haskell
849au BufNewFile,BufRead *.hs,*.hs-boot		setf haskell
850au BufNewFile,BufRead *.lhs			setf lhaskell
851au BufNewFile,BufRead *.chs			setf chaskell
852
853" Haste
854au BufNewFile,BufRead *.ht			setf haste
855au BufNewFile,BufRead *.htpp			setf hastepreproc
856
857" Hercules
858au BufNewFile,BufRead *.vc,*.ev,*.rs,*.sum,*.errsum	setf hercules
859
860" HEX (Intel)
861au BufNewFile,BufRead *.hex,*.h32		setf hex
862
863" Tilde (must be before HTML)
864au BufNewFile,BufRead *.t.html			setf tilde
865
866" HTML (.shtml and .stm for server side)
867au BufNewFile,BufRead *.html,*.htm,*.shtml,*.stm  call s:FThtml()
868
869" Distinguish between HTML, XHTML and Django
870func! s:FThtml()
871  let n = 1
872  while n < 10 && n < line("$")
873    if getline(n) =~ '\<DTD\s\+XHTML\s'
874      setf xhtml
875      return
876    endif
877    if getline(n) =~ '{%\s*\(extends\|block\|load\)\>\|{#\s\+'
878      setf htmldjango
879      return
880    endif
881    let n = n + 1
882  endwhile
883  setf html
884endfunc
885
886" HTML with Ruby - eRuby
887au BufNewFile,BufRead *.erb,*.rhtml		setf eruby
888
889" HTML with M4
890au BufNewFile,BufRead *.html.m4			setf htmlm4
891
892" HTML Cheetah template
893au BufNewFile,BufRead *.tmpl			setf htmlcheetah
894
895" Host config
896au BufNewFile,BufRead */etc/host.conf		setf hostconf
897
898" Hosts access
899au BufNewFile,BufRead */etc/hosts.allow,*/etc/hosts.deny  setf hostsaccess
900
901" Hyper Builder
902au BufNewFile,BufRead *.hb			setf hb
903
904" Httest
905au BufNewFile,BufRead *.htt,*.htb		setf httest
906
907" Icon
908au BufNewFile,BufRead *.icn			setf icon
909
910" IDL (Interface Description Language)
911au BufNewFile,BufRead *.idl			call s:FTidl()
912
913" Distinguish between standard IDL and MS-IDL
914func! s:FTidl()
915  let n = 1
916  while n < 50 && n < line("$")
917    if getline(n) =~ '^\s*import\s\+"\(unknwn\|objidl\)\.idl"'
918      setf msidl
919      return
920    endif
921    let n = n + 1
922  endwhile
923  setf idl
924endfunc
925
926" Microsoft IDL (Interface Description Language)  Also *.idl
927" MOF = WMI (Windows Management Instrumentation) Managed Object Format
928au BufNewFile,BufRead *.odl,*.mof		setf msidl
929
930" Icewm menu
931au BufNewFile,BufRead */.icewm/menu		setf icemenu
932
933" Indent profile (must come before IDL *.pro!)
934au BufNewFile,BufRead .indent.pro		setf indent
935au BufNewFile,BufRead indent.pro		call s:ProtoCheck('indent')
936
937" IDL (Interactive Data Language)
938au BufNewFile,BufRead *.pro			call s:ProtoCheck('idlang')
939
940" Distinguish between "default" and Cproto prototype file. */
941func! s:ProtoCheck(default)
942  " Cproto files have a comment in the first line and a function prototype in
943  " the second line, it always ends in ";".  Indent files may also have
944  " comments, thus we can't match comments to see the difference.
945  " IDL files can have a single ';' in the second line, require at least one
946  " chacter before the ';'.
947  if getline(2) =~ '.;$'
948    setf cpp
949  else
950    exe 'setf ' . a:default
951  endif
952endfunc
953
954
955" Indent RC
956au BufNewFile,BufRead indentrc			setf indent
957
958" Inform
959au BufNewFile,BufRead *.inf,*.INF		setf inform
960
961" Initng
962au BufNewFile,BufRead */etc/initng/*/*.i,*.ii	setf initng
963
964" Innovation Data Processing
965au BufRead,BufNewFile upstream.dat\c,upstream.*.dat\c,*.upstream.dat\c 	setf upstreamdat
966au BufRead,BufNewFile upstream.log\c,upstream.*.log\c,*.upstream.log\c 	setf upstreamlog
967au BufRead,BufNewFile upstreaminstall.log\c,upstreaminstall.*.log\c,*.upstreaminstall.log\c setf upstreaminstalllog
968au BufRead,BufNewFile usserver.log\c,usserver.*.log\c,*.usserver.log\c 	setf usserverlog
969au BufRead,BufNewFile usw2kagt.log\c,usw2kagt.*.log\c,*.usw2kagt.log\c 	setf usw2kagtlog
970
971" Ipfilter
972au BufNewFile,BufRead ipf.conf,ipf6.conf,ipf.rules	setf ipfilter
973
974" Informix 4GL (source - canonical, include file, I4GL+M4 preproc.)
975au BufNewFile,BufRead *.4gl,*.4gh,*.m4gl	setf fgl
976
977" .INI file for MSDOS
978au BufNewFile,BufRead *.ini			setf dosini
979
980" SysV Inittab
981au BufNewFile,BufRead inittab			setf inittab
982
983" Inno Setup
984au BufNewFile,BufRead *.iss			setf iss
985
986" J
987au BufNewFile,BufRead *.ijs			setf j
988
989" JAL
990au BufNewFile,BufRead *.jal,*.JAL		setf jal
991
992" Jam
993au BufNewFile,BufRead *.jpl,*.jpr		setf jam
994
995" Java
996au BufNewFile,BufRead *.java,*.jav		setf java
997
998" JavaCC
999au BufNewFile,BufRead *.jj,*.jjt		setf javacc
1000
1001" JavaScript, ECMAScript
1002au BufNewFile,BufRead *.js,*.javascript,*.es,*.jsx   setf javascript
1003
1004" Java Server Pages
1005au BufNewFile,BufRead *.jsp			setf jsp
1006
1007" Java Properties resource file (note: doesn't catch font.properties.pl)
1008au BufNewFile,BufRead *.properties,*.properties_??,*.properties_??_??	setf jproperties
1009au BufNewFile,BufRead *.properties_??_??_*	call s:StarSetf('jproperties')
1010
1011" Jess
1012au BufNewFile,BufRead *.clp			setf jess
1013
1014" Jgraph
1015au BufNewFile,BufRead *.jgr			setf jgraph
1016
1017" Jovial
1018au BufNewFile,BufRead *.jov,*.j73,*.jovial	setf jovial
1019
1020" JSON
1021au BufNewFile,BufRead *.json,*.jsonp,*.webmanifest	setf json
1022
1023" Kixtart
1024au BufNewFile,BufRead *.kix			setf kix
1025
1026" Kimwitu[++]
1027au BufNewFile,BufRead *.k			setf kwt
1028
1029" Kivy
1030au BufNewFile,BufRead *.kv			setf kivy
1031
1032" KDE script
1033au BufNewFile,BufRead *.ks			setf kscript
1034
1035" Kconfig
1036au BufNewFile,BufRead Kconfig,Kconfig.debug	setf kconfig
1037
1038" Lace (ISE)
1039au BufNewFile,BufRead *.ace,*.ACE		setf lace
1040
1041" Latte
1042au BufNewFile,BufRead *.latte,*.lte		setf latte
1043
1044" Limits
1045au BufNewFile,BufRead */etc/limits,*/etc/*limits.conf,*/etc/*limits.d/*.conf	setf limits
1046
1047" LambdaProlog (*.mod too, see Modsim)
1048au BufNewFile,BufRead *.sig			setf lprolog
1049
1050" LDAP LDIF
1051au BufNewFile,BufRead *.ldif			setf ldif
1052
1053" Ld loader
1054au BufNewFile,BufRead *.ld			setf ld
1055
1056" Less
1057au BufNewFile,BufRead *.less			setf less
1058
1059" Lex
1060au BufNewFile,BufRead *.lex,*.l,*.lxx,*.l++	setf lex
1061
1062" Libao
1063au BufNewFile,BufRead */etc/libao.conf,*/.libao	setf libao
1064
1065" Libsensors
1066au BufNewFile,BufRead */etc/sensors.conf,*/etc/sensors3.conf	setf sensors
1067
1068" LFTP
1069au BufNewFile,BufRead lftp.conf,.lftprc,*lftp/rc	setf lftp
1070
1071" Lifelines (or Lex for C++!)
1072au BufNewFile,BufRead *.ll			setf lifelines
1073
1074" Lilo: Linux loader
1075au BufNewFile,BufRead lilo.conf			setf lilo
1076
1077" Lisp (*.el = ELisp, *.cl = Common Lisp, *.jl = librep Lisp)
1078if has("fname_case")
1079  au BufNewFile,BufRead *.lsp,*.lisp,*.el,*.cl,*.jl,*.L,.emacs,.sawfishrc setf lisp
1080else
1081  au BufNewFile,BufRead *.lsp,*.lisp,*.el,*.cl,*.jl,.emacs,.sawfishrc setf lisp
1082endif
1083
1084" SBCL implementation of Common Lisp
1085au BufNewFile,BufRead sbclrc,.sbclrc		setf lisp
1086
1087" Liquid
1088au BufNewFile,BufRead *.liquid			setf liquid
1089
1090" Lite
1091au BufNewFile,BufRead *.lite,*.lt		setf lite
1092
1093" LiteStep RC files
1094au BufNewFile,BufRead */LiteStep/*/*.rc		setf litestep
1095
1096" Login access
1097au BufNewFile,BufRead */etc/login.access	setf loginaccess
1098
1099" Login defs
1100au BufNewFile,BufRead */etc/login.defs		setf logindefs
1101
1102" Logtalk
1103au BufNewFile,BufRead *.lgt			setf logtalk
1104
1105" LOTOS
1106au BufNewFile,BufRead *.lot,*.lotos		setf lotos
1107
1108" Lout (also: *.lt)
1109au BufNewFile,BufRead *.lou,*.lout		setf lout
1110
1111" Lua
1112au BufNewFile,BufRead *.lua			setf lua
1113
1114" Luarocks
1115au BufNewFile,BufRead *.rockspec		setf lua
1116
1117" Linden Scripting Language (Second Life)
1118au BufNewFile,BufRead *.lsl			setf lsl
1119
1120" Lynx style file (or LotusScript!)
1121au BufNewFile,BufRead *.lss			setf lss
1122
1123" M4
1124au BufNewFile,BufRead *.m4
1125	\ if expand("<afile>") !~? 'html.m4$\|fvwm2rc' | setf m4 | endif
1126
1127" MaGic Point
1128au BufNewFile,BufRead *.mgp			setf mgp
1129
1130" Mail (for Elm, trn, mutt, muttng, rn, slrn)
1131au 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
1132
1133" Mail aliases
1134au BufNewFile,BufRead */etc/mail/aliases,*/etc/aliases	setf mailaliases
1135
1136" Mailcap configuration file
1137au BufNewFile,BufRead .mailcap,mailcap		setf mailcap
1138
1139" Makefile
1140au BufNewFile,BufRead *[mM]akefile,*.mk,*.mak,*.dsp setf make
1141
1142" MakeIndex
1143au BufNewFile,BufRead *.ist,*.mst		setf ist
1144
1145" Mallard
1146au BufNewFile,BufRead *.page			setf mallard
1147
1148" Manpage
1149au BufNewFile,BufRead *.man			setf man
1150
1151" Man config
1152au BufNewFile,BufRead */etc/man.conf,man.config	setf manconf
1153
1154" Maple V
1155au BufNewFile,BufRead *.mv,*.mpl,*.mws		setf maple
1156
1157" Map (UMN mapserver config file)
1158au BufNewFile,BufRead *.map			setf map
1159
1160" Markdown
1161au BufNewFile,BufRead *.markdown,*.mdown,*.mkd,*.mkdn,*.mdwn,*.md  setf markdown
1162
1163" Mason
1164au BufNewFile,BufRead *.mason,*.mhtml,*.comp	setf mason
1165
1166" Matlab or Objective C
1167au BufNewFile,BufRead *.m			call s:FTm()
1168
1169func! s:FTm()
1170  let n = 1
1171  while n < 10
1172    let line = getline(n)
1173    if line =~ '^\s*\(#\s*\(include\|import\)\>\|@import\>\|/\*\|//\)'
1174      setf objc
1175      return
1176    endif
1177    if line =~ '^\s*%'
1178      setf matlab
1179      return
1180    endif
1181    if line =~ '^\s*(\*'
1182      setf mma
1183      return
1184    endif
1185    let n = n + 1
1186  endwhile
1187  if exists("g:filetype_m")
1188    exe "setf " . g:filetype_m
1189  else
1190    setf matlab
1191  endif
1192endfunc
1193
1194" Mathematica notebook
1195au BufNewFile,BufRead *.nb			setf mma
1196
1197" Maya Extension Language
1198au BufNewFile,BufRead *.mel			setf mel
1199
1200" Mercurial (hg) commit file
1201au BufNewFile,BufRead hg-editor-*.txt		setf hgcommit
1202
1203" Mercurial config (looks like generic config file)
1204au BufNewFile,BufRead *.hgrc,*hgrc		setf cfg
1205
1206" Messages (logs mostly)
1207au 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
1208
1209" Metafont
1210au BufNewFile,BufRead *.mf			setf mf
1211
1212" MetaPost
1213au BufNewFile,BufRead *.mp			setf mp
1214
1215" MGL
1216au BufNewFile,BufRead *.mgl			setf mgl
1217
1218" MIX - Knuth assembly
1219au BufNewFile,BufRead *.mix,*.mixal		setf mix
1220
1221" MMIX or VMS makefile
1222au BufNewFile,BufRead *.mms			call s:FTmms()
1223
1224" Symbian meta-makefile definition (MMP)
1225au BufNewFile,BufRead *.mmp			setf mmp
1226
1227func! s:FTmms()
1228  let n = 1
1229  while n < 10
1230    let line = getline(n)
1231    if line =~ '^\s*\(%\|//\)' || line =~ '^\*'
1232      setf mmix
1233      return
1234    endif
1235    if line =~ '^\s*#'
1236      setf make
1237      return
1238    endif
1239    let n = n + 1
1240  endwhile
1241  setf mmix
1242endfunc
1243
1244
1245" Modsim III (or LambdaProlog)
1246au BufNewFile,BufRead *.mod
1247	\ if getline(1) =~ '\<module\>' |
1248	\   setf lprolog |
1249	\ else |
1250	\   setf modsim3 |
1251	\ endif
1252
1253" Modula 2  (.md removed in favor of Markdown)
1254au BufNewFile,BufRead *.m2,*.DEF,*.MOD,*.mi	setf modula2
1255
1256" Modula 3 (.m3, .i3, .mg, .ig)
1257au BufNewFile,BufRead *.[mi][3g]		setf modula3
1258
1259" Monk
1260au BufNewFile,BufRead *.isc,*.monk,*.ssc,*.tsc	setf monk
1261
1262" MOO
1263au BufNewFile,BufRead *.moo			setf moo
1264
1265" Modconf
1266au BufNewFile,BufRead */etc/modules.conf,*/etc/modules,*/etc/conf.modules setf modconf
1267
1268" Mplayer config
1269au BufNewFile,BufRead mplayer.conf,*/.mplayer/config	setf mplayerconf
1270
1271" Motorola S record
1272au BufNewFile,BufRead *.s19,*.s28,*.s37,*.mot,*.srec	setf srec
1273
1274" Mrxvtrc
1275au BufNewFile,BufRead mrxvtrc,.mrxvtrc		setf mrxvtrc
1276
1277" Msql
1278au BufNewFile,BufRead *.msql			setf msql
1279
1280" Mysql
1281au BufNewFile,BufRead *.mysql			setf mysql
1282
1283" Mutt setup files (must be before catch *.rc)
1284au BufNewFile,BufRead */etc/Muttrc.d/*		call s:StarSetf('muttrc')
1285
1286" M$ Resource files
1287au BufNewFile,BufRead *.rc,*.rch		setf rc
1288
1289" MuPAD source
1290au BufRead,BufNewFile *.mu			setf mupad
1291
1292" Mush
1293au BufNewFile,BufRead *.mush			setf mush
1294
1295" Mutt setup file (also for Muttng)
1296au BufNewFile,BufRead Mutt{ng,}rc		setf muttrc
1297
1298" Nano
1299au BufNewFile,BufRead */etc/nanorc,*.nanorc  	setf nanorc
1300
1301" Nastran input/DMAP
1302"au BufNewFile,BufRead *.dat			setf nastran
1303
1304" Natural
1305au BufNewFile,BufRead *.NS[ACGLMNPS]		setf natural
1306
1307" Netrc
1308au BufNewFile,BufRead .netrc			setf netrc
1309
1310" Ninja file
1311au BufNewFile,BufRead *.ninja			setf ninja
1312
1313" Novell netware batch files
1314au BufNewFile,BufRead *.ncf			setf ncf
1315
1316" Nroff/Troff (*.ms and *.t are checked below)
1317au BufNewFile,BufRead *.me
1318	\ if expand("<afile>") != "read.me" && expand("<afile>") != "click.me" |
1319	\   setf nroff |
1320	\ endif
1321au BufNewFile,BufRead *.tr,*.nr,*.roff,*.tmac,*.mom	setf nroff
1322au BufNewFile,BufRead *.[1-9]			call s:FTnroff()
1323
1324" This function checks if one of the first five lines start with a dot.  In
1325" that case it is probably an nroff file: 'filetype' is set and 1 is returned.
1326func! s:FTnroff()
1327  if getline(1)[0] . getline(2)[0] . getline(3)[0] . getline(4)[0] . getline(5)[0] =~ '\.'
1328    setf nroff
1329    return 1
1330  endif
1331  return 0
1332endfunc
1333
1334" Nroff or Objective C++
1335au BufNewFile,BufRead *.mm			call s:FTmm()
1336
1337func! s:FTmm()
1338  let n = 1
1339  while n < 10
1340    let line = getline(n)
1341    if line =~ '^\s*\(#\s*\(include\|import\)\>\|@import\>\|/\*\)'
1342      setf objcpp
1343      return
1344    endif
1345    let n = n + 1
1346  endwhile
1347  setf nroff
1348endfunc
1349
1350" Not Quite C
1351au BufNewFile,BufRead *.nqc			setf nqc
1352
1353" NSIS
1354au BufNewFile,BufRead *.nsi,*.nsh		setf nsis
1355
1356" OCAML
1357au BufNewFile,BufRead *.ml,*.mli,*.mll,*.mly,.ocamlinit	setf ocaml
1358
1359" Occam
1360au BufNewFile,BufRead *.occ			setf occam
1361
1362" Omnimark
1363au BufNewFile,BufRead *.xom,*.xin		setf omnimark
1364
1365" OpenROAD
1366au BufNewFile,BufRead *.or			setf openroad
1367
1368" OPL
1369au BufNewFile,BufRead *.[Oo][Pp][Ll]		setf opl
1370
1371" Oracle config file
1372au BufNewFile,BufRead *.ora			setf ora
1373
1374" Packet filter conf
1375au BufNewFile,BufRead pf.conf			setf pf
1376
1377" Pam conf
1378au BufNewFile,BufRead */etc/pam.conf		setf pamconf
1379
1380" PApp
1381au BufNewFile,BufRead *.papp,*.pxml,*.pxsl	setf papp
1382
1383" Password file
1384au 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
1385
1386" Pascal (also *.p)
1387au BufNewFile,BufRead *.pas			setf pascal
1388
1389" Delphi project file
1390au BufNewFile,BufRead *.dpr			setf pascal
1391
1392" PDF
1393au BufNewFile,BufRead *.pdf			setf pdf
1394
1395" Perl
1396if has("fname_case")
1397  au BufNewFile,BufRead *.pl,*.PL		call s:FTpl()
1398else
1399  au BufNewFile,BufRead *.pl			call s:FTpl()
1400endif
1401au BufNewFile,BufRead *.plx,*.al		setf perl
1402au BufNewFile,BufRead *.p6,*.pm6,*.pl6		setf perl6
1403
1404func! s:FTpl()
1405  if exists("g:filetype_pl")
1406    exe "setf " . g:filetype_pl
1407  else
1408    " recognize Prolog by specific text in the first non-empty line
1409    " require a blank after the '%' because Perl uses "%list" and "%translate"
1410    let l = getline(nextnonblank(1))
1411    if l =~ '\<prolog\>' || l =~ '^\s*\(%\+\(\s\|$\)\|/\*\)' || l =~ ':-'
1412      setf prolog
1413    else
1414      setf perl
1415    endif
1416  endif
1417endfunc
1418
1419" Perl, XPM or XPM2
1420au BufNewFile,BufRead *.pm
1421	\ if getline(1) =~ "XPM2" |
1422	\   setf xpm2 |
1423	\ elseif getline(1) =~ "XPM" |
1424	\   setf xpm |
1425	\ else |
1426	\   setf perl |
1427	\ endif
1428
1429" Perl POD
1430au BufNewFile,BufRead *.pod			setf pod
1431au BufNewFile,BufRead *.pod6			setf pod6
1432
1433" Php, php3, php4, etc.
1434" Also Phtml (was used for PHP 2 in the past)
1435" Also .ctp for Cake template file
1436au BufNewFile,BufRead *.php,*.php\d,*.phtml,*.ctp	setf php
1437
1438" Pike
1439au BufNewFile,BufRead *.pike,*.lpc,*.ulpc,*.pmod setf pike
1440
1441" Pinfo config
1442au BufNewFile,BufRead */etc/pinforc,*/.pinforc	setf pinfo
1443
1444" Palm Resource compiler
1445au BufNewFile,BufRead *.rcp			setf pilrc
1446
1447" Pine config
1448au BufNewFile,BufRead .pinerc,pinerc,.pinercex,pinercex		setf pine
1449
1450" PL/1, PL/I
1451au BufNewFile,BufRead *.pli,*.pl1		setf pli
1452
1453" PL/M (also: *.inp)
1454au BufNewFile,BufRead *.plm,*.p36,*.pac		setf plm
1455
1456" PL/SQL
1457au BufNewFile,BufRead *.pls,*.plsql		setf plsql
1458
1459" PLP
1460au BufNewFile,BufRead *.plp			setf plp
1461
1462" PO and PO template (GNU gettext)
1463au BufNewFile,BufRead *.po,*.pot		setf po
1464
1465" Postfix main config
1466au BufNewFile,BufRead main.cf			setf pfmain
1467
1468" PostScript (+ font files, encapsulated PostScript, Adobe Illustrator)
1469au BufNewFile,BufRead *.ps,*.pfa,*.afm,*.eps,*.epsf,*.epsi,*.ai	  setf postscr
1470
1471" PostScript Printer Description
1472au BufNewFile,BufRead *.ppd			setf ppd
1473
1474" Povray
1475au BufNewFile,BufRead *.pov			setf pov
1476
1477" Povray configuration
1478au BufNewFile,BufRead .povrayrc			setf povini
1479
1480" Povray, PHP or assembly
1481au BufNewFile,BufRead *.inc			call s:FTinc()
1482
1483func! s:FTinc()
1484  if exists("g:filetype_inc")
1485    exe "setf " . g:filetype_inc
1486  else
1487    let lines = getline(1).getline(2).getline(3)
1488    if lines =~? "perlscript"
1489      setf aspperl
1490    elseif lines =~ "<%"
1491      setf aspvbs
1492    elseif lines =~ "<?"
1493      setf php
1494    else
1495      call s:FTasmsyntax()
1496      if exists("b:asmsyntax")
1497	exe "setf " . fnameescape(b:asmsyntax)
1498      else
1499	setf pov
1500      endif
1501    endif
1502  endif
1503endfunc
1504
1505" Printcap and Termcap
1506au BufNewFile,BufRead *printcap
1507	\ let b:ptcap_type = "print" | setf ptcap
1508au BufNewFile,BufRead *termcap
1509	\ let b:ptcap_type = "term" | setf ptcap
1510
1511" PCCTS / ANTRL
1512"au BufNewFile,BufRead *.g			setf antrl
1513au BufNewFile,BufRead *.g			setf pccts
1514
1515" PPWizard
1516au BufNewFile,BufRead *.it,*.ih			setf ppwiz
1517
1518" Obj 3D file format
1519" TODO: is there a way to avoid MS-Windows Object files?
1520au BufNewFile,BufRead *.obj			setf obj
1521
1522" Oracle Pro*C/C++
1523au BufNewFile,BufRead *.pc			setf proc
1524
1525" Privoxy actions file
1526au BufNewFile,BufRead *.action			setf privoxy
1527
1528" Procmail
1529au BufNewFile,BufRead .procmail,.procmailrc	setf procmail
1530
1531" Progress or CWEB
1532au BufNewFile,BufRead *.w			call s:FTprogress_cweb()
1533
1534func! s:FTprogress_cweb()
1535  if exists("g:filetype_w")
1536    exe "setf " . g:filetype_w
1537    return
1538  endif
1539  if getline(1) =~ '&ANALYZE' || getline(3) =~ '&GLOBAL-DEFINE'
1540    setf progress
1541  else
1542    setf cweb
1543  endif
1544endfunc
1545
1546" Progress or assembly
1547au BufNewFile,BufRead *.i			call s:FTprogress_asm()
1548
1549func! s:FTprogress_asm()
1550  if exists("g:filetype_i")
1551    exe "setf " . g:filetype_i
1552    return
1553  endif
1554  " This function checks for an assembly comment the first ten lines.
1555  " If not found, assume Progress.
1556  let lnum = 1
1557  while lnum <= 10 && lnum < line('$')
1558    let line = getline(lnum)
1559    if line =~ '^\s*;' || line =~ '^\*'
1560      call s:FTasm()
1561      return
1562    elseif line !~ '^\s*$' || line =~ '^/\*'
1563      " Not an empty line: Doesn't look like valid assembly code.
1564      " Or it looks like a Progress /* comment
1565      break
1566    endif
1567    let lnum = lnum + 1
1568  endw
1569  setf progress
1570endfunc
1571
1572" Progress or Pascal
1573au BufNewFile,BufRead *.p			call s:FTprogress_pascal()
1574
1575func! s:FTprogress_pascal()
1576  if exists("g:filetype_p")
1577    exe "setf " . g:filetype_p
1578    return
1579  endif
1580  " This function checks for valid Pascal syntax in the first ten lines.
1581  " Look for either an opening comment or a program start.
1582  " If not found, assume Progress.
1583  let lnum = 1
1584  while lnum <= 10 && lnum < line('$')
1585    let line = getline(lnum)
1586    if line =~ '^\s*\(program\|unit\|procedure\|function\|const\|type\|var\)\>'
1587	\ || line =~ '^\s*{' || line =~ '^\s*(\*'
1588      setf pascal
1589      return
1590    elseif line !~ '^\s*$' || line =~ '^/\*'
1591      " Not an empty line: Doesn't look like valid Pascal code.
1592      " Or it looks like a Progress /* comment
1593      break
1594    endif
1595    let lnum = lnum + 1
1596  endw
1597  setf progress
1598endfunc
1599
1600
1601" Software Distributor Product Specification File (POSIX 1387.2-1995)
1602au BufNewFile,BufRead *.psf			setf psf
1603au BufNewFile,BufRead INDEX,INFO
1604	\ if getline(1) =~ '^\s*\(distribution\|installed_software\|root\|bundle\|product\)\s*$' |
1605	\   setf psf |
1606	\ endif
1607
1608" Prolog
1609au BufNewFile,BufRead *.pdb			setf prolog
1610
1611" Promela
1612au BufNewFile,BufRead *.pml			setf promela
1613
1614" Google protocol buffers
1615au BufNewFile,BufRead *.proto			setf proto
1616
1617" Protocols
1618au BufNewFile,BufRead */etc/protocols		setf protocols
1619
1620" Pyrex
1621au BufNewFile,BufRead *.pyx,*.pxd		setf pyrex
1622
1623" Python, Python Shell Startup Files
1624" Quixote (Python-based web framework)
1625au BufNewFile,BufRead *.py,*.pyw,.pythonstartup,.pythonrc,*.ptl  setf python
1626
1627" Radiance
1628au BufNewFile,BufRead *.rad,*.mat		setf radiance
1629
1630" Ratpoison config/command files
1631au BufNewFile,BufRead .ratpoisonrc,ratpoisonrc	setf ratpoison
1632
1633" RCS file
1634au BufNewFile,BufRead *\,v			setf rcs
1635
1636" Readline
1637au BufNewFile,BufRead .inputrc,inputrc		setf readline
1638
1639" Registry for MS-Windows
1640au BufNewFile,BufRead *.reg
1641	\ if getline(1) =~? '^REGEDIT[0-9]*\s*$\|^Windows Registry Editor Version \d*\.\d*\s*$' | setf registry | endif
1642
1643" Renderman Interface Bytestream
1644au BufNewFile,BufRead *.rib			setf rib
1645
1646" Rexx
1647au BufNewFile,BufRead *.rex,*.orx,*.rxo,*.rxj,*.jrexx,*.rexxj,*.rexx,*.testGroup,*.testUnit	setf rexx
1648
1649" R (Splus)
1650if has("fname_case")
1651  au BufNewFile,BufRead *.s,*.S			setf r
1652else
1653  au BufNewFile,BufRead *.s			setf r
1654endif
1655
1656" R Help file
1657if has("fname_case")
1658  au BufNewFile,BufRead *.rd,*.Rd		setf rhelp
1659else
1660  au BufNewFile,BufRead *.rd			setf rhelp
1661endif
1662
1663" R noweb file
1664if has("fname_case")
1665  au BufNewFile,BufRead *.Rnw,*.rnw,*.Snw,*.snw		setf rnoweb
1666else
1667  au BufNewFile,BufRead *.rnw,*.snw			setf rnoweb
1668endif
1669
1670" R Markdown file
1671if has("fname_case")
1672  au BufNewFile,BufRead *.Rmd,*.rmd,*.Smd,*.smd		setf rmd
1673else
1674  au BufNewFile,BufRead *.rmd,*.smd			setf rmd
1675endif
1676
1677" R reStructuredText file
1678if has("fname_case")
1679  au BufNewFile,BufRead *.Rrst,*.rrst,*.Srst,*.srst	setf rrst
1680else
1681  au BufNewFile,BufRead *.rrst,*.srst			setf rrst
1682endif
1683
1684" Rexx, Rebol or R
1685au BufNewFile,BufRead *.r,*.R			call s:FTr()
1686
1687func! s:FTr()
1688  let max = line("$") > 50 ? 50 : line("$")
1689
1690  for n in range(1, max)
1691    " Rebol is easy to recognize, check for that first
1692    if getline(n) =~? '\<REBOL\>'
1693      setf rebol
1694      return
1695    endif
1696  endfor
1697
1698  for n in range(1, max)
1699    " R has # comments
1700    if getline(n) =~ '^\s*#'
1701      setf r
1702      return
1703    endif
1704    " Rexx has /* comments */
1705    if getline(n) =~ '^\s*/\*'
1706      setf rexx
1707      return
1708    endif
1709  endfor
1710
1711  " Nothing recognized, use user default or assume Rexx
1712  if exists("g:filetype_r")
1713    exe "setf " . g:filetype_r
1714  else
1715    " Rexx used to be the default, but R appears to be much more popular.
1716    setf r
1717  endif
1718endfunc
1719
1720" Remind
1721au BufNewFile,BufRead .reminders,*.remind,*.rem		setf remind
1722
1723" Resolv.conf
1724au BufNewFile,BufRead resolv.conf		setf resolv
1725
1726" Relax NG Compact
1727au BufNewFile,BufRead *.rnc			setf rnc
1728
1729" Relax NG XML
1730au BufNewFile,BufRead *.rng			setf rng
1731
1732" RPL/2
1733au BufNewFile,BufRead *.rpl			setf rpl
1734
1735" Robots.txt
1736au BufNewFile,BufRead robots.txt		setf robots
1737
1738" Rpcgen
1739au BufNewFile,BufRead *.x			setf rpcgen
1740
1741" reStructuredText Documentation Format
1742au BufNewFile,BufRead *.rst			setf rst
1743
1744" RTF
1745au BufNewFile,BufRead *.rtf			setf rtf
1746
1747" Interactive Ruby shell
1748au BufNewFile,BufRead .irbrc,irbrc		setf ruby
1749
1750" Ruby
1751au BufNewFile,BufRead *.rb,*.rbw		setf ruby
1752
1753" RubyGems
1754au BufNewFile,BufRead *.gemspec			setf ruby
1755
1756" Rackup
1757au BufNewFile,BufRead *.ru			setf ruby
1758
1759" Bundler
1760au BufNewFile,BufRead Gemfile			setf ruby
1761
1762" Ruby on Rails
1763au BufNewFile,BufRead *.builder,*.rxml,*.rjs	setf ruby
1764
1765" Rantfile and Rakefile is like Ruby
1766au BufNewFile,BufRead [rR]antfile,*.rant,[rR]akefile,*.rake	setf ruby
1767
1768" S-lang (or shader language, or SmallLisp)
1769au BufNewFile,BufRead *.sl			setf slang
1770
1771" Samba config
1772au BufNewFile,BufRead smb.conf			setf samba
1773
1774" SAS script
1775au BufNewFile,BufRead *.sas			setf sas
1776
1777" Sass
1778au BufNewFile,BufRead *.sass			setf sass
1779
1780" Sather
1781au BufNewFile,BufRead *.sa			setf sather
1782
1783" Scilab
1784au BufNewFile,BufRead *.sci,*.sce		setf scilab
1785
1786" SCSS
1787au BufNewFile,BufRead *.scss			setf scss
1788
1789" SD: Streaming Descriptors
1790au BufNewFile,BufRead *.sd			setf sd
1791
1792" SDL
1793au BufNewFile,BufRead *.sdl,*.pr		setf sdl
1794
1795" sed
1796au BufNewFile,BufRead *.sed			setf sed
1797
1798" Sieve (RFC 3028)
1799au BufNewFile,BufRead *.siv			setf sieve
1800
1801" Sendmail
1802au BufNewFile,BufRead sendmail.cf		setf sm
1803
1804" Sendmail .mc files are actually m4.  Could also be MS Message text file.
1805au BufNewFile,BufRead *.mc			call s:McSetf()
1806
1807func! s:McSetf()
1808  " Rely on the file to start with a comment.
1809  " MS message text files use ';', Sendmail files use '#' or 'dnl'
1810  for lnum in range(1, min([line("$"), 20]))
1811    let line = getline(lnum)
1812    if line =~ '^\s*\(#\|dnl\)'
1813      setf m4  " Sendmail .mc file
1814      return
1815    elseif line =~ '^\s*;'
1816      setf msmessages  " MS Message text file
1817      return
1818    endif
1819  endfor
1820  setf m4  " Default: Sendmail .mc file
1821endfunc
1822
1823" Services
1824au BufNewFile,BufRead */etc/services		setf services
1825
1826" Service Location config
1827au BufNewFile,BufRead */etc/slp.conf		setf slpconf
1828
1829" Service Location registration
1830au BufNewFile,BufRead */etc/slp.reg		setf slpreg
1831
1832" Service Location SPI
1833au BufNewFile,BufRead */etc/slp.spi		setf slpspi
1834
1835" Setserial config
1836au BufNewFile,BufRead */etc/serial.conf		setf setserial
1837
1838" SGML
1839au BufNewFile,BufRead *.sgm,*.sgml
1840	\ if getline(1).getline(2).getline(3).getline(4).getline(5) =~? 'linuxdoc' |
1841	\   setf sgmllnx |
1842	\ elseif getline(1) =~ '<!DOCTYPE.*DocBook' || getline(2) =~ '<!DOCTYPE.*DocBook' |
1843	\   let b:docbk_type = "sgml" |
1844	\   let b:docbk_ver = 4 |
1845	\   setf docbk |
1846	\ else |
1847	\   setf sgml |
1848	\ endif
1849
1850" SGMLDECL
1851au BufNewFile,BufRead *.decl,*.dcl,*.dec
1852	\ if getline(1).getline(2).getline(3) =~? '^<!SGML' |
1853	\    setf sgmldecl |
1854	\ endif
1855
1856" SGML catalog file
1857au BufNewFile,BufRead catalog			setf catalog
1858au BufNewFile,BufRead sgml.catalog*		call s:StarSetf('catalog')
1859
1860" Shell scripts (sh, ksh, bash, bash2, csh); Allow .profile_foo etc.
1861" Gentoo ebuilds and Arch Linux PKGBUILDs are actually bash scripts
1862au BufNewFile,BufRead .bashrc*,bashrc,bash.bashrc,.bash[_-]profile*,.bash[_-]logout*,.bash[_-]aliases*,*.bash,*/{,.}bash[_-]completion{,.d,.sh}{,/*},*.ebuild,*.eclass,PKGBUILD* call SetFileTypeSH("bash")
1863au BufNewFile,BufRead .kshrc*,*.ksh call SetFileTypeSH("ksh")
1864au BufNewFile,BufRead */etc/profile,.profile*,*.sh,*.env call SetFileTypeSH(getline(1))
1865
1866" Shell script (Arch Linux) or PHP file (Drupal)
1867au BufNewFile,BufRead *.install
1868	\ if getline(1) =~ '<?php' |
1869	\   setf php |
1870	\ else |
1871	\   call SetFileTypeSH("bash") |
1872	\ endif
1873
1874" Also called from scripts.vim.
1875func! SetFileTypeSH(name)
1876  if expand("<amatch>") =~ g:ft_ignore_pat
1877    return
1878  endif
1879  if a:name =~ '\<csh\>'
1880    " Some .sh scripts contain #!/bin/csh.
1881    call SetFileTypeShell("csh")
1882    return
1883  elseif a:name =~ '\<tcsh\>'
1884    " Some .sh scripts contain #!/bin/tcsh.
1885    call SetFileTypeShell("tcsh")
1886    return
1887  elseif a:name =~ '\<zsh\>'
1888    " Some .sh scripts contain #!/bin/zsh.
1889    call SetFileTypeShell("zsh")
1890    return
1891  elseif a:name =~ '\<ksh\>'
1892    let b:is_kornshell = 1
1893    if exists("b:is_bash")
1894      unlet b:is_bash
1895    endif
1896    if exists("b:is_sh")
1897      unlet b:is_sh
1898    endif
1899  elseif exists("g:bash_is_sh") || a:name =~ '\<bash\>' || a:name =~ '\<bash2\>'
1900    let b:is_bash = 1
1901    if exists("b:is_kornshell")
1902      unlet b:is_kornshell
1903    endif
1904    if exists("b:is_sh")
1905      unlet b:is_sh
1906    endif
1907  elseif a:name =~ '\<sh\>'
1908    let b:is_sh = 1
1909    if exists("b:is_kornshell")
1910      unlet b:is_kornshell
1911    endif
1912    if exists("b:is_bash")
1913      unlet b:is_bash
1914    endif
1915  endif
1916  call SetFileTypeShell("sh")
1917endfunc
1918
1919" For shell-like file types, check for an "exec" command hidden in a comment,
1920" as used for Tcl.
1921" Also called from scripts.vim, thus can't be local to this script.
1922func! SetFileTypeShell(name)
1923  if expand("<amatch>") =~ g:ft_ignore_pat
1924    return
1925  endif
1926  let l = 2
1927  while l < 20 && l < line("$") && getline(l) =~ '^\s*\(#\|$\)'
1928    " Skip empty and comment lines.
1929    let l = l + 1
1930  endwhile
1931  if l < line("$") && getline(l) =~ '\s*exec\s' && getline(l - 1) =~ '^\s*#.*\\$'
1932    " Found an "exec" line after a comment with continuation
1933    let n = substitute(getline(l),'\s*exec\s\+\([^ ]*/\)\=', '', '')
1934    if n =~ '\<tclsh\|\<wish'
1935      setf tcl
1936      return
1937    endif
1938  endif
1939  exe "setf " . a:name
1940endfunc
1941
1942" tcsh scripts
1943au BufNewFile,BufRead .tcshrc*,*.tcsh,tcsh.tcshrc,tcsh.login	call SetFileTypeShell("tcsh")
1944
1945" csh scripts, but might also be tcsh scripts (on some systems csh is tcsh)
1946au BufNewFile,BufRead .login*,.cshrc*,csh.cshrc,csh.login,csh.logout,*.csh,.alias  call s:CSH()
1947
1948func! s:CSH()
1949  if exists("g:filetype_csh")
1950    call SetFileTypeShell(g:filetype_csh)
1951  elseif &shell =~ "tcsh"
1952    call SetFileTypeShell("tcsh")
1953  else
1954    call SetFileTypeShell("csh")
1955  endif
1956endfunc
1957
1958" Z-Shell script
1959au BufNewFile,BufRead .zprofile,*/etc/zprofile,.zfbfmarks  setf zsh
1960au BufNewFile,BufRead .zsh*,.zlog*,.zcompdump*  call s:StarSetf('zsh')
1961au BufNewFile,BufRead *.zsh			setf zsh
1962
1963" Scheme
1964au BufNewFile,BufRead *.scm,*.ss,*.rkt		setf scheme
1965
1966" Screen RC
1967au BufNewFile,BufRead .screenrc,screenrc	setf screen
1968
1969" Simula
1970au BufNewFile,BufRead *.sim			setf simula
1971
1972" SINDA
1973au BufNewFile,BufRead *.sin,*.s85		setf sinda
1974
1975" SiSU
1976au BufNewFile,BufRead *.sst,*.ssm,*.ssi,*.-sst,*._sst setf sisu
1977au BufNewFile,BufRead *.sst.meta,*.-sst.meta,*._sst.meta setf sisu
1978
1979" SKILL
1980au BufNewFile,BufRead *.il,*.ils,*.cdf		setf skill
1981
1982" SLRN
1983au BufNewFile,BufRead .slrnrc			setf slrnrc
1984au BufNewFile,BufRead *.score			setf slrnsc
1985
1986" Smalltalk (and TeX)
1987au BufNewFile,BufRead *.st			setf st
1988au BufNewFile,BufRead *.cls
1989	\ if getline(1) =~ '^%' |
1990	\  setf tex |
1991	\ elseif getline(1)[0] == '#' && getline(1) =~ 'rexx' |
1992	\  setf rexx |
1993	\ else |
1994	\  setf st |
1995	\ endif
1996
1997" Smarty templates
1998au BufNewFile,BufRead *.tpl			setf smarty
1999
2000" SMIL or XML
2001au BufNewFile,BufRead *.smil
2002	\ if getline(1) =~ '<?\s*xml.*?>' |
2003	\   setf xml |
2004	\ else |
2005	\   setf smil |
2006	\ endif
2007
2008" SMIL or SNMP MIB file
2009au BufNewFile,BufRead *.smi
2010	\ if getline(1) =~ '\<smil\>' |
2011	\   setf smil |
2012	\ else |
2013	\   setf mib |
2014	\ endif
2015
2016" SMITH
2017au BufNewFile,BufRead *.smt,*.smith		setf smith
2018
2019" Snobol4 and spitbol
2020au BufNewFile,BufRead *.sno,*.spt		setf snobol4
2021
2022" SNMP MIB files
2023au BufNewFile,BufRead *.mib,*.my		setf mib
2024
2025" Snort Configuration
2026au BufNewFile,BufRead *.hog,snort.conf,vision.conf	setf hog
2027au BufNewFile,BufRead *.rules			call s:FTRules()
2028
2029let s:ft_rules_udev_rules_pattern = '^\s*\cudev_rules\s*=\s*"\([^"]\{-1,}\)/*".*'
2030func! s:FTRules()
2031  let path = expand('<amatch>:p')
2032  if path =~ '^/\(etc/udev/\%(rules\.d/\)\=.*\.rules\|lib/udev/\%(rules\.d/\)\=.*\.rules\)$'
2033    setf udevrules
2034    return
2035  endif
2036  if path =~ '^/etc/ufw/'
2037    setf conf  " Better than hog
2038    return
2039  endif
2040  if path =~ '^/\(etc\|usr/share\)/polkit-1/rules\.d'
2041    setf javascript
2042    return
2043  endif
2044  try
2045    let config_lines = readfile('/etc/udev/udev.conf')
2046  catch /^Vim\%((\a\+)\)\=:E484/
2047    setf hog
2048    return
2049  endtry
2050  let dir = expand('<amatch>:p:h')
2051  for line in config_lines
2052    if line =~ s:ft_rules_udev_rules_pattern
2053      let udev_rules = substitute(line, s:ft_rules_udev_rules_pattern, '\1', "")
2054      if dir == udev_rules
2055        setf udevrules
2056      endif
2057      break
2058    endif
2059  endfor
2060  setf hog
2061endfunc
2062
2063
2064" Spec (Linux RPM)
2065au BufNewFile,BufRead *.spec			setf spec
2066
2067" Speedup (AspenTech plant simulator)
2068au BufNewFile,BufRead *.speedup,*.spdata,*.spd	setf spup
2069
2070" Slice
2071au BufNewFile,BufRead *.ice			setf slice
2072
2073" Spice
2074au BufNewFile,BufRead *.sp,*.spice		setf spice
2075
2076" Spyce
2077au BufNewFile,BufRead *.spy,*.spi		setf spyce
2078
2079" Squid
2080au BufNewFile,BufRead squid.conf		setf squid
2081
2082" SQL for Oracle Designer
2083au BufNewFile,BufRead *.tyb,*.typ,*.tyc,*.pkb,*.pks	setf sql
2084
2085" SQL
2086au BufNewFile,BufRead *.sql			call s:SQL()
2087
2088func! s:SQL()
2089  if exists("g:filetype_sql")
2090    exe "setf " . g:filetype_sql
2091  else
2092    setf sql
2093  endif
2094endfunc
2095
2096" SQLJ
2097au BufNewFile,BufRead *.sqlj			setf sqlj
2098
2099" SQR
2100au BufNewFile,BufRead *.sqr,*.sqi		setf sqr
2101
2102" OpenSSH configuration
2103au BufNewFile,BufRead ssh_config,*/.ssh/config	setf sshconfig
2104
2105" OpenSSH server configuration
2106au BufNewFile,BufRead sshd_config		setf sshdconfig
2107
2108" Stata
2109au BufNewFile,BufRead *.ado,*.class,*.do,*.imata,*.mata   setf stata
2110
2111" SMCL
2112au BufNewFile,BufRead *.hlp,*.ihlp,*.smcl	setf smcl
2113
2114" Stored Procedures
2115au BufNewFile,BufRead *.stp			setf stp
2116
2117" Standard ML
2118au BufNewFile,BufRead *.sml			setf sml
2119
2120" Sratus VOS command macro
2121au BufNewFile,BufRead *.cm			setf voscm
2122
2123" Sysctl
2124au BufNewFile,BufRead */etc/sysctl.conf,*/etc/sysctl.d/*.conf	setf sysctl
2125
2126" Systemd unit files
2127au BufNewFile,BufRead */systemd/*.{automount,mount,path,service,socket,swap,target,timer}	setf systemd
2128
2129" Synopsys Design Constraints
2130au BufNewFile,BufRead *.sdc			setf sdc
2131
2132" Sudoers
2133au BufNewFile,BufRead */etc/sudoers,sudoers.tmp	setf sudoers
2134
2135" SVG (Scalable Vector Graphics)
2136au BufNewFile,BufRead *.svg			setf svg
2137
2138" If the file has an extension of 't' and is in a directory 't' or 'xt' then
2139" it is almost certainly a Perl test file.
2140" If the first line starts with '#' and contains 'perl' it's probably a Perl
2141" file.
2142" (Slow test) If a file contains a 'use' statement then it is almost certainly
2143" a Perl file.
2144func! s:FTperl()
2145  let dirname = expand("%:p:h:t")
2146  if expand("%:e") == 't' && (dirname == 't' || dirname == 'xt')
2147    setf perl
2148    return 1
2149  endif
2150  if getline(1)[0] == '#' && getline(1) =~ 'perl'
2151    setf perl
2152    return 1
2153  endif
2154  if search('^use\s\s*\k', 'nc', 30)
2155    setf perl
2156    return 1
2157  endif
2158  return 0
2159endfunc
2160
2161" Tads (or Nroff or Perl test file)
2162au BufNewFile,BufRead *.t
2163	\ if !s:FTnroff() && !s:FTperl() | setf tads | endif
2164
2165" Tags
2166au BufNewFile,BufRead tags			setf tags
2167
2168" TAK
2169au BufNewFile,BufRead *.tak			setf tak
2170
2171" Task
2172au BufRead,BufNewFile {pending,completed,undo}.data  setf taskdata
2173au BufRead,BufNewFile *.task			setf taskedit
2174
2175" Tcl (JACL too)
2176au BufNewFile,BufRead *.tcl,*.tk,*.itcl,*.itk,*.jacl	setf tcl
2177
2178" TealInfo
2179au BufNewFile,BufRead *.tli			setf tli
2180
2181" Telix Salt
2182au BufNewFile,BufRead *.slt			setf tsalt
2183
2184" Tera Term Language
2185au BufRead,BufNewFile *.ttl			setf teraterm
2186
2187" Terminfo
2188au BufNewFile,BufRead *.ti			setf terminfo
2189
2190" TeX
2191au BufNewFile,BufRead *.latex,*.sty,*.dtx,*.ltx,*.bbl	setf tex
2192au BufNewFile,BufRead *.tex			call s:FTtex()
2193
2194" Choose context, plaintex, or tex (LaTeX) based on these rules:
2195" 1. Check the first line of the file for "%&<format>".
2196" 2. Check the first 1000 non-comment lines for LaTeX or ConTeXt keywords.
2197" 3. Default to "latex" or to g:tex_flavor, can be set in user's vimrc.
2198func! s:FTtex()
2199  let firstline = getline(1)
2200  if firstline =~ '^%&\s*\a\+'
2201    let format = tolower(matchstr(firstline, '\a\+'))
2202    let format = substitute(format, 'pdf', '', '')
2203    if format == 'tex'
2204      let format = 'plain'
2205    endif
2206  else
2207    " Default value, may be changed later:
2208    let format = exists("g:tex_flavor") ? g:tex_flavor : 'plain'
2209    " Save position, go to the top of the file, find first non-comment line.
2210    let save_cursor = getpos('.')
2211    call cursor(1,1)
2212    let firstNC = search('^\s*[^[:space:]%]', 'c', 1000)
2213    if firstNC " Check the next thousand lines for a LaTeX or ConTeXt keyword.
2214      let lpat = 'documentclass\>\|usepackage\>\|begin{\|newcommand\>\|renewcommand\>'
2215      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\>'
2216      let kwline = search('^\s*\\\%(' . lpat . '\)\|^\s*\\\(' . cpat . '\)',
2217			      \ 'cnp', firstNC + 1000)
2218      if kwline == 1	" lpat matched
2219	let format = 'latex'
2220      elseif kwline == 2	" cpat matched
2221	let format = 'context'
2222      endif		" If neither matched, keep default set above.
2223      " let lline = search('^\s*\\\%(' . lpat . '\)', 'cn', firstNC + 1000)
2224      " let cline = search('^\s*\\\%(' . cpat . '\)', 'cn', firstNC + 1000)
2225      " if cline > 0
2226      "   let format = 'context'
2227      " endif
2228      " if lline > 0 && (cline == 0 || cline > lline)
2229      "   let format = 'tex'
2230      " endif
2231    endif " firstNC
2232    call setpos('.', save_cursor)
2233  endif " firstline =~ '^%&\s*\a\+'
2234
2235  " Translation from formats to file types.  TODO:  add AMSTeX, RevTex, others?
2236  if format == 'plain'
2237    setf plaintex
2238  elseif format == 'context'
2239    setf context
2240  else " probably LaTeX
2241    setf tex
2242  endif
2243  return
2244endfunc
2245
2246" ConTeXt
2247au BufNewFile,BufRead tex/context/*/*.tex,*.mkii,*.mkiv   setf context
2248
2249" Texinfo
2250au BufNewFile,BufRead *.texinfo,*.texi,*.txi	setf texinfo
2251
2252" TeX configuration
2253au BufNewFile,BufRead texmf.cnf			setf texmf
2254
2255" Tidy config
2256au BufNewFile,BufRead .tidyrc,tidyrc		setf tidy
2257
2258" TF mud client
2259au BufNewFile,BufRead *.tf,.tfrc,tfrc		setf tf
2260
2261" TPP - Text Presentation Program
2262au BufNewFile,BufReadPost *.tpp			setf tpp
2263
2264" Treetop
2265au BufRead,BufNewFile *.treetop			setf treetop
2266
2267" Trustees
2268au BufNewFile,BufRead trustees.conf		setf trustees
2269
2270" TSS - Geometry
2271au BufNewFile,BufReadPost *.tssgm		setf tssgm
2272
2273" TSS - Optics
2274au BufNewFile,BufReadPost *.tssop		setf tssop
2275
2276" TSS - Command Line (temporary)
2277au BufNewFile,BufReadPost *.tsscl		setf tsscl
2278
2279" TWIG files
2280au BufNewFile,BufReadPost *.twig		setf twig
2281
2282" Motif UIT/UIL files
2283au BufNewFile,BufRead *.uit,*.uil		setf uil
2284
2285" Udev conf
2286au BufNewFile,BufRead */etc/udev/udev.conf	setf udevconf
2287
2288" Udev permissions
2289au BufNewFile,BufRead */etc/udev/permissions.d/*.permissions setf udevperm
2290"
2291" Udev symlinks config
2292au BufNewFile,BufRead */etc/udev/cdsymlinks.conf	setf sh
2293
2294" UnrealScript
2295au BufNewFile,BufRead *.uc			setf uc
2296
2297" Updatedb
2298au BufNewFile,BufRead */etc/updatedb.conf	setf updatedb
2299
2300" Upstart (init(8)) config files
2301au BufNewFile,BufRead */usr/share/upstart/*.conf	       setf upstart
2302au BufNewFile,BufRead */usr/share/upstart/*.override	       setf upstart
2303au BufNewFile,BufRead */etc/init/*.conf,*/etc/init/*.override  setf upstart
2304au BufNewFile,BufRead */.init/*.conf,*/.init/*.override        setf upstart
2305au BufNewFile,BufRead */.config/upstart/*.conf		       setf upstart
2306au BufNewFile,BufRead */.config/upstart/*.override	       setf upstart
2307
2308" Vera
2309au BufNewFile,BufRead *.vr,*.vri,*.vrh		setf vera
2310
2311" Verilog HDL
2312au BufNewFile,BufRead *.v			setf verilog
2313
2314" Verilog-AMS HDL
2315au BufNewFile,BufRead *.va,*.vams		setf verilogams
2316
2317" SystemVerilog
2318au BufNewFile,BufRead *.sv,*.svh		setf systemverilog
2319
2320" VHDL
2321au BufNewFile,BufRead *.hdl,*.vhd,*.vhdl,*.vbe,*.vst  setf vhdl
2322au BufNewFile,BufRead *.vhdl_[0-9]*		call s:StarSetf('vhdl')
2323
2324" Vim script
2325au BufNewFile,BufRead *.vim,*.vba,.exrc,_exrc	setf vim
2326
2327" Viminfo file
2328au BufNewFile,BufRead .viminfo,_viminfo		setf viminfo
2329
2330" Virata Config Script File or Drupal module
2331au BufRead,BufNewFile *.hw,*.module,*.pkg
2332	\ if getline(1) =~ '<?php' |
2333	\   setf php |
2334	\ else |
2335	\   setf virata |
2336	\ endif
2337
2338" Visual Basic (also uses *.bas) or FORM
2339au BufNewFile,BufRead *.frm			call s:FTVB("form")
2340
2341" SaxBasic is close to Visual Basic
2342au BufNewFile,BufRead *.sba			setf vb
2343
2344" Vgrindefs file
2345au BufNewFile,BufRead vgrindefs			setf vgrindefs
2346
2347" VRML V1.0c
2348au BufNewFile,BufRead *.wrl			setf vrml
2349
2350" Vroom (vim testing and executable documentation)
2351au BufNewFile,BufRead *.vroom			setf vroom
2352
2353" Webmacro
2354au BufNewFile,BufRead *.wm			setf webmacro
2355
2356" Wget config
2357au BufNewFile,BufRead .wgetrc,wgetrc		setf wget
2358
2359" Website MetaLanguage
2360au BufNewFile,BufRead *.wml			setf wml
2361
2362" Winbatch
2363au BufNewFile,BufRead *.wbt			setf winbatch
2364
2365" WSML
2366au BufNewFile,BufRead *.wsml			setf wsml
2367
2368" WvDial
2369au BufNewFile,BufRead wvdial.conf,.wvdialrc	setf wvdial
2370
2371" CVS RC file
2372au BufNewFile,BufRead .cvsrc			setf cvsrc
2373
2374" CVS commit file
2375au BufNewFile,BufRead cvs\d\+			setf cvs
2376
2377" WEB (*.web is also used for Winbatch: Guess, based on expecting "%" comment
2378" lines in a WEB file).
2379au BufNewFile,BufRead *.web
2380	\ if getline(1)[0].getline(2)[0].getline(3)[0].getline(4)[0].getline(5)[0] =~ "%" |
2381	\   setf web |
2382	\ else |
2383	\   setf winbatch |
2384	\ endif
2385
2386" Windows Scripting Host and Windows Script Component
2387au BufNewFile,BufRead *.ws[fc]			setf wsh
2388
2389" XHTML
2390au BufNewFile,BufRead *.xhtml,*.xht		setf xhtml
2391
2392" X Pixmap (dynamically sets colors, use BufEnter to make it work better)
2393au BufEnter *.xpm
2394	\ if getline(1) =~ "XPM2" |
2395	\   setf xpm2 |
2396	\ else |
2397	\   setf xpm |
2398	\ endif
2399au BufEnter *.xpm2				setf xpm2
2400
2401" XFree86 config
2402au BufNewFile,BufRead XF86Config
2403	\ if getline(1) =~ '\<XConfigurator\>' |
2404	\   let b:xf86conf_xfree86_version = 3 |
2405	\ endif |
2406	\ setf xf86conf
2407au BufNewFile,BufRead */xorg.conf.d/*.conf
2408	\ let b:xf86conf_xfree86_version = 4 |
2409	\ setf xf86conf
2410
2411" Xorg config
2412au BufNewFile,BufRead xorg.conf,xorg.conf-4	let b:xf86conf_xfree86_version = 4 | setf xf86conf
2413
2414" Xinetd conf
2415au BufNewFile,BufRead */etc/xinetd.conf		setf xinetd
2416
2417" XS Perl extension interface language
2418au BufNewFile,BufRead *.xs			setf xs
2419
2420" X resources file
2421au BufNewFile,BufRead .Xdefaults,.Xpdefaults,.Xresources,xdm-config,*.ad setf xdefaults
2422
2423" Xmath
2424au BufNewFile,BufRead *.msc,*.msf		setf xmath
2425au BufNewFile,BufRead *.ms
2426	\ if !s:FTnroff() | setf xmath | endif
2427
2428" XML  specific variants: docbk and xbl
2429au BufNewFile,BufRead *.xml			call s:FTxml()
2430
2431func! s:FTxml()
2432  let n = 1
2433  while n < 100 && n < line("$")
2434    let line = getline(n)
2435    " DocBook 4 or DocBook 5.
2436    let is_docbook4 = line =~ '<!DOCTYPE.*DocBook'
2437    let is_docbook5 = line =~ ' xmlns="http://docbook.org/ns/docbook"'
2438    if is_docbook4 || is_docbook5
2439      let b:docbk_type = "xml"
2440      if is_docbook5
2441	let b:docbk_ver = 5
2442      else
2443	let b:docbk_ver = 4
2444      endif
2445      setf docbk
2446      return
2447    endif
2448    if line =~ 'xmlns:xbl="http://www.mozilla.org/xbl"'
2449      setf xbl
2450      return
2451    endif
2452    let n += 1
2453  endwhile
2454  setf xml
2455endfunc
2456
2457" XMI (holding UML models) is also XML
2458au BufNewFile,BufRead *.xmi			setf xml
2459
2460" CSPROJ files are Visual Studio.NET's XML-based project config files
2461au BufNewFile,BufRead *.csproj,*.csproj.user	setf xml
2462
2463" Qt Linguist translation source and Qt User Interface Files are XML
2464au BufNewFile,BufRead *.ts,*.ui			setf xml
2465
2466" TPM's are RDF-based descriptions of TeX packages (Nikolai Weibull)
2467au BufNewFile,BufRead *.tpm			setf xml
2468
2469" Xdg menus
2470au BufNewFile,BufRead */etc/xdg/menus/*.menu	setf xml
2471
2472" ATI graphics driver configuration
2473au BufNewFile,BufRead fglrxrc			setf xml
2474
2475" XLIFF (XML Localisation Interchange File Format) is also XML
2476au BufNewFile,BufRead *.xlf			setf xml
2477au BufNewFile,BufRead *.xliff			setf xml
2478
2479" XML User Interface Language
2480au BufNewFile,BufRead *.xul			setf xml
2481
2482" X11 xmodmap (also see below)
2483au BufNewFile,BufRead *Xmodmap			setf xmodmap
2484
2485" Xquery
2486au BufNewFile,BufRead *.xq,*.xql,*.xqm,*.xquery,*.xqy	setf xquery
2487
2488" XSD
2489au BufNewFile,BufRead *.xsd			setf xsd
2490
2491" Xslt
2492au BufNewFile,BufRead *.xsl,*.xslt		setf xslt
2493
2494" Yacc
2495au BufNewFile,BufRead *.yy,*.yxx,*.y++		setf yacc
2496
2497" Yacc or racc
2498au BufNewFile,BufRead *.y			call s:FTy()
2499
2500func! s:FTy()
2501  let n = 1
2502  while n < 100 && n < line("$")
2503    let line = getline(n)
2504    if line =~ '^\s*%'
2505      setf yacc
2506      return
2507    endif
2508    if getline(n) =~ '^\s*\(#\|class\>\)' && getline(n) !~ '^\s*#\s*include'
2509      setf racc
2510      return
2511    endif
2512    let n = n + 1
2513  endwhile
2514  setf yacc
2515endfunc
2516
2517
2518" Yaml
2519au BufNewFile,BufRead *.yaml,*.yml		setf yaml
2520
2521" yum conf (close enough to dosini)
2522au BufNewFile,BufRead */etc/yum.conf		setf dosini
2523
2524" Zimbu
2525au BufNewFile,BufRead *.zu			setf zimbu
2526" Zimbu Templates
2527au BufNewFile,BufRead *.zut			setf zimbutempl
2528
2529" Zope
2530"   dtml (zope dynamic template markup language), pt (zope page template),
2531"   cpt (zope form controller page template)
2532au BufNewFile,BufRead *.dtml,*.pt,*.cpt		call s:FThtml()
2533"   zsql (zope sql method)
2534au BufNewFile,BufRead *.zsql			call s:SQL()
2535
2536" Z80 assembler asz80
2537au BufNewFile,BufRead *.z8a			setf z8a
2538
2539augroup END
2540
2541
2542" Source the user-specified filetype file, for backwards compatibility with
2543" Vim 5.x.
2544if exists("myfiletypefile") && filereadable(expand(myfiletypefile))
2545  execute "source " . myfiletypefile
2546endif
2547
2548
2549" Check for "*" after loading myfiletypefile, so that scripts.vim is only used
2550" when there are no matching file name extensions.
2551" Don't do this for compressed files.
2552augroup filetypedetect
2553au BufNewFile,BufRead *
2554	\ if !did_filetype() && expand("<amatch>") !~ g:ft_ignore_pat
2555	\ | runtime! scripts.vim | endif
2556au StdinReadPost * if !did_filetype() | runtime! scripts.vim | endif
2557
2558
2559" Extra checks for when no filetype has been detected now.  Mostly used for
2560" patterns that end in "*".  E.g., "zsh*" matches "zsh.vim", but that's a Vim
2561" script file.
2562" Most of these should call s:StarSetf() to avoid names ending in .gz and the
2563" like are used.
2564
2565" More Apache config files
2566au BufNewFile,BufRead access.conf*,apache.conf*,apache2.conf*,httpd.conf*,srm.conf*	call s:StarSetf('apache')
2567au BufNewFile,BufRead */etc/apache2/*.conf*,*/etc/apache2/conf.*/*,*/etc/apache2/mods-*/*,*/etc/apache2/sites-*/*,*/etc/httpd/conf.d/*.conf*		call s:StarSetf('apache')
2568
2569" Asterisk config file
2570au BufNewFile,BufRead *asterisk/*.conf*		call s:StarSetf('asterisk')
2571au BufNewFile,BufRead *asterisk*/*voicemail.conf* call s:StarSetf('asteriskvm')
2572
2573" Bazaar version control
2574au BufNewFile,BufRead bzr_log.*			setf bzr
2575
2576" BIND zone
2577au BufNewFile,BufRead */named/db.*,*/bind/db.*	call s:StarSetf('bindzone')
2578
2579" Calendar
2580au BufNewFile,BufRead */.calendar/*,
2581	\*/share/calendar/*/calendar.*,*/share/calendar/calendar.*
2582	\					call s:StarSetf('calendar')
2583
2584" Changelog
2585au BufNewFile,BufRead [cC]hange[lL]og*
2586	\ if getline(1) =~ '; urgency='
2587	\|  call s:StarSetf('debchangelog')
2588	\|else
2589	\|  call s:StarSetf('changelog')
2590	\|endif
2591
2592" Crontab
2593au BufNewFile,BufRead crontab,crontab.*,*/etc/cron.d/*		call s:StarSetf('crontab')
2594
2595" dnsmasq(8) configuration
2596au BufNewFile,BufRead */etc/dnsmasq.d/*		call s:StarSetf('dnsmasq')
2597
2598" Dracula
2599au BufNewFile,BufRead drac.*			call s:StarSetf('dracula')
2600
2601" Fvwm
2602au BufNewFile,BufRead */.fvwm/*			call s:StarSetf('fvwm')
2603au BufNewFile,BufRead *fvwmrc*,*fvwm95*.hook
2604	\ let b:fvwm_version = 1 | call s:StarSetf('fvwm')
2605au BufNewFile,BufRead *fvwm2rc*
2606	\ if expand("<afile>:e") == "m4"
2607	\|  call s:StarSetf('fvwm2m4')
2608	\|else
2609	\|  let b:fvwm_version = 2 | call s:StarSetf('fvwm')
2610	\|endif
2611
2612" Gedcom
2613au BufNewFile,BufRead */tmp/lltmp*		call s:StarSetf('gedcom')
2614
2615" GTK RC
2616au BufNewFile,BufRead .gtkrc*,gtkrc*		call s:StarSetf('gtkrc')
2617
2618" Jam
2619au BufNewFile,BufRead Prl*.*,JAM*.*		call s:StarSetf('jam')
2620
2621" Jargon
2622au! BufNewFile,BufRead *jarg*
2623	\ if getline(1).getline(2).getline(3).getline(4).getline(5) =~? 'THIS IS THE JARGON FILE'
2624	\|  call s:StarSetf('jargon')
2625	\|endif
2626
2627" Kconfig
2628au BufNewFile,BufRead Kconfig.*			call s:StarSetf('kconfig')
2629
2630" Lilo: Linux loader
2631au BufNewFile,BufRead lilo.conf*		call s:StarSetf('lilo')
2632
2633" Logcheck
2634au BufNewFile,BufRead */etc/logcheck/*.d*/*	call s:StarSetf('logcheck')
2635
2636" Makefile
2637au BufNewFile,BufRead [mM]akefile*		call s:StarSetf('make')
2638
2639" Ruby Makefile
2640au BufNewFile,BufRead [rR]akefile*		call s:StarSetf('ruby')
2641
2642" Mail (also matches muttrc.vim, so this is below the other checks)
2643au BufNewFile,BufRead mutt[[:alnum:]._-]\\\{6\}	setf mail
2644
2645au BufNewFile,BufRead reportbug-*		call s:StarSetf('mail')
2646
2647" Modconf
2648au BufNewFile,BufRead */etc/modutils/*
2649	\ if executable(expand("<afile>")) != 1
2650	\|  call s:StarSetf('modconf')
2651	\|endif
2652au BufNewFile,BufRead */etc/modprobe.*		call s:StarSetf('modconf')
2653
2654" Mutt setup file
2655au BufNewFile,BufRead .mutt{ng,}rc*,*/.mutt{ng,}/mutt{ng,}rc*	call s:StarSetf('muttrc')
2656au BufNewFile,BufRead mutt{ng,}rc*,Mutt{ng,}rc*		call s:StarSetf('muttrc')
2657
2658" Nroff macros
2659au BufNewFile,BufRead tmac.*			call s:StarSetf('nroff')
2660
2661" Pam conf
2662au BufNewFile,BufRead */etc/pam.d/*		call s:StarSetf('pamconf')
2663
2664" Printcap and Termcap
2665au BufNewFile,BufRead *printcap*
2666	\ if !did_filetype()
2667	\|  let b:ptcap_type = "print" | call s:StarSetf('ptcap')
2668	\|endif
2669au BufNewFile,BufRead *termcap*
2670	\ if !did_filetype()
2671	\|  let b:ptcap_type = "term" | call s:StarSetf('ptcap')
2672	\|endif
2673
2674" ReDIF
2675" Only used when the .rdf file was not detected to be XML.
2676au BufRead,BufNewFile *.rdf			call s:Redif()
2677func! s:Redif()
2678  let lnum = 1
2679  while lnum <= 5 && lnum < line('$')
2680    if getline(lnum) =~ "^\ctemplate-type:"
2681      setf redif
2682      return
2683    endif
2684    let lnum = lnum + 1
2685  endwhile
2686endfunc
2687
2688" Remind
2689au BufNewFile,BufRead .reminders*		call s:StarSetf('remind')
2690
2691" Vim script
2692au BufNewFile,BufRead *vimrc*			call s:StarSetf('vim')
2693
2694" Subversion commit file
2695au BufNewFile,BufRead svn-commit*.tmp		setf svn
2696
2697" X resources file
2698au BufNewFile,BufRead Xresources*,*/app-defaults/*,*/Xresources/* call s:StarSetf('xdefaults')
2699
2700" XFree86 config
2701au BufNewFile,BufRead XF86Config-4*
2702	\ let b:xf86conf_xfree86_version = 4 | call s:StarSetf('xf86conf')
2703au BufNewFile,BufRead XF86Config*
2704	\ if getline(1) =~ '\<XConfigurator\>'
2705	\|  let b:xf86conf_xfree86_version = 3
2706	\|endif
2707	\|call s:StarSetf('xf86conf')
2708
2709" X11 xmodmap
2710au BufNewFile,BufRead *xmodmap*			call s:StarSetf('xmodmap')
2711
2712" Xinetd conf
2713au BufNewFile,BufRead */etc/xinetd.d/*		call s:StarSetf('xinetd')
2714
2715" yum conf (close enough to dosini)
2716au BufNewFile,BufRead */etc/yum.repos.d/*	call s:StarSetf('dosini')
2717
2718" Z-Shell script
2719au BufNewFile,BufRead zsh*,zlog*		call s:StarSetf('zsh')
2720
2721
2722" Plain text files, needs to be far down to not override others.  This avoids
2723" the "conf" type being used if there is a line starting with '#'.
2724au BufNewFile,BufRead *.txt,*.text,README	setf text
2725
2726
2727" Use the filetype detect plugins.  They may overrule any of the previously
2728" detected filetypes.
2729runtime! ftdetect/*.vim
2730
2731" NOTE: The above command could have ended the filetypedetect autocmd group
2732" and started another one. Let's make sure it has ended to get to a consistent
2733" state.
2734augroup END
2735
2736" Generic configuration file (check this last, it's just guessing!)
2737au filetypedetect BufNewFile,BufRead,StdinReadPost *
2738	\ if !did_filetype() && expand("<amatch>") !~ g:ft_ignore_pat
2739	\    && (getline(1) =~ '^#' || getline(2) =~ '^#' || getline(3) =~ '^#'
2740	\	|| getline(4) =~ '^#' || getline(5) =~ '^#') |
2741	\   setf conf |
2742	\ endif
2743
2744
2745" If the GUI is already running, may still need to install the Syntax menu.
2746" Don't do it when the 'M' flag is included in 'guioptions'.
2747if has("menu") && has("gui_running")
2748      \ && !exists("did_install_syntax_menu") && &guioptions !~# "M"
2749  source <sfile>:p:h/menu.vim
2750endif
2751
2752" Function called for testing all functions defined here.  These are
2753" script-local, thus need to be executed here.
2754" Returns a string with error messages (hopefully empty).
2755func! TestFiletypeFuncs(testlist)
2756  let output = ''
2757  for f in a:testlist
2758    try
2759      exe f
2760    catch
2761      let output = output . "\n" . f . ": " . v:exception
2762    endtry
2763  endfor
2764  return output
2765endfunc
2766
2767" Restore 'cpoptions'
2768let &cpo = s:cpo_save
2769unlet s:cpo_save
2770