@@ -96,9 +96,26 @@ if has("gui_win32") && !exists("b:browsefilter")
9696endif
9797
9898let b: undo_ftplugin = " setl fo< inc< inex< sua< def< com< cms< path< kp<"
99- \ " | unlet! b:browsefilter b:match_ignorecase b:match_words b:match_skip"
100- \ " | if exists('&ofu') && has('ruby') | setl ofu< | endif"
101- \ " | if has('balloon_eval') && exists('+bexpr') | setl bexpr< | endif"
99+ \. " | unlet! b:browsefilter b:match_ignorecase b:match_words b:match_skip"
100+ \. " | if exists('&ofu') && has('ruby') | setl ofu< | 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
102119
103120let &cpo = s: cpo_save
104121unlet s: cpo_save
@@ -157,6 +174,28 @@ function! RubyBalloonexpr()
157174 endif
158175endfunction
159176
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
160199
161200"
162201" Instructions for enabling "matchit" support:
0 commit comments