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