Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 103 lines (87 sloc) 3.161 kB
21f0b56 @dkearns add new eRuby ftplugin
dkearns authored
1 " Vim filetype plugin
ad3a6a9 @dkearns add Release-Coordinator header line and remove GPL license
dkearns authored
2 " Language: eRuby
2dd56d6 @tpope Update Tim Pope's email
tpope authored
3 " Maintainer: Tim Pope <vimNOSPAM@tpope.org>
699670a @dkearns Update all RubyForge URLs with new GitHub equivalents.
dkearns authored
4 " URL: https://github.com/vim-ruby/vim-ruby
ad3a6a9 @dkearns add Release-Coordinator header line and remove GPL license
dkearns authored
5 " Anon CVS: See above site
6 " Release Coordinator: Doug Kearns <dougkearns@gmail.com>
21f0b56 @dkearns add new eRuby ftplugin
dkearns authored
7
8 " Only do this when not done yet for this buffer
653a80b @tpope Support for a subtype in ftplugin/eruby.vim
tpope authored
9 if exists("b:did_ftplugin")
21f0b56 @dkearns add new eRuby ftplugin
dkearns authored
10 finish
11 endif
12
13 let s:save_cpo = &cpo
14 set cpo-=C
15
16 " Define some defaults in case the included ftplugins don't set them.
17 let s:undo_ftplugin = ""
1859099 @tpope Add subtype support to indent/eruby.vim
tpope authored
18 let s:browsefilter = "All Files (*.*)\t*.*\n"
21f0b56 @dkearns add new eRuby ftplugin
dkearns authored
19 let s:match_words = ""
20
1ad4c67 @tpope default eruby subtype option
tpope authored
21 if !exists("g:eruby_default_subtype")
22 let g:eruby_default_subtype = "html"
23 endif
24
8ee9e43 @tpope Give higher precedence to eruby.foo subtype
tpope authored
25 if &filetype =~ '^eruby\.'
26 let b:eruby_subtype = matchstr(&filetype,'^eruby\.\zs\w\+')
27 elseif !exists("b:eruby_subtype")
653a80b @tpope Support for a subtype in ftplugin/eruby.vim
tpope authored
28 let s:lines = getline(1)."\n".getline(2)."\n".getline(3)."\n".getline(4)."\n".getline(5)."\n".getline("$")
29 let b:eruby_subtype = matchstr(s:lines,'eruby_subtype=\zs\w\+')
30 if b:eruby_subtype == ''
4476f38 @tpope Strip .erubis in subtype check
tpope authored
31 let b:eruby_subtype = matchstr(substitute(expand("%:t"),'\c\%(\.erb\|\.eruby\|\.erubis\)\+$','',''),'\.\zs\w\+$')
653a80b @tpope Support for a subtype in ftplugin/eruby.vim
tpope authored
32 endif
33 if b:eruby_subtype == 'rhtml'
34 let b:eruby_subtype = 'html'
35 elseif b:eruby_subtype == 'rb'
36 let b:eruby_subtype = 'ruby'
37 elseif b:eruby_subtype == 'yml'
38 let b:eruby_subtype = 'yaml'
5d28285 @tpope Refined eRuby subtype detection
tpope authored
39 elseif b:eruby_subtype == 'js'
40 let b:eruby_subtype = 'javascript'
653a80b @tpope Support for a subtype in ftplugin/eruby.vim
tpope authored
41 elseif b:eruby_subtype == 'txt'
42 " Conventional; not a real file type
43 let b:eruby_subtype = 'text'
44 elseif b:eruby_subtype == ''
1ad4c67 @tpope default eruby subtype option
tpope authored
45 let b:eruby_subtype = g:eruby_default_subtype
653a80b @tpope Support for a subtype in ftplugin/eruby.vim
tpope authored
46 endif
47 endif
48
49 if exists("b:eruby_subtype") && b:eruby_subtype != ''
50 exe "runtime! ftplugin/".b:eruby_subtype.".vim ftplugin/".b:eruby_subtype."_*.vim ftplugin/".b:eruby_subtype."/*.vim"
51 else
52 runtime! ftplugin/html.vim ftplugin/html_*.vim ftplugin/html/*.vim
53 endif
54 unlet! b:did_ftplugin
21f0b56 @dkearns add new eRuby ftplugin
dkearns authored
55
56 " Override our defaults if these were set by an included ftplugin.
57 if exists("b:undo_ftplugin")
653a80b @tpope Support for a subtype in ftplugin/eruby.vim
tpope authored
58 let s:undo_ftplugin = b:undo_ftplugin
59 unlet b:undo_ftplugin
21f0b56 @dkearns add new eRuby ftplugin
dkearns authored
60 endif
61 if exists("b:browsefilter")
653a80b @tpope Support for a subtype in ftplugin/eruby.vim
tpope authored
62 let s:browsefilter = b:browsefilter
63 unlet b:browsefilter
21f0b56 @dkearns add new eRuby ftplugin
dkearns authored
64 endif
65 if exists("b:match_words")
653a80b @tpope Support for a subtype in ftplugin/eruby.vim
tpope authored
66 let s:match_words = b:match_words
67 unlet b:match_words
21f0b56 @dkearns add new eRuby ftplugin
dkearns authored
68 endif
69
70 runtime! ftplugin/ruby.vim ftplugin/ruby_*.vim ftplugin/ruby/*.vim
71 let b:did_ftplugin = 1
72
73 " Combine the new set of values with those previously included.
74 if exists("b:undo_ftplugin")
653a80b @tpope Support for a subtype in ftplugin/eruby.vim
tpope authored
75 let s:undo_ftplugin = b:undo_ftplugin . " | " . s:undo_ftplugin
21f0b56 @dkearns add new eRuby ftplugin
dkearns authored
76 endif
77 if exists ("b:browsefilter")
653a80b @tpope Support for a subtype in ftplugin/eruby.vim
tpope authored
78 let s:browsefilter = substitute(b:browsefilter,'\cAll Files (\*\.\*)\t\*\.\*\n','','') . s:browsefilter
21f0b56 @dkearns add new eRuby ftplugin
dkearns authored
79 endif
80 if exists("b:match_words")
653a80b @tpope Support for a subtype in ftplugin/eruby.vim
tpope authored
81 let s:match_words = b:match_words . ',' . s:match_words
21f0b56 @dkearns add new eRuby ftplugin
dkearns authored
82 endif
83
84 " Change the browse dialog on Win32 to show mainly eRuby-related files
85 if has("gui_win32")
653a80b @tpope Support for a subtype in ftplugin/eruby.vim
tpope authored
86 let b:browsefilter="eRuby Files (*.erb, *.rhtml)\t*.erb;*.rhtml\n" . s:browsefilter
21f0b56 @dkearns add new eRuby ftplugin
dkearns authored
87 endif
88
89 " Load the combined list of match_words for matchit.vim
90 if exists("loaded_matchit")
653a80b @tpope Support for a subtype in ftplugin/eruby.vim
tpope authored
91 let b:match_words = s:match_words
21f0b56 @dkearns add new eRuby ftplugin
dkearns authored
92 endif
93
94 " TODO: comments=
95 setlocal commentstring=<%#%s%>
96
97 let b:undo_ftplugin = "setl cms< "
98 \ " | unlet! b:browsefilter b:match_words | " . s:undo_ftplugin
99
100 let &cpo = s:save_cpo
101
b2d3cba @tpope indent/eruby.vim: fix quirk in optional argument handling
tpope authored
102 " vim: nowrap sw=2 sts=2 ts=8:
Something went wrong with that request. Please try again.