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