Mercurial > vim
comparison runtime/ftplugin/ruby.vim @ 1215:1d08aac0aea9
updated for version 7.1b
author | vimboss |
---|---|
date | Thu, 10 May 2007 18:29:51 +0000 |
parents | c4cd8ad60bee |
children | 82b5078be2dd |
comparison
equal
deleted
inserted
replaced
1214:a91a2e0c4108 | 1215:1d08aac0aea9 |
---|---|
28 | 28 |
29 " Matchit support | 29 " Matchit support |
30 if exists("loaded_matchit") && !exists("b:match_words") | 30 if exists("loaded_matchit") && !exists("b:match_words") |
31 let b:match_ignorecase = 0 | 31 let b:match_ignorecase = 0 |
32 | 32 |
33 " TODO: improve optional do loops | |
34 let b:match_words = | 33 let b:match_words = |
35 \ '\%(' . | 34 \ '\<\%(if\|unless\|case\|while\|until\|for\|do\|class\|module\|def\|begin\)\>=\@!' . |
36 \ '\%(\%(\.\|\:\:\)\s*\|\:\)\@<!\<\%(class\|module\|begin\|def\|case\|for\|do\)\>' . | |
37 \ '\|' . | |
38 \ '\%(\%(^\|\.\.\.\=\|[{\:\,;([<>~\*/%&^|+-]\|\%(\<[_[\:lower\:]][_[\:alnum\:]]*\)\@<![!=?]\)\s*\)\@<=\%(if\|unless\|while\|until\)\>' . | |
39 \ '\)' . | |
40 \ ':' . | 35 \ ':' . |
41 \ '\%(' . | 36 \ '\<\%(else\|elsif\|ensure\|when\|rescue\|break\|redo\|next\|retry\)\>' . |
42 \ '\%(\%(\.\|\:\:\)\s*\|\:\)\@<!\<\%(else\|elsif\|ensure\|when\)\>' . | |
43 \ '\|' . | |
44 \ '\%(\%(^\|;\)\s*\)\@<=\<rescue\>' . | |
45 \ '\)' . | |
46 \ ':' . | 37 \ ':' . |
47 \ '\%(\%(\.\|\:\:\)\s*\|\:\)\@<!\<end\>' . | 38 \ '\<end\>' . |
48 \ ',{:},\[:\],(:)' | 39 \ ',{:},\[:\],(:)' |
49 | 40 |
50 let b:match_skip = | 41 let b:match_skip = |
51 \ "synIDattr(synID(line('.'),col('.'),0),'name') =~ '" . | 42 \ "synIDattr(synID(line('.'),col('.'),0),'name') =~ '" . |
52 \ "\\<ruby\\%(String\\|StringDelimiter\\|ASCIICode\\|Interpolation\\|" . | 43 \ "\\<ruby\\%(String\\|StringDelimiter\\|ASCIICode\\|Escape\\|" . |
53 \ "NoInterpolation\\|Escape\\|Comment\\|Documentation\\)\\>'" | 44 \ "Interpolation\\|NoInterpolation\\|Comment\\|Documentation\\|" . |
54 | 45 \ "ConditionalModifier\\|RepeatModifier\\|OptionalDo\\|" . |
46 \ "Function\\|BlockArgument\\|KeywordAsMethod\\|ClassVariable\\|" . | |
47 \ "InstanceVariable\\|GlobalVariable\\|Symbol\\)\\>'" | |
55 endif | 48 endif |
56 | 49 |
57 setlocal formatoptions-=t formatoptions+=croql | 50 setlocal formatoptions-=t formatoptions+=croql |
58 | 51 |
59 setlocal include=^\\s*\\<\\(load\\\|\w*require\\)\\> | 52 setlocal include=^\\s*\\<\\(load\\\|\w*require\\)\\> |
101 let b:browsefilter = "Ruby Source Files (*.rb)\t*.rb\n" . | 94 let b:browsefilter = "Ruby Source Files (*.rb)\t*.rb\n" . |
102 \ "All Files (*.*)\t*.*\n" | 95 \ "All Files (*.*)\t*.*\n" |
103 endif | 96 endif |
104 | 97 |
105 let b:undo_ftplugin = "setl fo< inc< inex< sua< def< com< cms< path< kp<" | 98 let b:undo_ftplugin = "setl fo< inc< inex< sua< def< com< cms< path< kp<" |
106 \ "| unlet! b:browsefilter b:match_ignorecase b:match_words b:match_skip" | 99 \."| unlet! b:browsefilter b:match_ignorecase b:match_words b:match_skip" |
107 \ "| if exists('&ofu') && has('ruby') | setl ofu< | endif" | 100 \."| if exists('&ofu') && has('ruby') | setl ofu< | endif" |
108 \ "| if has('balloon_eval') && exists('+bexpr') | setl bexpr< | endif" | 101 \."| if has('balloon_eval') && exists('+bexpr') | setl bexpr< | endif" |
102 | |
103 if !exists("g:no_plugin_maps") && !exists("g:no_ruby_maps") | |
104 | |
105 noremap <silent> <buffer> [m :<C-U>call <SID>searchsyn('\<def\>','rubyDefine','b')<CR> | |
106 noremap <silent> <buffer> ]m :<C-U>call <SID>searchsyn('\<def\>','rubyDefine','')<CR> | |
107 noremap <silent> <buffer> [M :<C-U>call <SID>searchsyn('\<end\>','rubyDefine','b')<CR> | |
108 noremap <silent> <buffer> ]M :<C-U>call <SID>searchsyn('\<end\>','rubyDefine','')<CR> | |
109 | |
110 noremap <silent> <buffer> [[ :<C-U>call <SID>searchsyn('\<\%(class\<Bar>module\)\>','rubyModule\<Bar>rubyClass','b')<CR> | |
111 noremap <silent> <buffer> ]] :<C-U>call <SID>searchsyn('\<\%(class\<Bar>module\)\>','rubyModule\<Bar>rubyClass','')<CR> | |
112 noremap <silent> <buffer> [] :<C-U>call <SID>searchsyn('\<end\>','rubyModule\<Bar>rubyClass','b')<CR> | |
113 noremap <silent> <buffer> ][ :<C-U>call <SID>searchsyn('\<end\>','rubyModule\<Bar>rubyClass','')<CR> | |
114 | |
115 let b:undo_ftplugin = b:undo_ftplugin | |
116 \."| sil! exe 'unmap <buffer> [[' | sil! exe 'unmap <buffer> ]]' | sil! exe 'unmap <buffer> []' | sil! exe 'unmap <buffer> ]['" | |
117 \."| sil! exe 'unmap <buffer> [m' | sil! exe 'unmap <buffer> ]m' | sil! exe 'unmap <buffer> [M' | sil! exe 'unmap <buffer> ]M'" | |
118 endif | |
109 | 119 |
110 let &cpo = s:cpo_save | 120 let &cpo = s:cpo_save |
111 unlet s:cpo_save | 121 unlet s:cpo_save |
112 | 122 |
113 if exists("g:did_ruby_ftplugin_functions") | 123 if exists("g:did_ruby_ftplugin_functions") |
153 let str = substitute(str,'.*\.\s*to_proc\s*\.\s*','Proc#','') | 163 let str = substitute(str,'.*\.\s*to_proc\s*\.\s*','Proc#','') |
154 if str !~ '^\w' | 164 if str !~ '^\w' |
155 return '' | 165 return '' |
156 endif | 166 endif |
157 silent! let res = substitute(system("ri -f simple -T \"".str.'"'),'\n$','','') | 167 silent! let res = substitute(system("ri -f simple -T \"".str.'"'),'\n$','','') |
158 if res =~ '^Nothing known about' || res =~ '^Bad argument:' | 168 if res =~ '^Nothing known about' || res =~ '^Bad argument:' || res =~ '^More than one method' |
159 return '' | 169 return '' |
160 endif | 170 endif |
161 return res | 171 return res |
162 else | 172 else |
163 return "" | 173 return "" |
164 endif | 174 endif |
165 endfunction | 175 endfunction |
166 | 176 |
177 function! s:searchsyn(pattern,syn,flags) | |
178 norm! m' | |
179 let i = 0 | |
180 let cnt = v:count ? v:count : 1 | |
181 while i < cnt | |
182 let i = i + 1 | |
183 let line = line('.') | |
184 let col = col('.') | |
185 let pos = search(a:pattern,'W'.a:flags) | |
186 while pos != 0 && s:synname() !~# a:syn | |
187 let pos = search(a:pattern,'W'.a:flags) | |
188 endwhile | |
189 if pos == 0 | |
190 call cursor(line,col) | |
191 return | |
192 endif | |
193 endwhile | |
194 endfunction | |
195 | |
196 function! s:synname() | |
197 return synIDattr(synID(line('.'),col('.'),0),'name') | |
198 endfunction | |
167 | 199 |
168 " | 200 " |
169 " Instructions for enabling "matchit" support: | 201 " Instructions for enabling "matchit" support: |
170 " | 202 " |
171 " 1. Look for the latest "matchit" plugin at | 203 " 1. Look for the latest "matchit" plugin at |