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