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