annotate runtime/ftplugin/ruby.vim @ 2784:930b171ce3fc v7.3.168

updated for version 7.3.168 Problem: When the second argument of input() contains a CR the text up to that is used without asking the user. (Yasuhiro Matsumoto) Solution: Change CR, NL and ESC in the text to a space.
author Bram Moolenaar <bram@vim.org>
date Thu, 28 Apr 2011 17:30:09 +0200
parents dd5c1983e355
children a5352e73dc00
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1 " Vim filetype plugin
831
f24a95dae8ee updated for version 7.0d05
vimboss
parents: 829
diff changeset
2 " Language: Ruby
867
a5677b7ce858 updated for version 7.0g04
vimboss
parents: 831
diff changeset
3 " Maintainer: Gavin Sinclair <gsinclair at gmail.com>
2225
dd5c1983e355 Runtime file updates.
Bram Moolenaar <bram@vim.org>
parents: 2034
diff changeset
4 " Last Change: 2010 Mar 15
831
f24a95dae8ee updated for version 7.0d05
vimboss
parents: 829
diff changeset
5 " URL: http://vim-ruby.rubyforge.org
f24a95dae8ee updated for version 7.0d05
vimboss
parents: 829
diff changeset
6 " Anon CVS: See above site
1123
c4cd8ad60bee updated for version 7.1a
vimboss
parents: 867
diff changeset
7 " Release Coordinator: Doug Kearns <dougkearns@gmail.com>
530
339999b511a0 updated for version 7.0148
vimboss
parents: 7
diff changeset
8 " ----------------------------------------------------------------------------
339999b511a0 updated for version 7.0148
vimboss
parents: 7
diff changeset
9 "
1123
c4cd8ad60bee updated for version 7.1a
vimboss
parents: 867
diff changeset
10 " Original matchit support thanks to Ned Konz. See his ftplugin/ruby.vim at
530
339999b511a0 updated for version 7.0148
vimboss
parents: 7
diff changeset
11 " http://bike-nomad.com/vim/ruby.vim.
339999b511a0 updated for version 7.0148
vimboss
parents: 7
diff changeset
12 " ----------------------------------------------------------------------------
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
13
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
14 " Only do this when not done yet for this buffer
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
15 if (exists("b:did_ftplugin"))
530
339999b511a0 updated for version 7.0148
vimboss
parents: 7
diff changeset
16 finish
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
17 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
18 let b:did_ftplugin = 1
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
19
530
339999b511a0 updated for version 7.0148
vimboss
parents: 7
diff changeset
20 let s:cpo_save = &cpo
339999b511a0 updated for version 7.0148
vimboss
parents: 7
diff changeset
21 set cpo&vim
339999b511a0 updated for version 7.0148
vimboss
parents: 7
diff changeset
22
1123
c4cd8ad60bee updated for version 7.1a
vimboss
parents: 867
diff changeset
23 if has("gui_running") && !has("gui_win32")
c4cd8ad60bee updated for version 7.1a
vimboss
parents: 867
diff changeset
24 setlocal keywordprg=ri\ -T
c4cd8ad60bee updated for version 7.1a
vimboss
parents: 867
diff changeset
25 else
c4cd8ad60bee updated for version 7.1a
vimboss
parents: 867
diff changeset
26 setlocal keywordprg=ri
c4cd8ad60bee updated for version 7.1a
vimboss
parents: 867
diff changeset
27 endif
c4cd8ad60bee updated for version 7.1a
vimboss
parents: 867
diff changeset
28
530
339999b511a0 updated for version 7.0148
vimboss
parents: 7
diff changeset
29 " Matchit support
339999b511a0 updated for version 7.0148
vimboss
parents: 7
diff changeset
30 if exists("loaded_matchit") && !exists("b:match_words")
339999b511a0 updated for version 7.0148
vimboss
parents: 7
diff changeset
31 let b:match_ignorecase = 0
339999b511a0 updated for version 7.0148
vimboss
parents: 7
diff changeset
32
1123
c4cd8ad60bee updated for version 7.1a
vimboss
parents: 867
diff changeset
33 let b:match_words =
1215
1d08aac0aea9 updated for version 7.1b
vimboss
parents: 1123
diff changeset
34 \ '\<\%(if\|unless\|case\|while\|until\|for\|do\|class\|module\|def\|begin\)\>=\@!' .
1123
c4cd8ad60bee updated for version 7.1a
vimboss
parents: 867
diff changeset
35 \ ':' .
1215
1d08aac0aea9 updated for version 7.1b
vimboss
parents: 1123
diff changeset
36 \ '\<\%(else\|elsif\|ensure\|when\|rescue\|break\|redo\|next\|retry\)\>' .
1123
c4cd8ad60bee updated for version 7.1a
vimboss
parents: 867
diff changeset
37 \ ':' .
1215
1d08aac0aea9 updated for version 7.1b
vimboss
parents: 1123
diff changeset
38 \ '\<end\>' .
1123
c4cd8ad60bee updated for version 7.1a
vimboss
parents: 867
diff changeset
39 \ ',{:},\[:\],(:)'
530
339999b511a0 updated for version 7.0148
vimboss
parents: 7
diff changeset
40
339999b511a0 updated for version 7.0148
vimboss
parents: 7
diff changeset
41 let b:match_skip =
1123
c4cd8ad60bee updated for version 7.1a
vimboss
parents: 867
diff changeset
42 \ "synIDattr(synID(line('.'),col('.'),0),'name') =~ '" .
1215
1d08aac0aea9 updated for version 7.1b
vimboss
parents: 1123
diff changeset
43 \ "\\<ruby\\%(String\\|StringDelimiter\\|ASCIICode\\|Escape\\|" .
1d08aac0aea9 updated for version 7.1b
vimboss
parents: 1123
diff changeset
44 \ "Interpolation\\|NoInterpolation\\|Comment\\|Documentation\\|" .
1d08aac0aea9 updated for version 7.1b
vimboss
parents: 1123
diff changeset
45 \ "ConditionalModifier\\|RepeatModifier\\|OptionalDo\\|" .
1d08aac0aea9 updated for version 7.1b
vimboss
parents: 1123
diff changeset
46 \ "Function\\|BlockArgument\\|KeywordAsMethod\\|ClassVariable\\|" .
1d08aac0aea9 updated for version 7.1b
vimboss
parents: 1123
diff changeset
47 \ "InstanceVariable\\|GlobalVariable\\|Symbol\\)\\>'"
530
339999b511a0 updated for version 7.0148
vimboss
parents: 7
diff changeset
48 endif
339999b511a0 updated for version 7.0148
vimboss
parents: 7
diff changeset
49
339999b511a0 updated for version 7.0148
vimboss
parents: 7
diff changeset
50 setlocal formatoptions-=t formatoptions+=croql
339999b511a0 updated for version 7.0148
vimboss
parents: 7
diff changeset
51
339999b511a0 updated for version 7.0148
vimboss
parents: 7
diff changeset
52 setlocal include=^\\s*\\<\\(load\\\|\w*require\\)\\>
339999b511a0 updated for version 7.0148
vimboss
parents: 7
diff changeset
53 setlocal includeexpr=substitute(substitute(v:fname,'::','/','g'),'$','.rb','')
339999b511a0 updated for version 7.0148
vimboss
parents: 7
diff changeset
54 setlocal suffixesadd=.rb
831
f24a95dae8ee updated for version 7.0d05
vimboss
parents: 829
diff changeset
55
1123
c4cd8ad60bee updated for version 7.1a
vimboss
parents: 867
diff changeset
56 if exists("&ofu") && has("ruby")
831
f24a95dae8ee updated for version 7.0d05
vimboss
parents: 829
diff changeset
57 setlocal omnifunc=rubycomplete#Complete
f24a95dae8ee updated for version 7.0d05
vimboss
parents: 829
diff changeset
58 endif
530
339999b511a0 updated for version 7.0148
vimboss
parents: 7
diff changeset
59
1123
c4cd8ad60bee updated for version 7.1a
vimboss
parents: 867
diff changeset
60 " To activate, :set ballooneval
c4cd8ad60bee updated for version 7.1a
vimboss
parents: 867
diff changeset
61 if has('balloon_eval') && exists('+balloonexpr')
c4cd8ad60bee updated for version 7.1a
vimboss
parents: 867
diff changeset
62 setlocal balloonexpr=RubyBalloonexpr()
c4cd8ad60bee updated for version 7.1a
vimboss
parents: 867
diff changeset
63 endif
c4cd8ad60bee updated for version 7.1a
vimboss
parents: 867
diff changeset
64
c4cd8ad60bee updated for version 7.1a
vimboss
parents: 867
diff changeset
65
530
339999b511a0 updated for version 7.0148
vimboss
parents: 7
diff changeset
66 " TODO:
339999b511a0 updated for version 7.0148
vimboss
parents: 7
diff changeset
67 "setlocal define=^\\s*def
339999b511a0 updated for version 7.0148
vimboss
parents: 7
diff changeset
68
339999b511a0 updated for version 7.0148
vimboss
parents: 7
diff changeset
69 setlocal comments=:#
339999b511a0 updated for version 7.0148
vimboss
parents: 7
diff changeset
70 setlocal commentstring=#\ %s
339999b511a0 updated for version 7.0148
vimboss
parents: 7
diff changeset
71
2225
dd5c1983e355 Runtime file updates.
Bram Moolenaar <bram@vim.org>
parents: 2034
diff changeset
72 if !exists("s:ruby_path")
dd5c1983e355 Runtime file updates.
Bram Moolenaar <bram@vim.org>
parents: 2034
diff changeset
73 if exists("g:ruby_path")
dd5c1983e355 Runtime file updates.
Bram Moolenaar <bram@vim.org>
parents: 2034
diff changeset
74 let s:ruby_path = g:ruby_path
dd5c1983e355 Runtime file updates.
Bram Moolenaar <bram@vim.org>
parents: 2034
diff changeset
75 elseif has("ruby") && has("win32")
dd5c1983e355 Runtime file updates.
Bram Moolenaar <bram@vim.org>
parents: 2034
diff changeset
76 ruby VIM::command( 'let s:ruby_path = "%s"' % ($: + begin; require %q{rubygems}; Gem.all_load_paths.sort.uniq; rescue LoadError; []; end).join(%q{,}) )
dd5c1983e355 Runtime file updates.
Bram Moolenaar <bram@vim.org>
parents: 2034
diff changeset
77 let s:ruby_path = '.,' . substitute(s:ruby_path, '\%(^\|,\)\.\%(,\|$\)', ',,', '')
1123
c4cd8ad60bee updated for version 7.1a
vimboss
parents: 867
diff changeset
78 elseif executable("ruby")
548
f43150a669dc updated for version 7.0155
vimboss
parents: 530
diff changeset
79 let s:code = "print ($: + begin; require %q{rubygems}; Gem.all_load_paths.sort.uniq; rescue LoadError; []; end).join(%q{,})"
530
339999b511a0 updated for version 7.0148
vimboss
parents: 7
diff changeset
80 if &shellxquote == "'"
2225
dd5c1983e355 Runtime file updates.
Bram Moolenaar <bram@vim.org>
parents: 2034
diff changeset
81 let s:ruby_path = system('ruby -e "' . s:code . '"')
530
339999b511a0 updated for version 7.0148
vimboss
parents: 7
diff changeset
82 else
2225
dd5c1983e355 Runtime file updates.
Bram Moolenaar <bram@vim.org>
parents: 2034
diff changeset
83 let s:ruby_path = system("ruby -e '" . s:code . "'")
530
339999b511a0 updated for version 7.0148
vimboss
parents: 7
diff changeset
84 endif
2225
dd5c1983e355 Runtime file updates.
Bram Moolenaar <bram@vim.org>
parents: 2034
diff changeset
85 let s:ruby_path = '.,' . substitute(s:ruby_path, '\%(^\|,\)\.\%(,\|$\)', ',,', '')
530
339999b511a0 updated for version 7.0148
vimboss
parents: 7
diff changeset
86 else
339999b511a0 updated for version 7.0148
vimboss
parents: 7
diff changeset
87 " If we can't call ruby to get its path, just default to using the
339999b511a0 updated for version 7.0148
vimboss
parents: 7
diff changeset
88 " current directory and the directory of the current file.
2225
dd5c1983e355 Runtime file updates.
Bram Moolenaar <bram@vim.org>
parents: 2034
diff changeset
89 let s:ruby_path = ".,,"
530
339999b511a0 updated for version 7.0148
vimboss
parents: 7
diff changeset
90 endif
339999b511a0 updated for version 7.0148
vimboss
parents: 7
diff changeset
91 endif
339999b511a0 updated for version 7.0148
vimboss
parents: 7
diff changeset
92
2225
dd5c1983e355 Runtime file updates.
Bram Moolenaar <bram@vim.org>
parents: 2034
diff changeset
93 let &l:path = s:ruby_path
530
339999b511a0 updated for version 7.0148
vimboss
parents: 7
diff changeset
94
339999b511a0 updated for version 7.0148
vimboss
parents: 7
diff changeset
95 if has("gui_win32") && !exists("b:browsefilter")
339999b511a0 updated for version 7.0148
vimboss
parents: 7
diff changeset
96 let b:browsefilter = "Ruby Source Files (*.rb)\t*.rb\n" .
1123
c4cd8ad60bee updated for version 7.1a
vimboss
parents: 867
diff changeset
97 \ "All Files (*.*)\t*.*\n"
530
339999b511a0 updated for version 7.0148
vimboss
parents: 7
diff changeset
98 endif
339999b511a0 updated for version 7.0148
vimboss
parents: 7
diff changeset
99
1123
c4cd8ad60bee updated for version 7.1a
vimboss
parents: 867
diff changeset
100 let b:undo_ftplugin = "setl fo< inc< inex< sua< def< com< cms< path< kp<"
1215
1d08aac0aea9 updated for version 7.1b
vimboss
parents: 1123
diff changeset
101 \."| unlet! b:browsefilter b:match_ignorecase b:match_words b:match_skip"
1d08aac0aea9 updated for version 7.1b
vimboss
parents: 1123
diff changeset
102 \."| if exists('&ofu') && has('ruby') | setl ofu< | endif"
1d08aac0aea9 updated for version 7.1b
vimboss
parents: 1123
diff changeset
103 \."| if has('balloon_eval') && exists('+bexpr') | setl bexpr< | endif"
1d08aac0aea9 updated for version 7.1b
vimboss
parents: 1123
diff changeset
104
1d08aac0aea9 updated for version 7.1b
vimboss
parents: 1123
diff changeset
105 if !exists("g:no_plugin_maps") && !exists("g:no_ruby_maps")
1d08aac0aea9 updated for version 7.1b
vimboss
parents: 1123
diff changeset
106
2225
dd5c1983e355 Runtime file updates.
Bram Moolenaar <bram@vim.org>
parents: 2034
diff changeset
107 nnoremap <silent> <buffer> [m :<C-U>call <SID>searchsyn('\<def\>','rubyDefine','b','n')<CR>
dd5c1983e355 Runtime file updates.
Bram Moolenaar <bram@vim.org>
parents: 2034
diff changeset
108 nnoremap <silent> <buffer> ]m :<C-U>call <SID>searchsyn('\<def\>','rubyDefine','','n')<CR>
dd5c1983e355 Runtime file updates.
Bram Moolenaar <bram@vim.org>
parents: 2034
diff changeset
109 nnoremap <silent> <buffer> [M :<C-U>call <SID>searchsyn('\<end\>','rubyDefine','b','n')<CR>
dd5c1983e355 Runtime file updates.
Bram Moolenaar <bram@vim.org>
parents: 2034
diff changeset
110 nnoremap <silent> <buffer> ]M :<C-U>call <SID>searchsyn('\<end\>','rubyDefine','','n')<CR>
dd5c1983e355 Runtime file updates.
Bram Moolenaar <bram@vim.org>
parents: 2034
diff changeset
111 xnoremap <silent> <buffer> [m :<C-U>call <SID>searchsyn('\<def\>','rubyDefine','b','v')<CR>
dd5c1983e355 Runtime file updates.
Bram Moolenaar <bram@vim.org>
parents: 2034
diff changeset
112 xnoremap <silent> <buffer> ]m :<C-U>call <SID>searchsyn('\<def\>','rubyDefine','','v')<CR>
dd5c1983e355 Runtime file updates.
Bram Moolenaar <bram@vim.org>
parents: 2034
diff changeset
113 xnoremap <silent> <buffer> [M :<C-U>call <SID>searchsyn('\<end\>','rubyDefine','b','v')<CR>
dd5c1983e355 Runtime file updates.
Bram Moolenaar <bram@vim.org>
parents: 2034
diff changeset
114 xnoremap <silent> <buffer> ]M :<C-U>call <SID>searchsyn('\<end\>','rubyDefine','','v')<CR>
1215
1d08aac0aea9 updated for version 7.1b
vimboss
parents: 1123
diff changeset
115
2225
dd5c1983e355 Runtime file updates.
Bram Moolenaar <bram@vim.org>
parents: 2034
diff changeset
116 nnoremap <silent> <buffer> [[ :<C-U>call <SID>searchsyn('\<\%(class\<Bar>module\)\>','rubyModule\<Bar>rubyClass','b','n')<CR>
dd5c1983e355 Runtime file updates.
Bram Moolenaar <bram@vim.org>
parents: 2034
diff changeset
117 nnoremap <silent> <buffer> ]] :<C-U>call <SID>searchsyn('\<\%(class\<Bar>module\)\>','rubyModule\<Bar>rubyClass','','n')<CR>
dd5c1983e355 Runtime file updates.
Bram Moolenaar <bram@vim.org>
parents: 2034
diff changeset
118 nnoremap <silent> <buffer> [] :<C-U>call <SID>searchsyn('\<end\>','rubyModule\<Bar>rubyClass','b','n')<CR>
dd5c1983e355 Runtime file updates.
Bram Moolenaar <bram@vim.org>
parents: 2034
diff changeset
119 nnoremap <silent> <buffer> ][ :<C-U>call <SID>searchsyn('\<end\>','rubyModule\<Bar>rubyClass','','n')<CR>
dd5c1983e355 Runtime file updates.
Bram Moolenaar <bram@vim.org>
parents: 2034
diff changeset
120 xnoremap <silent> <buffer> [[ :<C-U>call <SID>searchsyn('\<\%(class\<Bar>module\)\>','rubyModule\<Bar>rubyClass','b','v')<CR>
dd5c1983e355 Runtime file updates.
Bram Moolenaar <bram@vim.org>
parents: 2034
diff changeset
121 xnoremap <silent> <buffer> ]] :<C-U>call <SID>searchsyn('\<\%(class\<Bar>module\)\>','rubyModule\<Bar>rubyClass','','v')<CR>
dd5c1983e355 Runtime file updates.
Bram Moolenaar <bram@vim.org>
parents: 2034
diff changeset
122 xnoremap <silent> <buffer> [] :<C-U>call <SID>searchsyn('\<end\>','rubyModule\<Bar>rubyClass','b','v')<CR>
dd5c1983e355 Runtime file updates.
Bram Moolenaar <bram@vim.org>
parents: 2034
diff changeset
123 xnoremap <silent> <buffer> ][ :<C-U>call <SID>searchsyn('\<end\>','rubyModule\<Bar>rubyClass','','v')<CR>
1215
1d08aac0aea9 updated for version 7.1b
vimboss
parents: 1123
diff changeset
124
1d08aac0aea9 updated for version 7.1b
vimboss
parents: 1123
diff changeset
125 let b:undo_ftplugin = b:undo_ftplugin
1d08aac0aea9 updated for version 7.1b
vimboss
parents: 1123
diff changeset
126 \."| sil! exe 'unmap <buffer> [[' | sil! exe 'unmap <buffer> ]]' | sil! exe 'unmap <buffer> []' | sil! exe 'unmap <buffer> ]['"
1d08aac0aea9 updated for version 7.1b
vimboss
parents: 1123
diff changeset
127 \."| sil! exe 'unmap <buffer> [m' | sil! exe 'unmap <buffer> ]m' | sil! exe 'unmap <buffer> [M' | sil! exe 'unmap <buffer> ]M'"
2225
dd5c1983e355 Runtime file updates.
Bram Moolenaar <bram@vim.org>
parents: 2034
diff changeset
128
dd5c1983e355 Runtime file updates.
Bram Moolenaar <bram@vim.org>
parents: 2034
diff changeset
129 if maparg("\<C-]>",'n') == ''
dd5c1983e355 Runtime file updates.
Bram Moolenaar <bram@vim.org>
parents: 2034
diff changeset
130 nnoremap <silent> <buffer> <C-]> :<C-U>exe v:count1."tag <C-R>=RubyCursorIdentifier()<CR>"<CR>
dd5c1983e355 Runtime file updates.
Bram Moolenaar <bram@vim.org>
parents: 2034
diff changeset
131 nnoremap <silent> <buffer> g<C-]> :<C-U>exe "tjump <C-R>=RubyCursorIdentifier()<CR>"<CR>
dd5c1983e355 Runtime file updates.
Bram Moolenaar <bram@vim.org>
parents: 2034
diff changeset
132 nnoremap <silent> <buffer> g] :<C-U>exe "tselect <C-R>=RubyCursorIdentifier()<CR>"<CR>
dd5c1983e355 Runtime file updates.
Bram Moolenaar <bram@vim.org>
parents: 2034
diff changeset
133 nnoremap <silent> <buffer> <C-W>] :<C-U>exe v:count1."stag <C-R>=RubyCursorIdentifier()<CR>"<CR>
dd5c1983e355 Runtime file updates.
Bram Moolenaar <bram@vim.org>
parents: 2034
diff changeset
134 nnoremap <silent> <buffer> <C-W><C-]> :<C-U>exe v:count1."stag <C-R>=RubyCursorIdentifier()<CR>"<CR>
dd5c1983e355 Runtime file updates.
Bram Moolenaar <bram@vim.org>
parents: 2034
diff changeset
135 nnoremap <silent> <buffer> <C-W>g<C-]> :<C-U>exe "stjump <C-R>=RubyCursorIdentifier()<CR>"<CR>
dd5c1983e355 Runtime file updates.
Bram Moolenaar <bram@vim.org>
parents: 2034
diff changeset
136 nnoremap <silent> <buffer> <C-W>g] :<C-U>exe "stselect <C-R>=RubyCursorIdentifier()<CR>"<CR>
dd5c1983e355 Runtime file updates.
Bram Moolenaar <bram@vim.org>
parents: 2034
diff changeset
137 nnoremap <silent> <buffer> <C-W>} :<C-U>exe "ptag <C-R>=RubyCursorIdentifier()<CR>"<CR>
dd5c1983e355 Runtime file updates.
Bram Moolenaar <bram@vim.org>
parents: 2034
diff changeset
138 nnoremap <silent> <buffer> <C-W>g} :<C-U>exe "ptjump <C-R>=RubyCursorIdentifier()<CR>"<CR>
dd5c1983e355 Runtime file updates.
Bram Moolenaar <bram@vim.org>
parents: 2034
diff changeset
139 let b:undo_ftplugin = b:undo_ftplugin
dd5c1983e355 Runtime file updates.
Bram Moolenaar <bram@vim.org>
parents: 2034
diff changeset
140 \."| sil! exe 'nunmap <buffer> <C-]>'| sil! exe 'nunmap <buffer> g<C-]>'| sil! exe 'nunmap <buffer> g]'"
dd5c1983e355 Runtime file updates.
Bram Moolenaar <bram@vim.org>
parents: 2034
diff changeset
141 \."| sil! exe 'nunmap <buffer> <C-W>]'| sil! exe 'nunmap <buffer> <C-W><C-]>'"
dd5c1983e355 Runtime file updates.
Bram Moolenaar <bram@vim.org>
parents: 2034
diff changeset
142 \."| sil! exe 'nunmap <buffer> <C-W>g<C-]>'| sil! exe 'nunmap <buffer> <C-W>g]'"
dd5c1983e355 Runtime file updates.
Bram Moolenaar <bram@vim.org>
parents: 2034
diff changeset
143 \."| sil! exe 'nunmap <buffer> <C-W>}'| sil! exe 'nunmap <buffer> <C-W>g}'"
dd5c1983e355 Runtime file updates.
Bram Moolenaar <bram@vim.org>
parents: 2034
diff changeset
144 endif
1215
1d08aac0aea9 updated for version 7.1b
vimboss
parents: 1123
diff changeset
145 endif
530
339999b511a0 updated for version 7.0148
vimboss
parents: 7
diff changeset
146
339999b511a0 updated for version 7.0148
vimboss
parents: 7
diff changeset
147 let &cpo = s:cpo_save
339999b511a0 updated for version 7.0148
vimboss
parents: 7
diff changeset
148 unlet s:cpo_save
339999b511a0 updated for version 7.0148
vimboss
parents: 7
diff changeset
149
1123
c4cd8ad60bee updated for version 7.1a
vimboss
parents: 867
diff changeset
150 if exists("g:did_ruby_ftplugin_functions")
c4cd8ad60bee updated for version 7.1a
vimboss
parents: 867
diff changeset
151 finish
c4cd8ad60bee updated for version 7.1a
vimboss
parents: 867
diff changeset
152 endif
c4cd8ad60bee updated for version 7.1a
vimboss
parents: 867
diff changeset
153 let g:did_ruby_ftplugin_functions = 1
c4cd8ad60bee updated for version 7.1a
vimboss
parents: 867
diff changeset
154
c4cd8ad60bee updated for version 7.1a
vimboss
parents: 867
diff changeset
155 function! RubyBalloonexpr()
c4cd8ad60bee updated for version 7.1a
vimboss
parents: 867
diff changeset
156 if !exists('s:ri_found')
c4cd8ad60bee updated for version 7.1a
vimboss
parents: 867
diff changeset
157 let s:ri_found = executable('ri')
c4cd8ad60bee updated for version 7.1a
vimboss
parents: 867
diff changeset
158 endif
c4cd8ad60bee updated for version 7.1a
vimboss
parents: 867
diff changeset
159 if s:ri_found
c4cd8ad60bee updated for version 7.1a
vimboss
parents: 867
diff changeset
160 let line = getline(v:beval_lnum)
c4cd8ad60bee updated for version 7.1a
vimboss
parents: 867
diff changeset
161 let b = matchstr(strpart(line,0,v:beval_col),'\%(\w\|[:.]\)*$')
c4cd8ad60bee updated for version 7.1a
vimboss
parents: 867
diff changeset
162 let a = substitute(matchstr(strpart(line,v:beval_col),'^\w*\%([?!]\|\s*=\)\?'),'\s\+','','g')
c4cd8ad60bee updated for version 7.1a
vimboss
parents: 867
diff changeset
163 let str = b.a
c4cd8ad60bee updated for version 7.1a
vimboss
parents: 867
diff changeset
164 let before = strpart(line,0,v:beval_col-strlen(b))
c4cd8ad60bee updated for version 7.1a
vimboss
parents: 867
diff changeset
165 let after = strpart(line,v:beval_col+strlen(a))
c4cd8ad60bee updated for version 7.1a
vimboss
parents: 867
diff changeset
166 if str =~ '^\.'
c4cd8ad60bee updated for version 7.1a
vimboss
parents: 867
diff changeset
167 let str = substitute(str,'^\.','#','g')
c4cd8ad60bee updated for version 7.1a
vimboss
parents: 867
diff changeset
168 if before =~ '\]\s*$'
c4cd8ad60bee updated for version 7.1a
vimboss
parents: 867
diff changeset
169 let str = 'Array'.str
c4cd8ad60bee updated for version 7.1a
vimboss
parents: 867
diff changeset
170 elseif before =~ '}\s*$'
c4cd8ad60bee updated for version 7.1a
vimboss
parents: 867
diff changeset
171 " False positives from blocks here
c4cd8ad60bee updated for version 7.1a
vimboss
parents: 867
diff changeset
172 let str = 'Hash'.str
c4cd8ad60bee updated for version 7.1a
vimboss
parents: 867
diff changeset
173 elseif before =~ "[\"'`]\\s*$" || before =~ '\$\d\+\s*$'
c4cd8ad60bee updated for version 7.1a
vimboss
parents: 867
diff changeset
174 let str = 'String'.str
c4cd8ad60bee updated for version 7.1a
vimboss
parents: 867
diff changeset
175 elseif before =~ '\$\d\+\.\d\+\s*$'
c4cd8ad60bee updated for version 7.1a
vimboss
parents: 867
diff changeset
176 let str = 'Float'.str
c4cd8ad60bee updated for version 7.1a
vimboss
parents: 867
diff changeset
177 elseif before =~ '\$\d\+\s*$'
c4cd8ad60bee updated for version 7.1a
vimboss
parents: 867
diff changeset
178 let str = 'Integer'.str
c4cd8ad60bee updated for version 7.1a
vimboss
parents: 867
diff changeset
179 elseif before =~ '/\s*$'
c4cd8ad60bee updated for version 7.1a
vimboss
parents: 867
diff changeset
180 let str = 'Regexp'.str
c4cd8ad60bee updated for version 7.1a
vimboss
parents: 867
diff changeset
181 else
c4cd8ad60bee updated for version 7.1a
vimboss
parents: 867
diff changeset
182 let str = substitute(str,'^#','.','')
c4cd8ad60bee updated for version 7.1a
vimboss
parents: 867
diff changeset
183 endif
c4cd8ad60bee updated for version 7.1a
vimboss
parents: 867
diff changeset
184 endif
c4cd8ad60bee updated for version 7.1a
vimboss
parents: 867
diff changeset
185 let str = substitute(str,'.*\.\s*to_f\s*\.\s*','Float#','')
c4cd8ad60bee updated for version 7.1a
vimboss
parents: 867
diff changeset
186 let str = substitute(str,'.*\.\s*to_i\%(nt\)\=\s*\.\s*','Integer#','')
c4cd8ad60bee updated for version 7.1a
vimboss
parents: 867
diff changeset
187 let str = substitute(str,'.*\.\s*to_s\%(tr\)\=\s*\.\s*','String#','')
c4cd8ad60bee updated for version 7.1a
vimboss
parents: 867
diff changeset
188 let str = substitute(str,'.*\.\s*to_sym\s*\.\s*','Symbol#','')
c4cd8ad60bee updated for version 7.1a
vimboss
parents: 867
diff changeset
189 let str = substitute(str,'.*\.\s*to_a\%(ry\)\=\s*\.\s*','Array#','')
c4cd8ad60bee updated for version 7.1a
vimboss
parents: 867
diff changeset
190 let str = substitute(str,'.*\.\s*to_proc\s*\.\s*','Proc#','')
c4cd8ad60bee updated for version 7.1a
vimboss
parents: 867
diff changeset
191 if str !~ '^\w'
c4cd8ad60bee updated for version 7.1a
vimboss
parents: 867
diff changeset
192 return ''
c4cd8ad60bee updated for version 7.1a
vimboss
parents: 867
diff changeset
193 endif
c4cd8ad60bee updated for version 7.1a
vimboss
parents: 867
diff changeset
194 silent! let res = substitute(system("ri -f simple -T \"".str.'"'),'\n$','','')
1215
1d08aac0aea9 updated for version 7.1b
vimboss
parents: 1123
diff changeset
195 if res =~ '^Nothing known about' || res =~ '^Bad argument:' || res =~ '^More than one method'
1123
c4cd8ad60bee updated for version 7.1a
vimboss
parents: 867
diff changeset
196 return ''
c4cd8ad60bee updated for version 7.1a
vimboss
parents: 867
diff changeset
197 endif
c4cd8ad60bee updated for version 7.1a
vimboss
parents: 867
diff changeset
198 return res
c4cd8ad60bee updated for version 7.1a
vimboss
parents: 867
diff changeset
199 else
c4cd8ad60bee updated for version 7.1a
vimboss
parents: 867
diff changeset
200 return ""
c4cd8ad60bee updated for version 7.1a
vimboss
parents: 867
diff changeset
201 endif
c4cd8ad60bee updated for version 7.1a
vimboss
parents: 867
diff changeset
202 endfunction
c4cd8ad60bee updated for version 7.1a
vimboss
parents: 867
diff changeset
203
2225
dd5c1983e355 Runtime file updates.
Bram Moolenaar <bram@vim.org>
parents: 2034
diff changeset
204 function! s:searchsyn(pattern,syn,flags,mode)
1215
1d08aac0aea9 updated for version 7.1b
vimboss
parents: 1123
diff changeset
205 norm! m'
2225
dd5c1983e355 Runtime file updates.
Bram Moolenaar <bram@vim.org>
parents: 2034
diff changeset
206 if a:mode ==# 'v'
dd5c1983e355 Runtime file updates.
Bram Moolenaar <bram@vim.org>
parents: 2034
diff changeset
207 norm! gv
dd5c1983e355 Runtime file updates.
Bram Moolenaar <bram@vim.org>
parents: 2034
diff changeset
208 endif
1215
1d08aac0aea9 updated for version 7.1b
vimboss
parents: 1123
diff changeset
209 let i = 0
1d08aac0aea9 updated for version 7.1b
vimboss
parents: 1123
diff changeset
210 let cnt = v:count ? v:count : 1
1d08aac0aea9 updated for version 7.1b
vimboss
parents: 1123
diff changeset
211 while i < cnt
1d08aac0aea9 updated for version 7.1b
vimboss
parents: 1123
diff changeset
212 let i = i + 1
1d08aac0aea9 updated for version 7.1b
vimboss
parents: 1123
diff changeset
213 let line = line('.')
1d08aac0aea9 updated for version 7.1b
vimboss
parents: 1123
diff changeset
214 let col = col('.')
1d08aac0aea9 updated for version 7.1b
vimboss
parents: 1123
diff changeset
215 let pos = search(a:pattern,'W'.a:flags)
1d08aac0aea9 updated for version 7.1b
vimboss
parents: 1123
diff changeset
216 while pos != 0 && s:synname() !~# a:syn
1d08aac0aea9 updated for version 7.1b
vimboss
parents: 1123
diff changeset
217 let pos = search(a:pattern,'W'.a:flags)
1d08aac0aea9 updated for version 7.1b
vimboss
parents: 1123
diff changeset
218 endwhile
1d08aac0aea9 updated for version 7.1b
vimboss
parents: 1123
diff changeset
219 if pos == 0
1d08aac0aea9 updated for version 7.1b
vimboss
parents: 1123
diff changeset
220 call cursor(line,col)
1d08aac0aea9 updated for version 7.1b
vimboss
parents: 1123
diff changeset
221 return
1d08aac0aea9 updated for version 7.1b
vimboss
parents: 1123
diff changeset
222 endif
1d08aac0aea9 updated for version 7.1b
vimboss
parents: 1123
diff changeset
223 endwhile
1d08aac0aea9 updated for version 7.1b
vimboss
parents: 1123
diff changeset
224 endfunction
1d08aac0aea9 updated for version 7.1b
vimboss
parents: 1123
diff changeset
225
1d08aac0aea9 updated for version 7.1b
vimboss
parents: 1123
diff changeset
226 function! s:synname()
1d08aac0aea9 updated for version 7.1b
vimboss
parents: 1123
diff changeset
227 return synIDattr(synID(line('.'),col('.'),0),'name')
1d08aac0aea9 updated for version 7.1b
vimboss
parents: 1123
diff changeset
228 endfunction
1123
c4cd8ad60bee updated for version 7.1a
vimboss
parents: 867
diff changeset
229
2225
dd5c1983e355 Runtime file updates.
Bram Moolenaar <bram@vim.org>
parents: 2034
diff changeset
230 function! RubyCursorIdentifier()
dd5c1983e355 Runtime file updates.
Bram Moolenaar <bram@vim.org>
parents: 2034
diff changeset
231 let asciicode = '\%(\w\|[]})\"'."'".']\)\@<!\%(?\%(\\M-\\C-\|\\C-\\M-\|\\M-\\c\|\\c\\M-\|\\c\|\\C-\|\\M-\)\=\%(\\\o\{1,3}\|\\x\x\{1,2}\|\\\=\S\)\)'
dd5c1983e355 Runtime file updates.
Bram Moolenaar <bram@vim.org>
parents: 2034
diff changeset
232 let number = '\%(\%(\w\|[]})\"'."'".']\s*\)\@<!-\)\=\%(\<[[:digit:]_]\+\%(\.[[:digit:]_]\+\)\=\%([Ee][[:digit:]_]\+\)\=\>\|\<0[xXbBoOdD][[:xdigit:]_]\+\>\)\|'.asciicode
dd5c1983e355 Runtime file updates.
Bram Moolenaar <bram@vim.org>
parents: 2034
diff changeset
233 let operator = '\%(\[\]\|<<\|<=>\|[!<>]=\=\|===\=\|[!=]\~\|>>\|\*\*\|\.\.\.\=\|=>\|[~^&|*/%+-]\)'
dd5c1983e355 Runtime file updates.
Bram Moolenaar <bram@vim.org>
parents: 2034
diff changeset
234 let method = '\%(\<[_a-zA-Z]\w*\>\%([?!]\|\s*=>\@!\)\=\)'
dd5c1983e355 Runtime file updates.
Bram Moolenaar <bram@vim.org>
parents: 2034
diff changeset
235 let global = '$\%([!$&"'."'".'*+,./:;<=>?@\`~]\|-\=\w\+\>\)'
dd5c1983e355 Runtime file updates.
Bram Moolenaar <bram@vim.org>
parents: 2034
diff changeset
236 let symbolizable = '\%(\%(@@\=\)\w\+\>\|'.global.'\|'.method.'\|'.operator.'\)'
dd5c1983e355 Runtime file updates.
Bram Moolenaar <bram@vim.org>
parents: 2034
diff changeset
237 let pattern = '\C\s*\%('.number.'\|\%(:\@<!:\)\='.symbolizable.'\)'
dd5c1983e355 Runtime file updates.
Bram Moolenaar <bram@vim.org>
parents: 2034
diff changeset
238 let [lnum, col] = searchpos(pattern,'bcn',line('.'))
dd5c1983e355 Runtime file updates.
Bram Moolenaar <bram@vim.org>
parents: 2034
diff changeset
239 let raw = matchstr(getline('.')[col-1 : ],pattern)
dd5c1983e355 Runtime file updates.
Bram Moolenaar <bram@vim.org>
parents: 2034
diff changeset
240 let stripped = substitute(substitute(raw,'\s\+=$','=',''),'^\s*:\=','','')
dd5c1983e355 Runtime file updates.
Bram Moolenaar <bram@vim.org>
parents: 2034
diff changeset
241 return stripped == '' ? expand("<cword>") : stripped
dd5c1983e355 Runtime file updates.
Bram Moolenaar <bram@vim.org>
parents: 2034
diff changeset
242 endfunction
dd5c1983e355 Runtime file updates.
Bram Moolenaar <bram@vim.org>
parents: 2034
diff changeset
243
530
339999b511a0 updated for version 7.0148
vimboss
parents: 7
diff changeset
244 "
339999b511a0 updated for version 7.0148
vimboss
parents: 7
diff changeset
245 " Instructions for enabling "matchit" support:
339999b511a0 updated for version 7.0148
vimboss
parents: 7
diff changeset
246 "
339999b511a0 updated for version 7.0148
vimboss
parents: 7
diff changeset
247 " 1. Look for the latest "matchit" plugin at
339999b511a0 updated for version 7.0148
vimboss
parents: 7
diff changeset
248 "
1123
c4cd8ad60bee updated for version 7.1a
vimboss
parents: 867
diff changeset
249 " http://www.vim.org/scripts/script.php?script_id=39
530
339999b511a0 updated for version 7.0148
vimboss
parents: 7
diff changeset
250 "
339999b511a0 updated for version 7.0148
vimboss
parents: 7
diff changeset
251 " It is also packaged with Vim, in the $VIMRUNTIME/macros directory.
339999b511a0 updated for version 7.0148
vimboss
parents: 7
diff changeset
252 "
339999b511a0 updated for version 7.0148
vimboss
parents: 7
diff changeset
253 " 2. Copy "matchit.txt" into a "doc" directory (e.g. $HOME/.vim/doc).
339999b511a0 updated for version 7.0148
vimboss
parents: 7
diff changeset
254 "
339999b511a0 updated for version 7.0148
vimboss
parents: 7
diff changeset
255 " 3. Copy "matchit.vim" into a "plugin" directory (e.g. $HOME/.vim/plugin).
339999b511a0 updated for version 7.0148
vimboss
parents: 7
diff changeset
256 "
339999b511a0 updated for version 7.0148
vimboss
parents: 7
diff changeset
257 " 4. Ensure this file (ftplugin/ruby.vim) is installed.
339999b511a0 updated for version 7.0148
vimboss
parents: 7
diff changeset
258 "
339999b511a0 updated for version 7.0148
vimboss
parents: 7
diff changeset
259 " 5. Ensure you have this line in your $HOME/.vimrc:
1123
c4cd8ad60bee updated for version 7.1a
vimboss
parents: 867
diff changeset
260 " filetype plugin on
530
339999b511a0 updated for version 7.0148
vimboss
parents: 7
diff changeset
261 "
339999b511a0 updated for version 7.0148
vimboss
parents: 7
diff changeset
262 " 6. Restart Vim and create the matchit documentation:
339999b511a0 updated for version 7.0148
vimboss
parents: 7
diff changeset
263 "
1123
c4cd8ad60bee updated for version 7.1a
vimboss
parents: 867
diff changeset
264 " :helptags ~/.vim/doc
530
339999b511a0 updated for version 7.0148
vimboss
parents: 7
diff changeset
265 "
339999b511a0 updated for version 7.0148
vimboss
parents: 7
diff changeset
266 " Now you can do ":help matchit", and you should be able to use "%" on Ruby
1123
c4cd8ad60bee updated for version 7.1a
vimboss
parents: 867
diff changeset
267 " keywords. Try ":echo b:match_words" to be sure.
530
339999b511a0 updated for version 7.0148
vimboss
parents: 7
diff changeset
268 "
1123
c4cd8ad60bee updated for version 7.1a
vimboss
parents: 867
diff changeset
269 " Thanks to Mark J. Reed for the instructions. See ":help vimrc" for the
530
339999b511a0 updated for version 7.0148
vimboss
parents: 7
diff changeset
270 " locations of plugin directories, etc., as there are several options, and it
339999b511a0 updated for version 7.0148
vimboss
parents: 7
diff changeset
271 " differs on Windows. Email gsinclair@soyabean.com.au if you need help.
339999b511a0 updated for version 7.0148
vimboss
parents: 7
diff changeset
272 "
339999b511a0 updated for version 7.0148
vimboss
parents: 7
diff changeset
273
1621
82b5078be2dd updated for version 7.2a
vimboss
parents: 1215
diff changeset
274 " vim: nowrap sw=2 sts=2 ts=8: