From 79166c430b3bb0e15f1b96933636897b5a02a816 Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Thu, 10 May 2007 18:29:51 +0000 Subject: updated for version 7.1b --- runtime/ftplugin/ruby.vim | 70 ++++++++++++++++++++++++++++++++++------------- 1 file changed, 51 insertions(+), 19 deletions(-) (limited to 'runtime/ftplugin') diff --git a/runtime/ftplugin/ruby.vim b/runtime/ftplugin/ruby.vim index 630d260c9e..694a6fd9c1 100644 --- a/runtime/ftplugin/ruby.vim +++ b/runtime/ftplugin/ruby.vim @@ -30,28 +30,21 @@ endif if exists("loaded_matchit") && !exists("b:match_words") let b:match_ignorecase = 0 - " TODO: improve optional do loops let b:match_words = - \ '\%(' . - \ '\%(\%(\.\|\:\:\)\s*\|\:\)\@' . - \ '\|' . - \ '\%(\%(^\|\.\.\.\=\|[{\:\,;([<>~\*/%&^|+-]\|\%(\<[_[\:lower\:]][_[\:alnum\:]]*\)\@' . - \ '\)' . + \ '\<\%(if\|unless\|case\|while\|until\|for\|do\|class\|module\|def\|begin\)\>=\@!' . \ ':' . - \ '\%(' . - \ '\%(\%(\.\|\:\:\)\s*\|\:\)\@' . - \ '\|' . - \ '\%(\%(^\|;\)\s*\)\@<=\' . - \ '\)' . + \ '\<\%(else\|elsif\|ensure\|when\|rescue\|break\|redo\|next\|retry\)\>' . \ ':' . - \ '\%(\%(\.\|\:\:\)\s*\|\:\)\@' . + \ '\' . \ ',{:},\[:\],(:)' let b:match_skip = \ "synIDattr(synID(line('.'),col('.'),0),'name') =~ '" . - \ "\\'" - + \ "\\'" endif setlocal formatoptions-=t formatoptions+=croql @@ -103,9 +96,26 @@ if has("gui_win32") && !exists("b:browsefilter") endif let b:undo_ftplugin = "setl fo< inc< inex< sua< def< com< cms< path< kp<" - \ "| unlet! b:browsefilter b:match_ignorecase b:match_words b:match_skip" - \ "| if exists('&ofu') && has('ruby') | setl ofu< | endif" - \ "| if has('balloon_eval') && exists('+bexpr') | setl bexpr< | endif" + \."| unlet! b:browsefilter b:match_ignorecase b:match_words b:match_skip" + \."| if exists('&ofu') && has('ruby') | setl ofu< | endif" + \."| if has('balloon_eval') && exists('+bexpr') | setl bexpr< | endif" + +if !exists("g:no_plugin_maps") && !exists("g:no_ruby_maps") + + noremap [m :call searchsyn('\','rubyDefine','b') + noremap ]m :call searchsyn('\','rubyDefine','') + noremap [M :call searchsyn('\','rubyDefine','b') + noremap ]M :call searchsyn('\','rubyDefine','') + + noremap [[ :call searchsyn('\<\%(class\module\)\>','rubyModule\rubyClass','b') + noremap ]] :call searchsyn('\<\%(class\module\)\>','rubyModule\rubyClass','') + noremap [] :call searchsyn('\','rubyModule\rubyClass','b') + noremap ][ :call searchsyn('\','rubyModule\rubyClass','') + + let b:undo_ftplugin = b:undo_ftplugin + \."| sil! exe 'unmap [[' | sil! exe 'unmap ]]' | sil! exe 'unmap []' | sil! exe 'unmap ]['" + \."| sil! exe 'unmap [m' | sil! exe 'unmap ]m' | sil! exe 'unmap [M' | sil! exe 'unmap ]M'" +endif let &cpo = s:cpo_save unlet s:cpo_save @@ -155,7 +165,7 @@ function! RubyBalloonexpr() return '' endif silent! let res = substitute(system("ri -f simple -T \"".str.'"'),'\n$','','') - if res =~ '^Nothing known about' || res =~ '^Bad argument:' + if res =~ '^Nothing known about' || res =~ '^Bad argument:' || res =~ '^More than one method' return '' endif return res @@ -164,6 +174,28 @@ function! RubyBalloonexpr() endif endfunction +function! s:searchsyn(pattern,syn,flags) + norm! m' + let i = 0 + let cnt = v:count ? v:count : 1 + while i < cnt + let i = i + 1 + let line = line('.') + let col = col('.') + let pos = search(a:pattern,'W'.a:flags) + while pos != 0 && s:synname() !~# a:syn + let pos = search(a:pattern,'W'.a:flags) + endwhile + if pos == 0 + call cursor(line,col) + return + endif + endwhile +endfunction + +function! s:synname() + return synIDattr(synID(line('.'),col('.'),0),'name') +endfunction " " Instructions for enabling "matchit" support: -- cgit v1.2.3