xref: /vim-8.2.3635/runtime/filetype.vim (revision a3227e2b)
1" Vim support file to detect file types
2"
3" Maintainer:	Bram Moolenaar <[email protected]>
4" Last Change:	2006 Mar 05
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
19au BufNewFile,BufRead ?\+.orig,?\+.bak,?\+.old,?\+.new,?\+.rpmsave,?\+.rpmnew
20	\ exe "doau filetypedetect BufRead " . expand("<afile>:r")
21au BufNewFile,BufRead *~
22	\ let s:name = expand("<afile>") |
23	\ let s:short = substitute(s:name, '\~$', '', '') |
24	\ if s:name != s:short && s:short != "" |
25	\   exe "doau filetypedetect BufRead " . s:short |
26	\ endif |
27	\ unlet s:name |
28	\ unlet s:short
29au BufNewFile,BufRead ?\+.in
30	\ if expand("<afile>:t") != "configure.in" |
31	\   exe "doau filetypedetect BufRead " . expand("<afile>:r") |
32	\ endif
33
34" Pattern used to match file names which should not be inspected.
35" Currently finds compressed files.
36if !exists("g:ft_ignore_pat")
37  let g:ft_ignore_pat = '\.\(Z\|gz\|bz2\|zip\|tgz\)$'
38endif
39
40" Function used for patterns that end in a star: don't set the filetype if the
41" file name matches ft_ignore_pat.
42fun! s:StarSetf(ft)
43  if expand("<amatch>") !~ g:ft_ignore_pat
44    exe 'setf ' . a:ft
45  endif
46endfun
47
48" Abaqus or Trasys
49au BufNewFile,BufRead *.inp			call s:Check_inp()
50
51fun! s:Check_inp()
52  if getline(1) =~ '^\*'
53    setf abaqus
54  else
55    let n = 1
56    if line("$") > 500
57      let nmax = 500
58    else
59      let nmax = line("$")
60    endif
61    while n <= nmax
62      if getline(n) =~? "^header surface data"
63	setf trasys
64	break
65      endif
66      let n = n + 1
67    endwhile
68  endif
69endfun
70
71" A-A-P recipe
72au BufNewFile,BufRead *.aap			setf aap
73
74" A2ps printing utility
75au BufNewFile,BufRead etc/a2ps.cfg,etc/a2ps/*.cfg,a2psrc,.a2psrc setf a2ps
76
77" ABAB/4
78au BufNewFile,BufRead *.abap			setf abap
79
80" ABC music notation
81au BufNewFile,BufRead *.abc			setf abc
82
83" ABEL
84au BufNewFile,BufRead *.abl			setf abel
85
86" AceDB
87au BufNewFile,BufRead *.wrm			setf acedb
88
89" Ada (83, 9X, 95)
90au BufNewFile,BufRead *.adb,*.ads,*.ada		setf ada
91
92" AHDL
93au BufNewFile,BufRead *.tdf			setf ahdl
94
95" AMPL
96au BufNewFile,BufRead *.run			setf ampl
97
98" Ant
99au BufNewFile,BufRead build.xml			setf ant
100
101" Apache style config file
102au BufNewFile,BufRead proftpd.conf*		call s:StarSetf('apachestyle')
103
104" Apache config file
105au BufNewFile,BufRead .htaccess			 setf apache
106au BufNewFile,BufRead httpd.conf*,srm.conf*,access.conf*,apache.conf*,apache2.conf*,/etc/apache2/*.conf* call s:StarSetf('apache')
107
108" XA65 MOS6510 cross assembler
109au BufNewFile,BufRead *.a65			setf a65
110
111" Applix ELF
112au BufNewFile,BufRead *.am
113	\ if expand("<afile>") !~? 'Makefile.am\>' | setf elf | endif
114
115" ALSA configuration
116au BufNewFile,BufRead ~/.asoundrc,/usr/share/alsa/alsa.conf,/etc/asound.conf	setf alsaconf
117
118" Arc Macro Language
119au BufNewFile,BufRead *.aml			setf aml
120
121" Arch Inventory file
122au BufNewFile,BufRead .arch-inventory,=tagging-method	setf arch
123
124" ART*Enterprise (formerly ART-IM)
125au BufNewFile,BufRead *.art			setf art
126
127" ASN.1
128au BufNewFile,BufRead *.asn,*.asn1		setf asn
129
130" Active Server Pages (with Visual Basic Script)
131au BufNewFile,BufRead *.asa
132	\ if exists("g:filetype_asa") |
133	\   exe "setf " . g:filetype_asa |
134	\ else |
135	\   setf aspvbs |
136	\ endif
137
138" Active Server Pages (with Perl or Visual Basic Script)
139au BufNewFile,BufRead *.asp
140	\ if exists("g:filetype_asp") |
141	\   exe "setf " . g:filetype_asp |
142	\ elseif getline(1) . getline(2) . getline(3) =~? "perlscript" |
143	\   setf aspperl |
144	\ else |
145	\   setf aspvbs |
146	\ endif
147
148" Grub (must be before catch *.lst)
149au BufNewFile,BufRead /boot/grub/menu.lst,/boot/grub/grub.conf	setf grub
150
151" Assembly (all kinds)
152" *.lst is not pure assembly, it has two extra columns (address, byte codes)
153au BufNewFile,BufRead *.asm,*.[sS],*.[aA],*.mac,*.lst	call s:FTasm()
154
155" This function checks for the kind of assembly that is wanted by the user, or
156" can be detected from the first five lines of the file.
157fun! s:FTasm()
158  " make sure b:asmsyntax exists
159  if !exists("b:asmsyntax")
160    let b:asmsyntax = ""
161  endif
162
163  if b:asmsyntax == ""
164    call s:FTasmsyntax()
165  endif
166
167  " if b:asmsyntax still isn't set, default to asmsyntax or GNU
168  if b:asmsyntax == ""
169    if exists("g:asmsyntax")
170      let b:asmsyntax = g:asmsyntax
171    else
172      let b:asmsyntax = "asm"
173    endif
174  endif
175
176  exe "setf " . b:asmsyntax
177endfun
178
179fun! s:FTasmsyntax()
180  " see if file contains any asmsyntax=foo overrides. If so, change
181  " b:asmsyntax appropriately
182  let head = " ".getline(1)." ".getline(2)." ".getline(3)." ".getline(4).
183	\" ".getline(5)." "
184  if head =~ '\sasmsyntax=\S\+\s'
185    let b:asmsyntax = substitute(head, '.*\sasmsyntax=\(\S\+\)\s.*','\1', "")
186  elseif ((head =~? '\.title') || (head =~? '\.ident') || (head =~? '\.macro') || (head =~? '\.subtitle') || (head =~? '\.library'))
187    let b:asmsyntax = "vmasm"
188  endif
189endfun
190
191" Macro (VAX)
192au BufNewFile,BufRead *.mar			setf vmasm
193
194" Atlas
195au BufNewFile,BufRead *.atl,*.as		setf atlas
196
197" Automake
198au BufNewFile,BufRead [mM]akefile.am		setf automake
199
200" Autotest .at files are actually m4
201au BufNewFile,BufRead *.at			setf m4
202
203" Avenue
204au BufNewFile,BufRead *.ave			setf ave
205
206" Awk
207au BufNewFile,BufRead *.awk			setf awk
208
209" B
210au BufNewFile,BufRead *.mch,*.ref,*.imp		setf b
211
212" BASIC or Visual Basic
213au BufNewFile,BufRead *.bas			call s:FTVB("basic")
214
215" Check if one of the first five lines contains "VB_Name".  In that case it is
216" probably a Visual Basic file.  Otherwise it's assumed to be "alt" filetype.
217fun! s:FTVB(alt)
218  if getline(1).getline(2).getline(3).getline(4).getline(5) =~? 'VB_Name\|Begin VB\.\(Form\|MDIForm\|UserControl\)'
219    setf vb
220  else
221    exe "setf " . a:alt
222  endif
223endfun
224
225" Visual Basic Script (close to Visual Basic)
226au BufNewFile,BufRead *.vbs,*.dsm,*.ctl		setf vb
227
228" Batch file for MSDOS.
229au BufNewFile,BufRead *.bat,*.sys		setf dosbatch
230" *.cmd is close to a Batch file, but on OS/2 Rexx files also use *.cmd.
231au BufNewFile,BufRead *.cmd
232	\ if getline(1) =~ '^/\*' | setf rexx | else | setf dosbatch | endif
233
234" Batch file for 4DOS
235au BufNewFile,BufRead *.btm			call s:FTbtm()
236fun! s:FTbtm()
237  if exists("g:dosbatch_syntax_for_btm") && g:dosbatch_syntax_for_btm
238    setf dosbatch
239  else
240    setf btm
241  endif
242endfun
243
244" BC calculator
245au BufNewFile,BufRead *.bc			setf bc
246
247" BDF font
248au BufNewFile,BufRead *.bdf			setf bdf
249
250" BibTeX bibliography database file
251au BufNewFile,BufRead *.bib			setf bib
252
253" BIND configuration
254au BufNewFile,BufRead named.conf,rndc.conf	setf named
255
256" BIND zone
257au BufNewFile,BufRead named.root		setf bindzone
258
259" Blank
260au BufNewFile,BufRead *.bl			setf blank
261
262" C or lpc
263au BufNewFile,BufRead *.c			call s:FTlpc()
264
265fun! s:FTlpc()
266  if exists("g:lpc_syntax_for_c")
267    let lnum = 1
268    while lnum <= 12
269      if getline(lnum) =~# '^\(//\|inherit\|private\|protected\|nosave\|string\|object\|mapping\|mixed\)'
270	setf lpc
271	return
272      endif
273      let lnum = lnum + 1
274    endwhile
275  endif
276  setf c
277endfun
278
279" Calendar
280au BufNewFile,BufRead calendar			setf calendar
281au BufNewFile,BufRead */.calendar/*,
282	\*/share/calendar/*/calendar.*,*/share/calendar/calendar.*
283	\					call s:StarSetf('calendar')
284
285" C#
286au BufNewFile,BufRead *.cs			setf cs
287
288" Cfengine
289au BufNewFile,BufRead cfengine.conf		setf cfengine
290
291" Comshare Dimension Definition Language
292au BufNewFile,BufRead *.cdl			setf cdl
293
294" Controllable Regex Mutilator
295au BufNewFile,BufRead *.crm			setf crm
296
297" Cyn++
298au BufNewFile,BufRead *.cyn			setf cynpp
299
300" Cynlib
301" .cc and .cpp files can be C++ or Cynlib.
302au BufNewFile,BufRead *.cc
303	\ if exists("cynlib_syntax_for_cc")|setf cynlib|else|setf cpp|endif
304au BufNewFile,BufRead *.cpp
305	\ if exists("cynlib_syntax_for_cpp")|setf cynlib|else|setf cpp|endif
306
307" C++
308if has("fname_case")
309  au BufNewFile,BufRead *.cxx,*.c++,*.C,*.H,*.hh,*.hxx,*.hpp,*.moc,*.tcc,*.inl setf cpp
310else
311  au BufNewFile,BufRead *.cxx,*.c++,*.hh,*.hxx,*.hpp,*.moc,*.tcc,*.inl setf cpp
312endif
313
314" .h files can be C, Ch or C++, set c_syntax_for_h if you want C,
315" ch_syntax_for_h if you want Ch.
316au BufNewFile,BufRead *.h
317	\ if exists("c_syntax_for_h") | setf c |
318	\ elseif exists("ch_syntax_for_h") | setf ch |
319	\ else | setf cpp | endif
320
321" Ch (CHscript)
322au BufNewFile,BufRead *.chf			setf ch
323
324" TLH files are C++ headers generated by Visual C++'s #import from typelibs
325au BufNewFile,BufRead *.tlh			setf cpp
326
327" Cascading Style Sheets
328au BufNewFile,BufRead *.css			setf css
329
330" Century Term Command Scripts (*.cmd too)
331au BufNewFile,BufRead *.con			setf cterm
332
333" Changelog
334au BufNewFile,BufRead changelog.Debian,changelog.dch setf debchangelog
335au BufNewFile,BufRead [cC]hange[lL]og		if getline(1) =~ '; urgency='
336	\| setf debchangelog | else | setf changelog | endif
337
338" CHILL
339au BufNewFile,BufRead *..ch			setf chill
340
341" Changes for WEB and CWEB or CHILL
342au BufNewFile,BufRead *.ch			call s:FTchange()
343
344" This function checks if one of the first ten lines start with a '@'.  In
345" that case it is probably a change file.
346" If the first line starts with # or ! it's probably a ch file.
347" If a line has "main", "include", "//" ir "/*" it's probably ch.
348" Otherwise CHILL is assumed.
349fun! s:FTchange()
350  let lnum = 1
351  while lnum <= 10
352    if getline(lnum)[0] == '@'
353      setf change
354      return
355    endif
356    if lnum == 1 && (getline(1)[0] == '#' || getline(1)[0] == '!')
357      setf ch
358      return
359    endif
360    if getline(lnum) =~ "MODULE"
361      setf chill
362      return
363    endif
364    if getline(lnum) =~ 'main\s*(\|#\s*include\|//'
365      setf ch
366      return
367    endif
368    let lnum = lnum + 1
369  endwhile
370  setf chill
371endfun
372
373" Clean
374au BufNewFile,BufRead *.dcl,*.icl		setf clean
375
376" Clever
377au BufNewFile,BufRead *.eni			setf cl
378
379" Clever or dtd
380au BufNewFile,BufRead *.ent			call s:FTent()
381
382fun! s:FTent()
383  " This function checks for valid cl syntax in the first five lines.
384  " Look for either an opening comment, '#', or a block start, '{".
385  " If not found, assume SGML.
386  let lnum = 1
387  while lnum < 6
388    let line = getline(lnum)
389    if line =~ '^\s*[#{]'
390      setf cl
391      return
392    elseif line !~ '^\s*$'
393      " Not a blank line, not a comment, and not a block start,
394      " so doesn't look like valid cl code.
395      break
396    endif
397    let lnum = lnum + 1
398  endw
399  setf dtd
400endfun
401
402" Clipper (or FoxPro; could also be eviews)
403au BufNewFile,BufRead *.prg
404	\ if exists("g:filetype_prg") |
405	\   exe "setf " . g:filetype_prg |
406	\ else |
407	\   setf clipper |
408	\ endif
409
410" Cobol
411au BufNewFile,BufRead *.cbl,*.cob,*.cpy,*.lib	setf cobol
412
413" Cold Fusion
414au BufNewFile,BufRead *.cfm,*.cfi,*.cfc		setf cf
415
416" Configure scripts
417au BufNewFile,BufRead configure.in,configure.ac setf config
418
419" WildPackets EtherPeek Decoder
420au BufNewFile,BufRead *.dcd			setf dcd
421
422" Enlightenment configuration files
423au BufNewFile,BufRead *enlightenment/*.cfg	setf c
424
425" Eterm
426au BufNewFile,BufRead *Eterm/*.cfg		setf eterm
427
428" Lynx config files
429au BufNewFile,BufRead lynx.cfg			setf lynx
430
431" Quake
432au BufNewFile,BufRead *baseq[2-3]/*.cfg,*id1/*.cfg	setf quake
433au BufNewFile,BufRead *quake[1-3]/*.cfg			setf quake
434
435" Quake C
436au BufNewFile,BufRead *.qc			setf c
437
438" Configure files
439au BufNewFile,BufRead *.cfg			setf cfg
440
441" Communicating Sequential Processes
442au BufNewFile,BufRead *.csp,*.fdr		setf csp
443
444" CUPL logic description and simulation
445au BufNewFile,BufRead *.pld			setf cupl
446au BufNewFile,BufRead *.si			setf cuplsim
447
448" Debian Control
449au BufNewFile,BufRead */debian/control		setf debcontrol
450
451" ROCKLinux package description
452au BufNewFile,BufRead *.desc			setf desc
453
454" the D language
455au BufNewFile,BufRead *.d			setf d
456
457" Desktop files
458au BufNewFile,BufRead *.desktop,.directory	setf desktop
459
460" Dict config
461au BufNewFile,BufRead dict.conf,.dictrc		setf dictconf
462
463" Dictd config
464au BufNewFile,BufRead dictd.conf		setf dictdconf
465
466" Diff files
467au BufNewFile,BufRead *.diff,*.rej,*.patch	setf diff
468
469" Dircolors
470au BufNewFile,BufRead .dir_colors,/etc/DIR_COLORS	setf dircolors
471
472" Diva (with Skill) or InstallShield
473au BufNewFile,BufRead *.rul
474	\ if getline(1).getline(2).getline(3).getline(4).getline(5).getline(6) =~? 'InstallShield' |
475	\   setf ishd |
476	\ else |
477	\   setf diva |
478	\ endif
479
480" DCL (Digital Command Language - vms) or DNS zone file
481au BufNewFile,BufRead *.com
482	\ if getline(1).getline(2) =~ '$ORIGIN\|$TTL\|IN\s*SOA'
483	\	|| getline(1).getline(2).getline(3).getline(4) =~ 'BIND.*named'
484	\ | setf dns | else | setf dcl | endif
485
486" DOT
487au BufNewFile,BufRead *.dot			setf dot
488
489" Dylan - lid files
490au BufNewFile,BufRead *.lid			setf dylanlid
491
492" Dylan - intr files (melange)
493au BufNewFile,BufRead *.intr			setf dylanintr
494
495" Dylan
496au BufNewFile,BufRead *.dylan			setf dylan
497
498" Microsoft Module Definition
499au BufNewFile,BufRead *.def			setf def
500
501" Dracula
502au BufNewFile,BufRead *.drac,*.drc,*lvs,*lpe	setf dracula
503
504" dsl
505au BufNewFile,BufRead *.dsl			setf dsl
506
507" DTD (Document Type Definition for XML)
508au BufNewFile,BufRead *.dtd			setf dtd
509
510" EDIF (*.edf,*.edif,*.edn,*.edo)
511au BufNewFile,BufRead *.ed\(f\|if\|n\|o\)	setf edif
512
513" Embedix Component Description
514au BufNewFile,BufRead *.ecd			setf ecd
515
516" Eiffel or Specman
517au BufNewFile,BufRead *.e,*.E			call s:FTe()
518
519" Elinks configuration
520au BufNewFile,BufRead */etc/elinks.conf,*/.elinks/elinks.conf	setf elinks
521
522fun! s:FTe()
523  let n = 1
524  while n < 100 && n < line("$")
525    if getline(n) =~ "^\\s*\\(<'\\|'>\\)\\s*$"
526      setf specman
527      return
528    endif
529    let n = n + 1
530  endwhile
531  setf eiffel
532endfun
533
534" ERicsson LANGuage
535au BufNewFile,BufRead *.erl			setf erlang
536
537" Elm Filter Rules file
538au BufNewFile,BufRead filter-rules		setf elmfilt
539
540" ESMTP rc file
541au BufNewFile,BufRead *esmtprc			setf esmtprc
542
543" ESQL-C
544au BufNewFile,BufRead *.ec,*.EC			setf esqlc
545
546" Esterel
547au BufNewFile,BufRead *.strl			setf esterel
548
549" Essbase script
550au BufNewFile,BufRead *.csc			setf csc
551
552" Exim
553au BufNewFile,BufRead exim.conf			setf exim
554
555" Expect
556au BufNewFile,BufRead *.exp			setf expect
557
558" Exports
559au BufNewFile,BufRead exports			setf exports
560
561" Factor
562au BufNewFile,BufRead *.factor			setf factor
563
564" Fetchmail RC file
565au BufNewFile,BufRead .fetchmailrc		setf fetchmail
566
567" Focus Executable
568au BufNewFile,BufRead *.fex,*.focexec		setf focexec
569
570" Focus Master file (but not for auto.master)
571au BufNewFile,BufRead auto.master		setf conf
572au BufNewFile,BufRead *.mas,*.master		setf master
573
574" Forth
575au BufNewFile,BufRead *.fs,*.ft			setf forth
576
577" Fortran
578au BufNewFile,BufRead *.f,*.F,*.for,*.fpp,*.FPP*.ftn,*.f77,*.F77,*.f90,*.F90,*.f95,*.F95	setf fortran
579
580" FStab
581au BufNewFile,BufRead fstab			setf fstab
582
583" GDB command files
584au BufNewFile,BufRead .gdbinit			setf gdb
585
586" GDMO
587au BufNewFile,BufRead *.mo,*.gdmo		setf gdmo
588
589" Gedcom
590au BufNewFile,BufRead *.ged			setf gedcom
591
592" Gkrellmrc
593au BufNewFile,BufRead gkrellmrc,gkrellmrc_?	setf gkrellmrc
594
595" GP scripts (2.0 and onward)
596au BufNewFile,BufRead *.gp			setf gp
597
598" GPG
599au BufNewFile,BufRead */.gnupg/options		setf gpg
600au BufNewFile,BufRead */.gnupg/gpg.conf		setf gpg
601au BufNewFile,BufRead /usr/**/gnupg/options.skel setf gpg
602
603" Gnuplot scripts
604au BufNewFile,BufRead *.gpi			setf gnuplot
605
606" GrADS scripts
607au BufNewFile,BufRead *.gs			setf grads
608
609" Gretl
610au BufNewFile,BufRead *.gretl			setf gretl
611
612" Groovy
613au BufNewFile,BufRead *.groovy			setf groovy
614
615" GNU Server Pages
616au BufNewFile,BufRead *.gsp			setf gsp
617
618" Group file
619au BufNewFile,BufRead /etc/group		setf group
620
621" GTK RC
622au BufNewFile,BufRead .gtkrc,gtkrc		setf gtkrc
623
624" Haskell
625au BufNewFile,BufRead *.hs			setf haskell
626au BufNewFile,BufRead *.lhs			setf lhaskell
627au BufNewFile,BufRead *.chs			setf chaskell
628
629" Hercules
630au BufNewFile,BufRead *.vc,*.ev,*.rs,*.sum,*.errsum	setf hercules
631
632" HEX (Intel)
633au BufNewFile,BufRead *.hex,*.h32		setf hex
634
635" Tilde (must be before HTML)
636au BufNewFile,BufRead *.t.html			setf tilde
637
638" HTML (.shtml and .stm for server side)
639au BufNewFile,BufRead *.html,*.htm,*.shtml,*.stm  call s:FThtml()
640
641" Distinguish between HTML and XHTML
642fun! s:FThtml()
643  let n = 1
644  while n < 10 && n < line("$")
645    if getline(n) =~ '\<DTD\s\+XHTML\s'
646      setf xhtml
647      return
648    endif
649    let n = n + 1
650  endwhile
651  setf html
652endfun
653
654" HTML with Ruby - eRuby
655au BufNewFile,BufRead *.rhtml			setf eruby
656
657" HTML with M4
658au BufNewFile,BufRead *.html.m4			setf htmlm4
659
660" HTML Cheetah template
661au BufNewFile,BufRead *.tmpl			setf htmlcheetah
662
663" Hyper Builder
664au BufNewFile,BufRead *.hb			setf hb
665
666" Icon
667au BufNewFile,BufRead *.icn			setf icon
668
669" IDL (Interface Description Language)
670au BufNewFile,BufRead *.idl			call s:FTidl()
671
672" Distinguish between standard IDL and MS-IDL
673fun! s:FTidl()
674  let n = 1
675  while n < 50 && n < line("$")
676    if getline(n) =~ '^\s*import\s\+"\(unknwn\|objidl\)\.idl"'
677      setf msidl
678      return
679    endif
680    let n = n + 1
681  endwhile
682  setf idl
683endfun
684
685" Microsoft IDL (Interface Description Language)  Also *.idl
686" MOF = WMI (Windows Management Instrumentation) Managed Object Format
687au BufNewFile,BufRead *.odl,*.mof		setf msidl
688
689" Icewm menu
690au BufNewFile,BufRead */.icewm/menu		setf icemenu
691
692" IDL (Interactive Data Language)
693au BufNewFile,BufRead *.pro			setf idlang
694
695" Indent RC
696au BufNewFile,BufRead indentrc			setf indentrc
697
698" Inform
699au BufNewFile,BufRead .indent.pro		setf indent
700
701" Inform
702au BufNewFile,BufRead *.inf,*.INF		setf inform
703
704" Ipfilter
705au BufNewFile,BufRead ipf.conf,ipf.rules	setf ipfilter
706
707" Informix 4GL (source - canonical, include file, I4GL+M4 preproc.)
708au BufNewFile,BufRead *.4gl,*.4gh,*.m4gl	setf fgl
709
710" .INI file for MSDOS
711au BufNewFile,BufRead *.ini			setf dosini
712
713" SysV Inittab
714au BufNewFile,BufRead inittab			setf inittab
715
716" Inno Setup
717au BufNewFile,BufRead *.iss			setf iss
718
719" JAL
720au BufNewFile,BufRead *.jal,*.JAL		setf jal
721
722" Jam
723au BufNewFile,BufRead *.jpl,*.jpr		setf jam
724
725" Java
726au BufNewFile,BufRead *.java,*.jav		setf java
727
728" JavaCC
729au BufNewFile,BufRead *.jj,*.jjt		setf javacc
730
731" JavaScript
732au BufNewFile,BufRead *.js,*.javascript		setf javascript
733
734" Java Server Pages
735au BufNewFile,BufRead *.jsp			setf jsp
736
737" Java Properties resource file (note: doesn't catch font.properties.pl)
738au BufNewFile,BufRead *.properties,*.properties_??,*.properties_??_??	setf jproperties
739au BufNewFile,BufRead *.properties_??_??_*	call s:StarSetf('jproperties')
740
741" Jess
742au BufNewFile,BufRead *.clp			setf jess
743
744" Jgraph
745au BufNewFile,BufRead *.jgr			setf jgraph
746
747" Kixtart
748au BufNewFile,BufRead *.kix			setf kix
749
750" Kimwitu[++]
751au BufNewFile,BufRead *.k			setf kwt
752
753" KDE script
754au BufNewFile,BufRead *.ks			setf kscript
755
756" Lace (ISE)
757au BufNewFile,BufRead *.ace,*.ACE		setf lace
758
759" Latte
760au BufNewFile,BufRead *.latte,*.lte		setf latte
761
762" Limits
763au BufNewFile,BufRead /etc/limits		setf limits
764
765" LambdaProlog (*.mod too, see Modsim)
766au BufNewFile,BufRead *.sig			setf lprolog
767
768" LDAP LDIF
769au BufNewFile,BufRead *.ldif			setf ldif
770
771" Ld loader
772au BufNewFile,BufRead *.ld			setf ld
773
774" Lex
775au BufNewFile,BufRead *.lex,*.l			setf lex
776
777" Libao
778au BufNewFile,BufRead /etc/libao.conf,*/.libao	setf libao
779
780" Libsensors
781au BufNewFile,BufRead /etc/sensors.conf		setf sensors
782
783" LFTP
784au BufNewFile,BufRead lftp.conf,.lftprc,*lftp/rc	setf lftp
785
786" Lifelines (or Lex for C++!)
787au BufNewFile,BufRead *.ll			setf lifelines
788
789" Lilo: Linux loader
790au BufNewFile,BufRead lilo.conf*		call s:StarSetf('lilo')
791
792" Lisp (*.el = ELisp, *.cl = Common Lisp, *.jl = librep Lisp)
793if has("fname_case")
794  au BufNewFile,BufRead *.lsp,*.lisp,*.el,*.cl,*.jl,*.L,.emacs,.sawfishrc setf lisp
795else
796  au BufNewFile,BufRead *.lsp,*.lisp,*.el,*.cl,*.jl,.emacs,.sawfishrc setf lisp
797endif
798
799" SBCL implementation of Common Lisp
800au BufNewFile,BufRead sbclrc,.sbclrc		setf lisp
801
802" Lite
803au BufNewFile,BufRead *.lite,*.lt		setf lite
804
805" Login access
806au BufNewFile,BufRead /etc/login.access		setf loginaccess
807
808" Login defs
809au BufNewFile,BufRead /etc/login.defs		setf logindefs
810
811" Logtalk
812au BufNewFile,BufRead *.lgt			setf logtalk
813
814" LOTOS
815au BufNewFile,BufRead *.lot,*.lotos		setf lotos
816
817" Lout (also: *.lt)
818au BufNewFile,BufRead *.lou,*.lout		setf lout
819
820" Lua
821au BufNewFile,BufRead *.lua			setf lua
822
823" Lynx style file (or LotusScript!)
824au BufNewFile,BufRead *.lss			setf lss
825
826" M4
827au BufNewFile,BufRead *.m4
828	\ if expand("<afile>") !~? 'html.m4$\|fvwm2rc' | setf m4 | endif
829
830" MaGic Point
831au BufNewFile,BufRead *.mgp			setf mgp
832
833" Mail (for Elm, trn, mutt, rn, slrn)
834au BufNewFile,BufRead snd.\d\+,.letter,.letter.\d\+,.followup,.article,.article.\d\+,pico.\d\+,mutt{ng,}-*-\w\+,mutt\w\{6\},ae\d\+.txt,/tmp/SLRN[0-9A-Z.]\+,*.eml setf mail
835
836" Mailcap configuration file
837au BufNewFile,BufRead .mailcap,mailcap		setf mailcap
838
839" Makefile
840au BufNewFile,BufRead *[mM]akefile,*.mk,*.mak,*.dsp setf make
841
842" MakeIndex
843au BufNewFile,BufRead *.ist,*.mst		setf ist
844
845" Manpage
846au BufNewFile,BufRead *.man			setf man
847
848" Man config
849au BufNewFile,BufRead /etc/man.conf		setf manconf
850
851" Maple V
852au BufNewFile,BufRead *.mv,*.mpl,*.mws		setf maple
853
854" Mason
855au BufNewFile,BufRead *.mason,*.mhtml		setf mason
856
857" Matlab or Objective C
858au BufNewFile,BufRead *.m			call s:FTm()
859
860fun! s:FTm()
861  let n = 1
862  while n < 10
863    let line = getline(n)
864    if line =~ '^\s*\(#\s*\(include\|import\)\>\|/\*\)'
865      setf objc
866      return
867    endif
868    if line =~ '^\s*%'
869      setf matlab
870      return
871    endif
872    if line =~ '^\s*(\*'
873      setf mma
874      return
875    endif
876    let n = n + 1
877  endwhile
878  if exists("g:filetype_m")
879    exe "setf " . g:filetype_m
880  else
881    setf matlab
882  endif
883endfun
884
885" Maya Extension Language
886au BufNewFile,BufRead *.mel			setf mel
887
888" Metafont
889au BufNewFile,BufRead *.mf			setf mf
890
891" MetaPost
892au BufNewFile,BufRead *.mp			setf mp
893
894" MGL
895au BufNewFile,BufRead *.mgl			setf mgl
896
897" MMIX or VMS makefile
898au BufNewFile,BufRead *.mms			call s:FTmms()
899
900fun! s:FTmms()
901  let n = 1
902  while n < 10
903    let line = getline(n)
904    if line =~ '^\s*\(%\|//\)' || line =~ '^\*'
905      setf mmix
906      return
907    endif
908    if line =~ '^\s*#'
909      setf make
910      return
911    endif
912    let n = n + 1
913  endwhile
914  setf mmix
915endfun
916
917
918" Modsim III (or LambdaProlog)
919au BufNewFile,BufRead *.mod
920	\ if getline(1) =~ '\<module\>' |
921	\   setf lprolog |
922	\ else |
923	\   setf modsim3 |
924	\ endif
925
926" Modula 2
927au BufNewFile,BufRead *.m2,*.DEF,*.MOD,*.md,*.mi setf modula2
928
929" Modula 3 (.m3, .i3, .mg, .ig)
930au BufNewFile,BufRead *.[mi][3g]		setf modula3
931
932" Monk
933au BufNewFile,BufRead *.isc,*.monk,*.ssc,*.tsc	setf monk
934
935" MOO
936au BufNewFile,BufRead *.moo			setf moo
937
938" Modconf
939au BufNewFile,BufRead /etc/modules.conf,/etc/conf.modules	setf modconf
940au BufNewFile,BufRead /etc/modutils/*
941	\ if executable(expand("<afile>")) != 1
942	\|  call s:StarSetf('modconf')
943	\|endif
944
945" Mplayer config
946au BufNewFile,BufRead mplayer.conf,*/.mplayer/config	setf mplayerconf
947
948" Moterola S record
949au BufNewFile,BufRead *.s19,*.s28,*.s37		setf srec
950
951" Msql
952au BufNewFile,BufRead *.msql			setf msql
953
954" Mysql
955au BufNewFile,BufRead *.mysql			setf mysql
956
957" M$ Resource files
958au BufNewFile,BufRead *.rc			setf rc
959
960" MuPAD source
961au BufRead,BufNewFile *.mu			setf mupad
962
963" Mush
964au BufNewFile,BufRead *.mush			setf mush
965
966" Mutt setup file
967au BufNewFile,BufRead Mutt{ng,}rc			setf muttrc
968au BufNewFile,BufRead .mutt{ng,}rc*,*/.mutt{ng,}/mutt{ng,}rc*	call s:StarSetf('muttrc')
969
970" Nano
971au BufNewFile,BufRead /etc/nanorc,.nanorc	setf nanorc
972
973" Nastran input/DMAP
974"au BufNewFile,BufRead *.dat			setf nastran
975
976" Natural
977au BufNewFile,BufRead *.NS[ACGLMNPS]		setf natural
978
979" Netrc
980au BufNewFile,BufRead .netrc			setf netrc
981
982" Novell netware batch files
983au BufNewFile,BufRead *.ncf			setf ncf
984
985" Nroff/Troff (*.ms and *.t are checked below)
986au BufNewFile,BufRead *.me
987	\ if expand("<afile>") != "read.me" && expand("<afile>") != "click.me" |
988	\   setf nroff |
989	\ endif
990au BufNewFile,BufRead *.tr,*.nr,*.roff,*.tmac,*.mom	setf nroff
991au BufNewFile,BufRead *.[1-9]			call s:FTnroff()
992
993" This function checks if one of the first five lines start with a dot.  In
994" that case it is probably an nroff file: 'filetype' is set and 1 is returned.
995fun! s:FTnroff()
996  if getline(1)[0] . getline(2)[0] . getline(3)[0] . getline(4)[0] . getline(5)[0] =~ '\.'
997    setf nroff
998    return 1
999  endif
1000  return 0
1001endfun
1002
1003" Nroff or Objective C++
1004au BufNewFile,BufRead *.mm			call s:FTmm()
1005
1006fun! s:FTmm()
1007  let n = 1
1008  while n < 10
1009    let line = getline(n)
1010    if line =~ '^\s*\(#\s*\(include\|import\)\>\|/\*\)'
1011      setf objcpp
1012      return
1013    endif
1014    let n = n + 1
1015  endwhile
1016  setf nroff
1017endfun
1018
1019" Not Quite C
1020au BufNewFile,BufRead *.nqc			setf nqc
1021
1022" NSIS
1023au BufNewFile,BufRead *.nsi			setf nsis
1024
1025" OCAML
1026au BufNewFile,BufRead *.ml,*.mli,*.mll,*.mly	setf ocaml
1027
1028" Occam
1029au BufNewFile,BufRead *.occ			setf occam
1030
1031" Omnimark
1032au BufNewFile,BufRead *.xom,*.xin		setf omnimark
1033
1034" OpenROAD
1035au BufNewFile,BufRead *.or			setf openroad
1036
1037" OPL
1038au BufNewFile,BufRead *.[Oo][Pp][Ll]		setf opl
1039
1040" Oracle config file
1041au BufNewFile,BufRead *.ora			setf ora
1042
1043" Packet filter conf
1044au BufNewFile,BufRead pf.conf			setf pf
1045
1046" Pam conf
1047au BufNewFile,BufRead /etc/pam.conf		setf pamconf
1048
1049" PApp
1050au BufNewFile,BufRead *.papp,*.pxml,*.pxsl	setf papp
1051
1052" Password file
1053au BufNewFile,BufRead /etc/passwd,/etc/shadow,/etc/shadow- setf passwd
1054
1055" Pascal (also *.p)
1056au BufNewFile,BufRead *.pas			setf pascal
1057
1058" Delphi project file
1059au BufNewFile,BufRead *.dpr			setf pascal
1060
1061" Perl
1062if has("fname_case")
1063  au BufNewFile,BufRead *.pl,*.PL		call s:FTpl()
1064else
1065  au BufNewFile,BufRead *.pl			call s:FTpl()
1066endif
1067au BufNewFile,BufRead *.plx			setf perl
1068
1069fun! s:FTpl()
1070  if exists("g:filetype_pl")
1071    exe "setf " . g:filetype_pl
1072  else
1073    " recognize Prolog by specific text in the first non-empty line
1074    " require a blank after the '%' because Perl uses "%list" and "%translate"
1075    let l = getline(nextnonblank(1))
1076    if l =~ '\<prolog\>' || l =~ '^\s*\(%\+\(\s\|$\)\|/\*\)' || l =~ ':-'
1077      setf prolog
1078    else
1079      setf perl
1080    endif
1081  endif
1082endfun
1083
1084" Perl, XPM or XPM2
1085au BufNewFile,BufRead *.pm
1086	\ if getline(1) =~ "XPM2" |
1087	\   setf xpm2 |
1088	\ elseif getline(1) =~ "XPM" |
1089	\   setf xpm |
1090	\ else |
1091	\   setf perl |
1092	\ endif
1093
1094" Perl POD
1095au BufNewFile,BufRead *.pod			setf pod
1096
1097" Php3
1098au BufNewFile,BufRead *.php,*.php3		setf php
1099
1100" Phtml
1101au BufNewFile,BufRead *.phtml			setf phtml
1102
1103" Pike
1104au BufNewFile,BufRead *.pike,*.lpc,*.ulpc,*.pmod setf pike
1105
1106" Pinfo config
1107au BufNewFile,BufRead */etc/pinforc,*/.pinforc	setf pinfo
1108
1109" Palm Resource compiler
1110au BufNewFile,BufRead *.rcp			setf pilrc
1111
1112" Pine config
1113au BufNewFile,BufRead .pinerc,pinerc,.pinercex,pinercex		setf pine
1114
1115" PL/M (also: *.inp)
1116au BufNewFile,BufRead *.plm,*.p36,*.pac		setf plm
1117
1118" PL/SQL
1119au BufNewFile,BufRead *.pls,*.plsql		setf plsql
1120
1121" PLP
1122au BufNewFile,BufRead *.plp			setf plp
1123
1124" PO and PO template (GNU gettext)
1125au BufNewFile,BufRead *.po,*.pot		setf po
1126
1127" Postfix main config
1128au BufNewFile,BufRead main.cf			setf pfmain
1129
1130" PostScript (+ font files, encapsulated PostScript, Adobe Illustrator)
1131au BufNewFile,BufRead *.ps,*.pfa,*.afm,*.eps,*.epsf,*.epsi,*.ai	  setf postscr
1132
1133" PostScript Printer Description
1134au BufNewFile,BufRead *.ppd			setf ppd
1135
1136" Povray
1137au BufNewFile,BufRead *.pov			setf pov
1138
1139" Povray configuration
1140au BufNewFile,BufRead .povrayrc			setf povini
1141
1142" Povray, PHP or assembly
1143au BufNewFile,BufRead *.inc			call s:FTinc()
1144
1145fun! s:FTinc()
1146  if exists("g:filetype_inc")
1147    exe "setf " . g:filetype_inc
1148  else
1149    let lines = getline(1).getline(2).getline(3)
1150    if lines =~? "perlscript"
1151      setf aspperl
1152    elseif lines =~ "<%"
1153      setf aspvbs
1154    elseif lines =~ "<?"
1155      setf php
1156    else
1157      call s:FTasmsyntax()
1158      if exists("b:asmsyntax")
1159	exe "setf " . b:asmsyntax
1160      else
1161	setf pov
1162      endif
1163    endif
1164  endif
1165endfun
1166
1167" Printcap and Termcap
1168au BufNewFile,BufRead *printcap
1169	\ let b:ptcap_type = "print" | setf ptcap
1170au BufNewFile,BufRead *termcap
1171	\ let b:ptcap_type = "term" | setf ptcap
1172
1173" PCCTS / ANTRL
1174"au BufNewFile,BufRead *.g			setf antrl
1175au BufNewFile,BufRead *.g			setf pccts
1176
1177" PPWizard
1178au BufNewFile,BufRead *.it,*.ih			setf ppwiz
1179
1180" Oracle Pro*C/C++
1181au BufNewFile,BufRead .pc			setf proc
1182
1183" Procmail
1184au BufNewFile,BufRead .procmail,.procmailrc	setf procmail
1185
1186" Progress or CWEB
1187au BufNewFile,BufRead *.w			call s:FTprogress_cweb()
1188
1189function! s:FTprogress_cweb()
1190  if exists("g:filetype_w")
1191    exe "setf " . g:filetype_w
1192    return
1193  endif
1194  if getline(1) =~ '&ANALYZE' || getline(3) =~ '&GLOBAL-DEFINE'
1195    setf progress
1196  else
1197    setf cweb
1198  endif
1199endfun
1200
1201" Progress or assembly
1202au BufNewFile,BufRead *.i			call s:FTprogress_asm()
1203
1204function! s:FTprogress_asm()
1205  if exists("g:filetype_i")
1206    exe "setf " . g:filetype_i
1207    return
1208  endif
1209  " This function checks for an assembly comment the first ten lines.
1210  " If not found, assume Progress.
1211  let lnum = 1
1212  while lnum <= 10 && lnum < line('$')
1213    let line = getline(lnum)
1214    if line =~ '^\s*;' || line =~ '^\*'
1215      call s:FTasm()
1216      return
1217    elseif line !~ '^\s*$' || line =~ '^/\*'
1218      " Not an empty line: Doesn't look like valid assembly code.
1219      " Or it looks like a Progress /* comment
1220      break
1221    endif
1222    let lnum = lnum + 1
1223  endw
1224  setf progress
1225endfun
1226
1227" Progress or Pascal
1228au BufNewFile,BufRead *.p			call s:FTprogress_pascal()
1229
1230function! s:FTprogress_pascal()
1231  if exists("g:filetype_p")
1232    exe "setf " . g:filetype_p
1233    return
1234  endif
1235  " This function checks for valid Pascal syntax in the first ten lines.
1236  " Look for either an opening comment or a program start.
1237  " If not found, assume Progress.
1238  let lnum = 1
1239  while lnum <= 10 && lnum < line('$')
1240    let line = getline(lnum)
1241    if line =~ '^\s*\(program\|unit\|procedure\|function\|const\|type\|var\)\>'
1242	\ || line =~ '^\s*{' || line =~ '^\s*(\*'
1243      setf pascal
1244      return
1245    elseif line !~ '^\s*$' || line =~ '^/\*'
1246      " Not an empty line: Doesn't look like valid Pascal code.
1247      " Or it looks like a Progress /* comment
1248      break
1249    endif
1250    let lnum = lnum + 1
1251  endw
1252  setf progress
1253endfun
1254
1255
1256" Software Distributor Product Specification File (POSIX 1387.2-1995)
1257au BufNewFile,BufRead *.psf			setf psf
1258au BufNewFile,BufRead INDEX,INFO
1259	\ if getline(1) =~ '^\s*\(distribution\|installed_software\|root\|bundle\|product\)\s*$' |
1260	\   setf psf |
1261	\ endif
1262
1263" Prolog
1264au BufNewFile,BufRead *.pdb			setf prolog
1265
1266" Protocols
1267au BufNewFile,BufRead /etc/protocols		setf protocols
1268
1269" Pyrex
1270au BufNewFile,BufRead *.pyx,*.pxd		setf pyrex
1271
1272" Python
1273au BufNewFile,BufRead *.py,*.pyw		setf python
1274
1275" Radiance
1276au BufNewFile,BufRead *.rad,*.mat		setf radiance
1277
1278" Ratpoison config/command files
1279au BufNewFile,BufRead .ratpoisonrc,ratpoisonrc	setf ratpoison
1280
1281" RCS file
1282au BufNewFile,BufRead *\,v			setf rcs
1283
1284" Readline
1285au BufNewFile,BufRead .inputrc,inputrc		setf readline
1286
1287" Registry for MS-Windows
1288au BufNewFile,BufRead *.reg
1289	\ if getline(1) =~? '^REGEDIT[0-9]*\s*$\|^Windows Registry Editor Version \d*\.\d*\s*$' | setf registry | endif
1290
1291" Renderman Interface Bytestream
1292au BufNewFile,BufRead *.rib			setf rib
1293
1294" Rexx
1295au BufNewFile,BufRead *.rexx,*.rex		setf rexx
1296
1297" R (Splus)
1298au BufNewFile,BufRead *.s,*.S			setf r
1299
1300" R Help file
1301au BufNewFile,BufRead *.rd,*.Rd			setf rhelp
1302
1303" Rexx, Rebol or R
1304au BufNewFile,BufRead *.r,*.R			call s:FTr()
1305
1306fun! s:FTr()
1307  if getline(1) =~ '^REBOL'
1308    setf rebol
1309  else
1310    let n = 1
1311    let max = line("$")
1312    if max > 50
1313      let max = 50
1314    endif
1315    while n < max
1316      " R has # comments
1317      if getline(n) =~ '^\s*#'
1318	setf r
1319	break
1320      endif
1321      " Rexx has /* comments */
1322      if getline(n) =~ '^\s*/\*'
1323	setf rexx
1324	break
1325      endif
1326      let n = n + 1
1327    endwhile
1328    if n >= max
1329      setf rexx
1330    endif
1331  endif
1332endfun
1333
1334" Remind
1335au BufNewFile,BufRead .reminders*		call s:StarSetf('remind')
1336
1337" Resolv.conf
1338au BufNewFile,BufRead resolv.conf		setf resolv
1339
1340" Relax NG Compact
1341au BufNewFile,BufRead *.rnc			setf rnc
1342
1343" RPL/2
1344au BufNewFile,BufRead *.rpl			setf rpl
1345
1346" Robots.txt
1347au BufNewFile,BufRead robots.txt		setf robots
1348
1349" Rpcgen
1350au BufNewFile,BufRead *.x			setf rpcgen
1351
1352" reStructuredText Documentation Format
1353au BufNewFile,BufRead *.rst			setf rst
1354
1355" RTF
1356au BufNewFile,BufRead *.rtf			setf rtf
1357
1358" Ruby
1359au BufNewFile,BufRead *.rb,*.rbw,*.gem,*.gemspec	setf ruby
1360
1361" Rantfile is like Ruby
1362au BufNewFile,BufRead [rR]antfile,*.rant	setf ruby
1363
1364" S-lang (or shader language!)
1365au BufNewFile,BufRead *.sl			setf slang
1366
1367" Samba config
1368au BufNewFile,BufRead smb.conf			setf samba
1369
1370" SAS script
1371au BufNewFile,BufRead *.sas			setf sas
1372
1373" Sather
1374au BufNewFile,BufRead *.sa			setf sather
1375
1376" Scilab
1377au BufNewFile,BufRead *.sci			setf scilab
1378
1379" SDL
1380au BufNewFile,BufRead *.sdl,*.pr		setf sdl
1381
1382" sed
1383au BufNewFile,BufRead *.sed			setf sed
1384
1385" Sieve (RFC 3028)
1386au BufNewFile,BufRead *.siv			setf sieve
1387
1388" Sendmail
1389au BufNewFile,BufRead sendmail.cf		setf sm
1390
1391" Sendmail .mc files are actually m4
1392au BufNewFile,BufRead *.mc			setf m4
1393
1394" Services
1395au BufNewFile,BufRead /etc/services		setf services
1396
1397" Service Location config
1398au BufNewFile,BufRead /etc/slp.conf		setf slpconf
1399
1400" Service Location registration
1401au BufNewFile,BufRead /etc/slp.reg		setf slpreg
1402
1403" Service Location SPI
1404au BufNewFile,BufRead /etc/slp.spi		setf slpspi
1405
1406" Setserial config
1407au BufNewFile,BufRead /etc/serial.conf		setf setserial
1408
1409" SGML
1410au BufNewFile,BufRead *.sgm,*.sgml
1411	\ if getline(1).getline(2).getline(3).getline(4).getline(5) =~? 'linuxdoc' |
1412	\   setf sgmllnx |
1413	\ elseif getline(1) =~ '<!DOCTYPE.*DocBook' || getline(2) =~ '<!DOCTYPE.*DocBook' |
1414	\   let b:docbk_type="sgml" |
1415	\   setf docbk |
1416	\ else |
1417	\   setf sgml |
1418	\ endif
1419
1420" SGMLDECL
1421au BufNewFile,BufRead *.decl,*.dcl,*.dec
1422	\ if getline(1).getline(2).getline(3) =~? '^<!SGML' |
1423	\    setf sgmldecl |
1424	\ endif
1425
1426" SGML catalog file
1427au BufNewFile,BufRead catalog			setf catalog
1428au BufNewFile,BufRead sgml.catalog*		call s:StarSetf('catalog')
1429
1430" Shell scripts (sh, ksh, bash, bash2, csh); Allow .profile_foo etc.
1431" Gentoo ebuilds are actually bash scripts
1432au BufNewFile,BufRead .bashrc*,bashrc,bash.bashrc,.bash_profile*,.bash_logout*,*.bash,*.ebuild call SetFileTypeSH("bash")
1433au BufNewFile,BufRead .kshrc*,*.ksh call SetFileTypeSH("ksh")
1434au BufNewFile,BufRead /etc/profile,.profile*,*.sh,*.env call SetFileTypeSH(getline(1))
1435
1436" Also called from scripts.vim.
1437fun! SetFileTypeSH(name)
1438  if expand("<amatch>") =~ g:ft_ignore_pat
1439    return
1440  endif
1441  if a:name =~ '\<ksh\>'
1442    let b:is_kornshell = 1
1443    if exists("b:is_bash")
1444      unlet b:is_bash
1445    endif
1446    if exists("b:is_sh")
1447      unlet b:is_sh
1448    endif
1449  elseif exists("g:bash_is_sh") || a:name =~ '\<bash\>' || a:name =~ '\<bash2\>'
1450    let b:is_bash = 1
1451    if exists("b:is_kornshell")
1452      unlet b:is_kornshell
1453    endif
1454    if exists("b:is_sh")
1455      unlet b:is_sh
1456    endif
1457  elseif a:name =~ '\<sh\>'
1458    let b:is_sh = 1
1459    if exists("b:is_kornshell")
1460      unlet b:is_kornshell
1461    endif
1462    if exists("b:is_bash")
1463      unlet b:is_bash
1464    endif
1465  endif
1466  call SetFileTypeShell("sh")
1467endfun
1468
1469" For shell-like file types, check for an "exec" command hidden in a comment,
1470" as used for Tcl.
1471" Also called from scripts.vim, thus can't be local to this script.
1472fun! SetFileTypeShell(name)
1473  if expand("<amatch>") =~ g:ft_ignore_pat
1474    return
1475  endif
1476  let l = 2
1477  while l < 20 && l < line("$") && getline(l) =~ '^\s*\(#\|$\)'
1478    " Skip empty and comment lines.
1479    let l = l + 1
1480  endwhile
1481  if l < line("$") && getline(l) =~ '\s*exec\s' && getline(l - 1) =~ '^\s*#.*\\$'
1482    " Found an "exec" line after a comment with continuation
1483    let n = substitute(getline(l),'\s*exec\s\+\([^ ]*/\)\=', '', '')
1484    if n =~ '\<tclsh\|\<wish'
1485      setf tcl
1486      return
1487    endif
1488  endif
1489  exe "setf " . a:name
1490endfun
1491
1492" tcsh scripts
1493au BufNewFile,BufRead .tcshrc*,*.tcsh,tcsh.tcshrc,tcsh.login	call SetFileTypeShell("tcsh")
1494
1495" csh scripts, but might also be tcsh scripts (on some systems csh is tcsh)
1496au BufNewFile,BufRead .login*,.cshrc*,csh.cshrc,csh.login,csh.logout,*.csh,.alias  call s:CSH()
1497
1498fun! s:CSH()
1499  if exists("g:filetype_csh")
1500    call SetFileTypeShell(g:filetype_csh)
1501  elseif &shell =~ "tcsh"
1502    call SetFileTypeShell("tcsh")
1503  else
1504    call SetFileTypeShell("csh")
1505  endif
1506endfun
1507
1508" Z-Shell script
1509au BufNewFile,BufRead .zprofile,/etc/zprofile,.zfbfmarks  setf zsh
1510au BufNewFile,BufRead .zsh*,.zlog*,.zcompdump*  call s:StarSetf('zsh')
1511
1512" Scheme
1513au BufNewFile,BufRead *.scm,*.ss		setf scheme
1514
1515" Screen RC
1516au BufNewFile,BufRead .screenrc,screenrc	setf screen
1517
1518" Simula
1519au BufNewFile,BufRead *.sim			setf simula
1520
1521" SINDA
1522au BufNewFile,BufRead *.sin,*.s85		setf sinda
1523
1524" SKILL
1525au BufNewFile,BufRead *.il,*.ils,*.cdf		setf skill
1526
1527" SLRN
1528au BufNewFile,BufRead .slrnrc			setf slrnrc
1529au BufNewFile,BufRead *.score			setf slrnsc
1530
1531" Smalltalk (and TeX)
1532au BufNewFile,BufRead *.st			setf st
1533au BufNewFile,BufRead *.cls
1534	\ if getline(1) =~ '^%' |
1535	\  setf tex |
1536	\ else |
1537	\  setf st |
1538	\ endif
1539
1540" Smarty templates
1541au BufNewFile,BufRead *.tpl			setf smarty
1542
1543" SMIL or XML
1544au BufNewFile,BufRead *.smil
1545	\ if getline(1) =~ '<?\s*xml.*?>' |
1546	\   setf xml |
1547	\ else |
1548	\   setf smil |
1549	\ endif
1550
1551" SMIL or SNMP MIB file
1552au BufNewFile,BufRead *.smi
1553	\ if getline(1) =~ '\<smil\>' |
1554	\   setf smil |
1555	\ else |
1556	\   setf mib |
1557	\ endif
1558
1559" SMITH
1560au BufNewFile,BufRead *.smt,*.smith		setf smith
1561
1562" Snobol4
1563au BufNewFile,BufRead *.sno			setf snobol4
1564
1565" SNMP MIB files
1566au BufNewFile,BufRead *.mib,*.my		setf mib
1567
1568" Snort Configuration
1569au BufNewFile,BufRead *.hog,snort.conf,vision.conf,*.rules	setf hog
1570
1571" Spec (Linux RPM)
1572au BufNewFile,BufRead *.spec			setf spec
1573
1574" Speedup (AspenTech plant simulator)
1575au BufNewFile,BufRead *.speedup,*.spdata,*.spd	setf spup
1576
1577" Slice
1578au BufNewFile,BufRead *.ice			setf slice
1579
1580" Spice
1581au BufNewFile,BufRead *.sp,*.spice		setf spice
1582
1583" Spyce
1584au BufNewFile,BufRead *.spy,*.spi		setf spyce
1585
1586" Squid
1587au BufNewFile,BufRead squid.conf		setf squid
1588
1589" SQL for Oracle Designer
1590au BufNewFile,BufRead *.tyb,*.typ,*.tyc,*.pkb,*.pks	setf sql
1591
1592" SQL
1593au BufNewFile,BufRead *.sql			call s:SQL()
1594
1595fun! s:SQL()
1596  if exists("g:filetype_sql")
1597    exe "setf " . g:filetype_sql
1598  else
1599    setf sql
1600  endif
1601endfun
1602
1603" SQLJ
1604au BufNewFile,BufRead *.sqlj			setf sqlj
1605
1606" SQR
1607au BufNewFile,BufRead *.sqr,*.sqi		setf sqr
1608
1609" OpenSSH configuration
1610au BufNewFile,BufRead ssh_config,*/.ssh/config	setf sshconfig
1611
1612" OpenSSH server configuration
1613au BufNewFile,BufRead sshd_config		setf sshdconfig
1614
1615" Stored Procedures
1616au BufNewFile,BufRead *.stp			setf stp
1617
1618" Standard ML
1619au BufNewFile,BufRead *.sml			setf sml
1620
1621" Sysctl
1622au BufNewFile,BufRead /etc/sysctl.conf		setf sysctl
1623
1624" Sudoers
1625au BufNewFile,BufRead /etc/sudoers,sudoers.tmp	setf sudoers
1626
1627" If the first line starts with '#' and contains 'perl' it's probably a Perl
1628" file.
1629fun! s:FTperl()
1630  if getline(1)[0] == '#' && getline(1) =~ 'perl'
1631    setf perl
1632    return 1
1633  endif
1634  return 0
1635endfun
1636
1637" Tads (or Nroff or Perl test file)
1638au BufNewFile,BufRead *.t
1639	\ if !s:FTnroff() && !s:FTperl() | setf tads | endif
1640
1641" Tags
1642au BufNewFile,BufRead tags			setf tags
1643
1644" TAK
1645au BufNewFile,BufRead *.tak			setf tak
1646
1647" Tcl (JACL too)
1648au BufNewFile,BufRead *.tcl,*.tk,*.itcl,*.itk,*.jacl	setf tcl
1649
1650" TealInfo
1651au BufNewFile,BufRead *.tli			setf tli
1652
1653" Telix Salt
1654au BufNewFile,BufRead *.slt			setf tsalt
1655
1656" Terminfo
1657au BufNewFile,BufRead *.ti			setf terminfo
1658
1659" TeX
1660au BufNewFile,BufRead *.latex,*.sty,*.dtx,*.ltx,*.bbl	setf tex
1661au BufNewFile,BufRead *.tex			call s:FTtex()
1662
1663fun! s:FTtex()
1664  let lnum = 1
1665  let checked = 0
1666  while checked < 25 && lnum < line("$")
1667    let line = getline(lnum)
1668    if line !~ '^\s*%'
1669      if line =~ '^\s*\\\%(documentclass\>\|usepackage\>\|begin{\|newcommand\>\|renewcommand\>\)'
1670	setf tex
1671	return
1672      elseif line =~ '^\s*\\\%(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\)\>'
1673	setf context
1674	return
1675      endif
1676      let checked = checked + 1
1677    endif
1678    let lnum = lnum + 1
1679  endwhile
1680
1681  " Didn't recognize anything, guess.
1682  if exists("g:tex_flavour") && g:tex_flavour == "context"
1683    setf context
1684  else
1685    setf tex
1686  endif
1687endfun
1688
1689" Context
1690au BufNewFile,BufRead tex/context/*/*.tex	setf context
1691
1692" Texinfo
1693au BufNewFile,BufRead *.texinfo,*.texi,*.txi	setf texinfo
1694
1695" TeX configuration
1696au BufNewFile,BufRead texmf.cnf			setf texmf
1697
1698" Tidy config
1699au BufNewFile,BufRead .tidyrc,tidyrc		setf tidy
1700
1701" TF mud client
1702au BufNewFile,BufRead *.tf,.tfrc,tfrc		setf tf
1703
1704" TPP - Text Presentation Program
1705au BufNewFile,BufReadPost *.tpp			setf tpp
1706
1707" Trustees
1708au BufNewFile,BufRead trustees.conf		setf trustees
1709
1710" TSS - Geometry
1711au BufNewFile,BufReadPost *.tssgm		setf tssgm
1712
1713" TSS - Optics
1714au BufNewFile,BufReadPost *.tssop		setf tssop
1715
1716" TSS - Command Line (temporary)
1717au BufNewFile,BufReadPost *.tsscl		setf tsscl
1718
1719" Motif UIT/UIL files
1720au BufNewFile,BufRead *.uit,*.uil		setf uil
1721
1722" Udev conf
1723au BufNewFile,BufRead /etc/udev/udev.conf	setf udevconf
1724
1725" Udev rules
1726au BufNewFile,BufRead /etc/udev/rules.d/*.rules setf udevrules
1727
1728" Udev permissions
1729au BufNewFile,BufRead /etc/udev/permissions.d/*.permissions setf udevperm
1730"
1731" Udev symlinks config
1732au BufNewFile,BufRead /etc/udev/cdsymlinks.conf	setf sh
1733
1734" UnrealScript
1735au BufNewFile,BufRead *.uc			setf uc
1736
1737" Updatedb
1738au BufNewFile,BufRead /etc/updatedb.conf	setf updatedb
1739
1740" Verilog HDL
1741au BufNewFile,BufRead *.v			setf verilog
1742
1743" Verilog-AMS HDL
1744au BufNewFile,BufRead *.va,*.vams		setf verilogams
1745
1746" VHDL
1747au BufNewFile,BufRead *.hdl,*.vhd,*.vhdl,*.vbe,*.vst  setf vhdl
1748au BufNewFile,BufRead *.vhdl_[0-9]*		call s:StarSetf('vhdl')
1749
1750" Vim script
1751au BufNewFile,BufRead *.vim,.exrc,_exrc		setf vim
1752
1753" Viminfo file
1754au BufNewFile,BufRead .viminfo,_viminfo		setf viminfo
1755
1756" Virata Config Script File
1757au BufRead,BufNewFile *.hw,*.module,*.pkg	setf virata
1758
1759" Visual Basic (also uses *.bas) or FORM
1760au BufNewFile,BufRead *.frm			call s:FTVB("form")
1761
1762" SaxBasic is close to Visual Basic
1763au BufNewFile,BufRead *.sba			setf vb
1764
1765" Vgrindefs file
1766au BufNewFile,BufRead vgrindefs			setf vgrindefs
1767
1768" VRML V1.0c
1769au BufNewFile,BufRead *.wrl			setf vrml
1770
1771" Webmacro
1772au BufNewFile,BufRead *.wm			setf webmacro
1773
1774" Wget config
1775au BufNewFile,BufRead .wgetrc,wgetrc		setf wget
1776
1777" Website MetaLanguage
1778au BufNewFile,BufRead *.wml			setf wml
1779
1780" Winbatch
1781au BufNewFile,BufRead *.wbt			setf winbatch
1782
1783" WvDial
1784au BufNewFile,BufRead wvdial.conf,.wvdialrc	setf wvdial
1785
1786" CVS RC file
1787au BufNewFile,BufRead .cvsrc			setf cvsrc
1788
1789" CVS commit file
1790au BufNewFile,BufRead cvs\d\+			setf cvs
1791
1792" WEB (*.web is also used for Winbatch: Guess, based on expecting "%" comment
1793" lines in a WEB file).
1794au BufNewFile,BufRead *.web
1795	\ if getline(1)[0].getline(2)[0].getline(3)[0].getline(4)[0].getline(5)[0] =~ "%" |
1796	\   setf web |
1797	\ else |
1798	\   setf winbatch |
1799	\ endif
1800
1801" Windows Scripting Host and Windows Script Component
1802au BufNewFile,BufRead *.ws[fc]			setf wsh
1803
1804" X Pixmap (dynamically sets colors, use BufEnter to make it work better)
1805au BufEnter *.xpm
1806	\ if getline(1) =~ "XPM2" |
1807	\   setf xpm2 |
1808	\ else |
1809	\   setf xpm |
1810	\ endif
1811au BufEnter *.xpm2				setf xpm2
1812
1813" XFree86 config
1814au BufNewFile,BufRead XF86Config
1815	\ if getline(1) =~ '\<XConfigurator\>' |
1816	\   let b:xf86c_xfree86_version = 3 |
1817	\ endif |
1818	\ setf xf86conf
1819
1820" Xorg config
1821au BufNewFile,BufRead xorg.conf,xorg.conf-4	let b:xf86c_xfree86_version = 4 | setf xf86conf
1822
1823" Xinetd conf
1824au BufNewFile,BufRead /etc/xinetd.conf		setf xinetd
1825
1826" XS Perl extension interface language
1827au BufNewFile,BufRead *.xs			setf xs
1828
1829" X resources file
1830au BufNewFile,BufRead .Xdefaults,.Xpdefaults,.Xresources,xdm-config,*.ad setf xdefaults
1831
1832" Xmath
1833au BufNewFile,BufRead *.msc,*.msf		setf xmath
1834au BufNewFile,BufRead *.ms
1835	\ if !s:FTnroff() | setf xmath | endif
1836
1837" XML
1838au BufNewFile,BufRead *.xml
1839	\ if getline(1) . getline(2) . getline(3) =~ '<!DOCTYPE.*DocBook' |
1840	\   let b:docbk_type="xml" |
1841	\   setf docbk |
1842	\ else |
1843	\   setf xml |
1844	\ endif
1845
1846" XMI (holding UML models) is also XML
1847au BufNewFile,BufRead *.xmi			setf xml
1848
1849" CSPROJ files are Visual Studio.NET's XML-based project config files
1850au BufNewFile,BufRead *.csproj,*.csproj.user	setf xml
1851
1852" Qt Linguist translation source and Qt User Interface Files are XML
1853au BufNewFile,BufRead *.ts,*.ui			setf xml
1854
1855" Xdg menus
1856au BufNewFile,BufRead /etc/xdg/menus/*.menu	setf xml
1857
1858" Xquery
1859au BufNewFile,BufRead *.xq,*.xql,*.xqm,*.xquery,*.xqy	setf xquery
1860
1861" XSD
1862au BufNewFile,BufRead *.xsd			setf xsd
1863
1864" Xslt
1865au BufNewFile,BufRead *.xsl,*.xslt		setf xslt
1866
1867" Yacc
1868au BufNewFile,BufRead *.yy			setf yacc
1869
1870" Yacc or racc
1871au BufNewFile,BufRead *.y			call s:FTy()
1872
1873fun! s:FTy()
1874  let n = 1
1875  while n < 100 && n < line("$")
1876    let line = getline(n)
1877    if line =~ '^\s*%'
1878      setf yacc
1879      return
1880    endif
1881    if getline(n) =~ '^\s*\(#\|class\>\)' && getline(n) !~ '^\s*#\s*include'
1882      setf racc
1883      return
1884    endif
1885    let n = n + 1
1886  endwhile
1887  setf yacc
1888endfun
1889
1890
1891" Yaml
1892au BufNewFile,BufRead *.yaml,*.yml		setf yaml
1893
1894" Z80 assembler asz80
1895au BufNewFile,BufRead *.z8a			setf z8a
1896
1897augroup END
1898
1899
1900" Source the user-specified filetype file, for backwards compatibility with
1901" Vim 5.x.
1902if exists("myfiletypefile") && filereadable(expand(myfiletypefile))
1903  execute "source " . myfiletypefile
1904endif
1905
1906
1907" Check for "*" after loading myfiletypefile, so that scripts.vim is only used
1908" when there are no matching file name extensions.
1909" Don't do this for compressed files.
1910augroup filetypedetect
1911au BufNewFile,BufRead *
1912	\ if !did_filetype() && expand("<amatch>") !~ g:ft_ignore_pat
1913	\ | runtime! scripts.vim | endif
1914au StdinReadPost * if !did_filetype() | runtime! scripts.vim | endif
1915
1916
1917" Extra checks for when no filetype has been detected now.  Mostly used for
1918" patterns that end in "*".  E.g., "zsh*" matches "zsh.vim", but that's a Vim
1919" script file.
1920" Most of these should call s:StarSetf() to avoid names ending in .gz and the
1921" like are used.
1922
1923" Asterisk config file
1924au BufNewFile,BufRead *asterisk/*.conf*         call s:StarSetf('asterisk')
1925
1926" BIND zone
1927au BufNewFile,BufRead /var/named/*		call s:StarSetf('bindzone')
1928
1929" Changelog
1930au BufNewFile,BufRead [cC]hange[lL]og*
1931	\ if getline(1) =~ '; urgency='
1932	\|  call s:StarSetf('debchangelog')
1933	\|else
1934	\|  call s:StarSetf('changelog')
1935	\|endif
1936
1937" Crontab
1938au BufNewFile,BufRead crontab,crontab.*		call s:StarSetf('crontab')
1939
1940" Dracula
1941au BufNewFile,BufRead drac.*			call s:StarSetf('dracula')
1942
1943" Fvwm
1944au BufNewFile,BufRead *fvwmrc*,*fvwm95*.hook
1945	\ let b:fvwm_version = 1 | call s:StarSetf('fvwm')
1946au BufNewFile,BufRead *fvwm2rc*
1947	\ if expand("<afile>:e") == "m4"
1948	\|  call s:StarSetf('fvwm2m4')
1949	\|else
1950	\|  let b:fvwm_version = 2 | call s:StarSetf('fvwm')
1951	\|endif
1952
1953" GTK RC
1954au BufNewFile,BufRead .gtkrc*,gtkrc*		call s:StarSetf('gtkrc')
1955
1956" Jam
1957au BufNewFile,BufRead Prl*.*,JAM*.*		call s:StarSetf('jam')
1958
1959" Jargon
1960au! BufNewFile,BufRead *jarg*
1961	\ if getline(1).getline(2).getline(3).getline(4).getline(5) =~? 'THIS IS THE JARGON FILE'
1962	\|  call s:StarSetf('jargon')
1963	\|endif
1964
1965" Makefile
1966au BufNewFile,BufRead [mM]akefile*		call s:StarSetf('make')
1967
1968" Modconf
1969au BufNewFile,BufRead /etc/modprobe.*		call s:StarSetf('modconf')
1970
1971" Ruby Makefile
1972au BufNewFile,BufRead [rR]akefile*		call s:StarSetf('ruby')
1973
1974" Mutt setup file
1975au BufNewFile,BufRead mutt{ng,}rc*,Mutt{ng,}rc*		call s:StarSetf('muttrc')
1976
1977" Nroff macros
1978au BufNewFile,BufRead tmac.*			call s:StarSetf('nroff')
1979
1980" Pam conf
1981au BufNewFile,BufRead /etc/pam.d/*		call s:StarSetf('pamconf')
1982
1983" Printcap and Termcap
1984au BufNewFile,BufRead *printcap*
1985	\ if !did_filetype()
1986	\|  let b:ptcap_type = "print" | call s:StarSetf('ptcap')
1987	\|endif
1988au BufNewFile,BufRead *termcap*
1989	\ if !did_filetype()
1990	\|  let b:ptcap_type = "term" | call s:StarSetf('ptcap')
1991	\|endif
1992
1993" Vim script
1994au BufNewFile,BufRead *vimrc*			call s:StarSetf('vim')
1995
1996" Subversion commit file
1997au BufNewFile,BufRead svn-commit*.tmp		setf svn
1998
1999" X resources file
2000au BufNewFile,BufRead Xresources*,*/app-defaults/*,*/Xresources/* call s:StarSetf('xdefaults')
2001
2002" XFree86 config
2003au BufNewFile,BufRead XF86Config-4*
2004	\ let b:xf86c_xfree86_version = 4 | call s:StarSetf('xf86conf')
2005au BufNewFile,BufRead XF86Config*
2006	\ if getline(1) =~ '\<XConfigurator\>'
2007	\|  let b:xf86c_xfree86_version = 3
2008	\|endif
2009	\|call s:StarSetf('xf86conf')
2010
2011" X11 xmodmap
2012au BufNewFile,BufRead *xmodmap*			call s:StarSetf('xmodmap')
2013
2014" Xinetd conf
2015au BufNewFile,BufRead /etc/xinetd.d/*		call s:StarSetf('xinetd')
2016
2017" Z-Shell script
2018au BufNewFile,BufRead zsh*,zlog*		call s:StarSetf('zsh')
2019
2020
2021" Generic configuration file (check this last, it's just guessing!)
2022au BufNewFile,BufRead,StdinReadPost *
2023	\ if !did_filetype() && expand("<amatch>") !~ g:ft_ignore_pat
2024	\    && (getline(1) =~ '^#' || getline(2) =~ '^#' || getline(3) =~ '^#'
2025	\	|| getline(4) =~ '^#' || getline(5) =~ '^#') |
2026	\   setf conf |
2027	\ endif
2028
2029" Use the plugin-filetype checks last, they may overrule any of the previously
2030" detected filetypes.
2031runtime! ftdetect/*.vim
2032
2033augroup END
2034
2035
2036" If the GUI is already running, may still need to install the Syntax menu.
2037" Don't do it when the 'M' flag is included in 'guioptions'.
2038if has("menu") && has("gui_running")
2039      \ && !exists("did_install_syntax_menu") && &guioptions !~# "M"
2040  source <sfile>:p:h/menu.vim
2041endif
2042
2043" Restore 'cpoptions'
2044let &cpo = s:cpo_save
2045unlet s:cpo_save
2046