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