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