529
|
1 " Vim filetype plugin
|
831
|
2 " Language: eRuby
|
2225
|
3 " Maintainer: Tim Pope <vimNOSPAM@tpope.org>
|
|
4 " Last Change: 2010 Apr 15
|
831
|
5 " URL: http://vim-ruby.rubyforge.org
|
|
6 " Anon CVS: See above site
|
|
7 " Release Coordinator: Doug Kearns <dougkearns@gmail.com>
|
529
|
8
|
|
9 " Only do this when not done yet for this buffer
|
1205
|
10 if exists("b:did_ftplugin")
|
529
|
11 finish
|
|
12 endif
|
|
13
|
|
14 let s:save_cpo = &cpo
|
|
15 set cpo-=C
|
|
16
|
|
17 " Define some defaults in case the included ftplugins don't set them.
|
|
18 let s:undo_ftplugin = ""
|
1205
|
19 let s:browsefilter = "All Files (*.*)\t*.*\n"
|
529
|
20 let s:match_words = ""
|
|
21
|
1205
|
22 if !exists("g:eruby_default_subtype")
|
|
23 let g:eruby_default_subtype = "html"
|
|
24 endif
|
|
25
|
|
26 if !exists("b:eruby_subtype")
|
|
27 let s:lines = getline(1)."\n".getline(2)."\n".getline(3)."\n".getline(4)."\n".getline(5)."\n".getline("$")
|
|
28 let b:eruby_subtype = matchstr(s:lines,'eruby_subtype=\zs\w\+')
|
|
29 if b:eruby_subtype == ''
|
2225
|
30 let b:eruby_subtype = matchstr(&filetype,'^eruby\.\zs\w\+')
|
|
31 endif
|
|
32 if b:eruby_subtype == ''
|
|
33 let b:eruby_subtype = matchstr(substitute(expand("%:t"),'\c\%(\.erb\|\.eruby\|\.erubis\)\+$','',''),'\.\zs\w\+$')
|
1205
|
34 endif
|
|
35 if b:eruby_subtype == 'rhtml'
|
|
36 let b:eruby_subtype = 'html'
|
|
37 elseif b:eruby_subtype == 'rb'
|
|
38 let b:eruby_subtype = 'ruby'
|
|
39 elseif b:eruby_subtype == 'yml'
|
|
40 let b:eruby_subtype = 'yaml'
|
|
41 elseif b:eruby_subtype == 'js'
|
|
42 let b:eruby_subtype = 'javascript'
|
|
43 elseif b:eruby_subtype == 'txt'
|
|
44 " Conventional; not a real file type
|
|
45 let b:eruby_subtype = 'text'
|
|
46 elseif b:eruby_subtype == ''
|
|
47 let b:eruby_subtype = g:eruby_default_subtype
|
|
48 endif
|
|
49 endif
|
|
50
|
|
51 if exists("b:eruby_subtype") && b:eruby_subtype != ''
|
|
52 exe "runtime! ftplugin/".b:eruby_subtype.".vim ftplugin/".b:eruby_subtype."_*.vim ftplugin/".b:eruby_subtype."/*.vim"
|
|
53 else
|
|
54 runtime! ftplugin/html.vim ftplugin/html_*.vim ftplugin/html/*.vim
|
|
55 endif
|
|
56 unlet! b:did_ftplugin
|
529
|
57
|
|
58 " Override our defaults if these were set by an included ftplugin.
|
|
59 if exists("b:undo_ftplugin")
|
1205
|
60 let s:undo_ftplugin = b:undo_ftplugin
|
|
61 unlet b:undo_ftplugin
|
529
|
62 endif
|
|
63 if exists("b:browsefilter")
|
1205
|
64 let s:browsefilter = b:browsefilter
|
|
65 unlet b:browsefilter
|
529
|
66 endif
|
|
67 if exists("b:match_words")
|
1205
|
68 let s:match_words = b:match_words
|
|
69 unlet b:match_words
|
529
|
70 endif
|
|
71
|
|
72 runtime! ftplugin/ruby.vim ftplugin/ruby_*.vim ftplugin/ruby/*.vim
|
|
73 let b:did_ftplugin = 1
|
|
74
|
|
75 " Combine the new set of values with those previously included.
|
|
76 if exists("b:undo_ftplugin")
|
1205
|
77 let s:undo_ftplugin = b:undo_ftplugin . " | " . s:undo_ftplugin
|
529
|
78 endif
|
|
79 if exists ("b:browsefilter")
|
1205
|
80 let s:browsefilter = substitute(b:browsefilter,'\cAll Files (\*\.\*)\t\*\.\*\n','','') . s:browsefilter
|
529
|
81 endif
|
|
82 if exists("b:match_words")
|
1205
|
83 let s:match_words = b:match_words . ',' . s:match_words
|
529
|
84 endif
|
|
85
|
|
86 " Change the browse dialog on Win32 to show mainly eRuby-related files
|
|
87 if has("gui_win32")
|
1205
|
88 let b:browsefilter="eRuby Files (*.erb, *.rhtml)\t*.erb;*.rhtml\n" . s:browsefilter
|
529
|
89 endif
|
|
90
|
|
91 " Load the combined list of match_words for matchit.vim
|
|
92 if exists("loaded_matchit")
|
1205
|
93 let b:match_words = s:match_words
|
529
|
94 endif
|
|
95
|
|
96 " TODO: comments=
|
|
97 setlocal commentstring=<%#%s%>
|
|
98
|
|
99 let b:undo_ftplugin = "setl cms< "
|
|
100 \ " | unlet! b:browsefilter b:match_words | " . s:undo_ftplugin
|
|
101
|
|
102 let &cpo = s:save_cpo
|
|
103
|
1620
|
104 " vim: nowrap sw=2 sts=2 ts=8:
|