/
filetype.vim
79 lines (63 loc) · 2.13 KB
/
filetype.vim
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
" ======================================================================================
" File : filetype.vim
" Author : Wu Jie
" Last Change : 12/09/2009 | 18:14:34 PM | Wednesday,December
" Description : Vim support file to overrule default file types
" ======================================================================================
" /////////////////////////////////////////////////////////////////////////////
" au defines
" /////////////////////////////////////////////////////////////////////////////
" additional cpp file type
au BufNewFile,BufRead *.ipp setf cpp
" High Level Shader Language
au BufNewFile,BufRead *.hlsl,*.fx,*.fxh,*.cg,*.vsh,*.psh,*.shd,*.glsl,*.shader setf hlsl
" Max Script
au BufNewFile,BufRead *.ms,*.mse,*.mcr,*.mzp,*.ds setf maxscript
" Doxygen Comment
au BufNewFile,BufRead *.dox,*.doxygen setf cpp.doxygen
" gmsh
au BufNewFile,BufRead *.geo setf gmsh
" as (actionscript/flash) I use java analyasis it
au BufNewFile,BufRead *.as setf javascript
" nsis
au BufNewFile,BufRead *.nsh setf nsis
" swig
au BufNewFile,BufRead *.i,*.swg setf swig
" cs
au BufNewFile,BufRead *.tt setf cs
" treat gitignore file as config file
au BufNewFile,BufRead *.gitignore setf cfg
" Matlab or Objective C
au BufNewFile,BufRead *.m call s:ex_FTm()
" lua
au BufNewFile,BufRead *.wlua setf lua
"/////////////////////////////////////////////////////////////////////////////
" ex_FTm
"/////////////////////////////////////////////////////////////////////////////
" ------------------------------------------------------------------
" Desc:
" ------------------------------------------------------------------
func! s:ex_FTm()
let n = 1
while n < 10
let line = getline(n)
if line =~ '^\s*\(#\s*\(include\|import\)\>\|\/\*\|^\/\/\)'
setf objc
return
endif
if line =~ '^\s*%'
setf matlab
return
endif
if line =~ '^\s*(\*'
setf mma
return
endif
let n = n + 1
endwhile
if exists("g:filetype_m")
exe "setf " . g:filetype_m
else
setf matlab
endif
endfunc