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