More generic code.
[~madcoder/dotfiles.git] / vim / filetype.vim
1 if exists("did_load_filetypes")
2   finish
3 endif
4
5 augroup filetypedetect
6   au BufRead,BufNewFile *.JS               setf javascript
7   au BufRead,BufNewFile *.jas              setf asm
8   au BufRead,BufNewFile *.swfml            setf xml
9   au BufRead,BufNewFile *.hx               setf haxe
10
11   au BufRead,BufNewFile *.tpl              setf xhtml
12
13   au BufRead,BufNewFile massif.*.txt       setf massif
14
15   " HTML (.shtml and .stm for server side)
16   au BufNewFile,BufRead *.html,*.htm,*.shtml,*.stm  call s:FThtml()
17
18   au BufNewFile,BufRead {mad,}mutt{ng,}-*-\w\+ setf mail
19
20   au BufNewFile,BufRead */X11/xkb/* setf xkb
21
22   au BufNewFile,BufRead *.as setf actionscript
23
24   au BufNewFile,BufRead *.dox setf doxygen
25
26   au BufNewFile,BufRead *.iop setf d
27
28   au BufNewFile,BufRead .gitsendemail.* setf gitsendemail
29
30   " Distinguish between HTML, XHTML and Django
31   fun! s:FThtml()
32     let n = 1
33     while n < 10 && n < line("$")
34       if getline(n) =~ '<?'
35         setf php
36         return
37       endif
38       if getline(n) =~ '\<DTD\s\+XHTML\s'
39         setf xhtml
40         return
41       endif
42       if getline(n) =~ '{%\s*\(extends\|block\)\>'
43         setf htmldjango
44         return
45       endif
46       let n = n + 1
47     endwhile
48     setf html
49   endfun
50
51 augroup END