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