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