3 " Maintainer: Tim Pope <vimNOSPAM@tpope.info>
4 " Info: $Id: eruby.vim,v 1.12 2008/06/29 04:18:43 tpope Exp $
5 " URL: http://vim-ruby.rubyforge.org
6 " Anon CVS: See above site
7 " Release Coordinator: Doug Kearns <dougkearns@gmail.com>
9 " Only do this when not done yet for this buffer
10 if exists("b:did_ftplugin")
17 " Define some defaults in case the included ftplugins don't set them.
18 let s:undo_ftplugin = ""
19 let s:browsefilter = "All Files (*.*)\t*.*\n"
20 let s:match_words = ""
22 if !exists("g:eruby_default_subtype")
23 let g:eruby_default_subtype = "html"
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 == ''
30 let b:eruby_subtype = matchstr(substitute(expand("%:t"),'\c\%(\.erb\|\.eruby\)\+$','',''),'\.\zs\w\+$')
32 if b:eruby_subtype == 'rhtml'
33 let b:eruby_subtype = 'html'
34 elseif b:eruby_subtype == 'rb'
35 let b:eruby_subtype = 'ruby'
36 elseif b:eruby_subtype == 'yml'
37 let b:eruby_subtype = 'yaml'
38 elseif b:eruby_subtype == 'js'
39 let b:eruby_subtype = 'javascript'
40 elseif b:eruby_subtype == 'txt'
41 " Conventional; not a real file type
42 let b:eruby_subtype = 'text'
43 elseif b:eruby_subtype == ''
44 let b:eruby_subtype = g:eruby_default_subtype
48 if exists("b:eruby_subtype") && b:eruby_subtype != ''
49 exe "runtime! ftplugin/".b:eruby_subtype.".vim ftplugin/".b:eruby_subtype."_*.vim ftplugin/".b:eruby_subtype."/*.vim"
51 runtime! ftplugin/html.vim ftplugin/html_*.vim ftplugin/html/*.vim
55 " Override our defaults if these were set by an included ftplugin.
56 if exists("b:undo_ftplugin")
57 let s:undo_ftplugin = b:undo_ftplugin
60 if exists("b:browsefilter")
61 let s:browsefilter = b:browsefilter
64 if exists("b:match_words")
65 let s:match_words = b:match_words
69 runtime! ftplugin/ruby.vim ftplugin/ruby_*.vim ftplugin/ruby/*.vim
70 let b:did_ftplugin = 1
72 " Combine the new set of values with those previously included.
73 if exists("b:undo_ftplugin")
74 let s:undo_ftplugin = b:undo_ftplugin . " | " . s:undo_ftplugin
76 if exists ("b:browsefilter")
77 let s:browsefilter = substitute(b:browsefilter,'\cAll Files (\*\.\*)\t\*\.\*\n','','') . s:browsefilter
79 if exists("b:match_words")
80 let s:match_words = b:match_words . ',' . s:match_words
83 " Change the browse dialog on Win32 to show mainly eRuby-related files
85 let b:browsefilter="eRuby Files (*.erb, *.rhtml)\t*.erb;*.rhtml\n" . s:browsefilter
88 " Load the combined list of match_words for matchit.vim
89 if exists("loaded_matchit")
90 let b:match_words = s:match_words
94 setlocal commentstring=<%#%s%>
96 let b:undo_ftplugin = "setl cms< "
97 \ " | unlet! b:browsefilter b:match_words | " . s:undo_ftplugin
101 " vim: nowrap sw=2 sts=2 ts=8: