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