c0f12d21bee906e4f6f19d071eea3fc96dc9e44a
[~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   au BufRead,BufNewFile *.blk              setf c
13   au BufRead,BufNewFile *.blkk             setf cpp
14
15   au BufRead,BufNewFile massif.*.txt       setf massif
16
17   " HTML (.shtml and .stm for server side)
18   au BufNewFile,BufRead *.html,*.htm,*.shtml,*.stm  call s:FThtml()
19
20   au BufNewFile,BufRead {mad,}mutt{ng,}-*-\w\+ setf mail
21
22   au BufNewFile,BufRead */X11/xkb/* setf xkb
23
24   au BufNewFile,BufRead *.as setf actionscript
25
26   au BufNewFile,BufRead *.dox setf doxygen
27
28   au BufNewFile,BufRead *.iop setf d
29
30   au BufNewFile,BufRead .gitsendemail.* setf gitsendemail
31
32   " Distinguish between HTML, XHTML and Django
33   fun! s:FThtml()
34     let n = 1
35     while n < 10 && n < line("$")
36       if getline(n) =~ '<?'
37         setf php
38         return
39       endif
40       if getline(n) =~ '\<DTD\s\+XHTML\s'
41         setf xhtml
42         return
43       endif
44       if getline(n) =~ '{%\s*\(extends\|block\)\>'
45         setf htmldjango
46         return
47       endif
48       let n = n + 1
49     endwhile
50     setf html
51   endfun
52
53 augroup END