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