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