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