annotate 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
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>
831
f24a95dae8ee updated for version 7.0d05
vimboss
parents: 829
diff changeset
4 " Info: $Id$
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
339999b511a0 updated for version 7.0148
vimboss
parents: 7
diff changeset
72 if !exists("s:rubypath")
1123
c4cd8ad60bee updated for version 7.1a
vimboss
parents: 867
diff changeset
73 if has("ruby") && has("win32")
c4cd8ad60bee updated for version 7.1a
vimboss
parents: 867
diff changeset
74 ruby VIM::command( 'let s:rubypath = "%s"' % ($: + begin; require %q{rubygems}; Gem.all_load_paths.sort.uniq; rescue LoadError; []; end).join(%q{,}) )
c4cd8ad60bee updated for version 7.1a
vimboss
parents: 867
diff changeset
75 let s:rubypath = '.,' . substitute(s:rubypath, '\%(^\|,\)\.\%(,\|$\)', ',,', '')
c4cd8ad60bee updated for version 7.1a
vimboss
parents: 867
diff changeset
76 elseif executable("ruby")
548
f43150a669dc updated for version 7.0155
vimboss
parents: 530
diff changeset
77 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
78 if &shellxquote == "'"
548
f43150a669dc updated for version 7.0155
vimboss
parents: 530
diff changeset
79 let s:rubypath = system('ruby -e "' . s:code . '"')
530
339999b511a0 updated for version 7.0148
vimboss
parents: 7
diff changeset
80 else
548
f43150a669dc updated for version 7.0155
vimboss
parents: 530
diff changeset
81 let s:rubypath = system("ruby -e '" . s:code . "'")
530
339999b511a0 updated for version 7.0148
vimboss
parents: 7
diff changeset
82 endif
548
f43150a669dc updated for version 7.0155
vimboss
parents: 530
diff changeset
83 let s:rubypath = '.,' . substitute(s:rubypath, '\%(^\|,\)\.\%(,\|$\)', ',,', '')
530
339999b511a0 updated for version 7.0148
vimboss
parents: 7
diff changeset
84 else
339999b511a0 updated for version 7.0148
vimboss
parents: 7
diff changeset
85 " 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
86 " current directory and the directory of the current file.
339999b511a0 updated for version 7.0148
vimboss
parents: 7
diff changeset
87 let s:rubypath = ".,,"
339999b511a0 updated for version 7.0148
vimboss
parents: 7
diff changeset
88 endif
339999b511a0 updated for version 7.0148
vimboss
parents: 7
diff changeset
89 endif
339999b511a0 updated for version 7.0148
vimboss
parents: 7
diff changeset
90
339999b511a0 updated for version 7.0148
vimboss
parents: 7
diff changeset
91 let &l:path = s:rubypath
339999b511a0 updated for version 7.0148
vimboss
parents: 7
diff changeset
92
339999b511a0 updated for version 7.0148
vimboss
parents: 7
diff changeset
93 if has("gui_win32") && !exists("b:browsefilter")
339999b511a0 updated for version 7.0148
vimboss
parents: 7
diff changeset
94 let b:browsefilter = "Ruby Source Files (*.rb)\t*.rb\n" .
1123
c4cd8ad60bee updated for version 7.1a
vimboss
parents: 867
diff changeset
95 \ "All Files (*.*)\t*.*\n"
530
339999b511a0 updated for version 7.0148
vimboss
parents: 7
diff changeset
96 endif
339999b511a0 updated for version 7.0148
vimboss
parents: 7
diff changeset
97
1123
c4cd8ad60bee updated for version 7.1a
vimboss
parents: 867
diff changeset
98 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
99 \."| unlet! b:browsefilter b:match_ignorecase b:match_words b:match_skip"
1d08aac0aea9 updated for version 7.1b
vimboss
parents: 1123
diff changeset
100 \."| if exists('&ofu') && has('ruby') | setl ofu< | endif"
1d08aac0aea9 updated for version 7.1b
vimboss
parents: 1123
diff changeset
101 \."| if has('balloon_eval') && exists('+bexpr') | setl bexpr< | endif"
1d08aac0aea9 updated for version 7.1b
vimboss
parents: 1123
diff changeset
102
1d08aac0aea9 updated for version 7.1b
vimboss
parents: 1123
diff changeset
103 if !exists("g:no_plugin_maps") && !exists("g:no_ruby_maps")
1d08aac0aea9 updated for version 7.1b
vimboss
parents: 1123
diff changeset
104
1d08aac0aea9 updated for version 7.1b
vimboss
parents: 1123
diff changeset
105 noremap <silent> <buffer> [m :<C-U>call <SID>searchsyn('\<def\>','rubyDefine','b')<CR>
1d08aac0aea9 updated for version 7.1b
vimboss
parents: 1123
diff changeset
106 noremap <silent> <buffer> ]m :<C-U>call <SID>searchsyn('\<def\>','rubyDefine','')<CR>
1d08aac0aea9 updated for version 7.1b
vimboss
parents: 1123
diff changeset
107 noremap <silent> <buffer> [M :<C-U>call <SID>searchsyn('\<end\>','rubyDefine','b')<CR>
1d08aac0aea9 updated for version 7.1b
vimboss
parents: 1123
diff changeset
108 noremap <silent> <buffer> ]M :<C-U>call <SID>searchsyn('\<end\>','rubyDefine','')<CR>
1d08aac0aea9 updated for version 7.1b
vimboss
parents: 1123
diff changeset
109
1d08aac0aea9 updated for version 7.1b
vimboss
parents: 1123
diff changeset
110 noremap <silent> <buffer> [[ :<C-U>call <SID>searchsyn('\<\%(class\<Bar>module\)\>','rubyModule\<Bar>rubyClass','b')<CR>
1d08aac0aea9 updated for version 7.1b
vimboss
parents: 1123
diff changeset
111 noremap <silent> <buffer> ]] :<C-U>call <SID>searchsyn('\<\%(class\<Bar>module\)\>','rubyModule\<Bar>rubyClass','')<CR>
1d08aac0aea9 updated for version 7.1b
vimboss
parents: 1123
diff changeset
112 noremap <silent> <buffer> [] :<C-U>call <SID>searchsyn('\<end\>','rubyModule\<Bar>rubyClass','b')<CR>
1d08aac0aea9 updated for version 7.1b
vimboss
parents: 1123
diff changeset
113 noremap <silent> <buffer> ][ :<C-U>call <SID>searchsyn('\<end\>','rubyModule\<Bar>rubyClass','')<CR>
1d08aac0aea9 updated for version 7.1b
vimboss
parents: 1123
diff changeset
114
1d08aac0aea9 updated for version 7.1b
vimboss
parents: 1123
diff changeset
115 let b:undo_ftplugin = b:undo_ftplugin
1d08aac0aea9 updated for version 7.1b
vimboss
parents: 1123
diff changeset
116 \."| 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
117 \."| sil! exe 'unmap <buffer> [m' | sil! exe 'unmap <buffer> ]m' | sil! exe 'unmap <buffer> [M' | sil! exe 'unmap <buffer> ]M'"
1d08aac0aea9 updated for version 7.1b
vimboss
parents: 1123
diff changeset
118 endif
530
339999b511a0 updated for version 7.0148
vimboss
parents: 7
diff changeset
119
339999b511a0 updated for version 7.0148
vimboss
parents: 7
diff changeset
120 let &cpo = s:cpo_save
339999b511a0 updated for version 7.0148
vimboss
parents: 7
diff changeset
121 unlet s:cpo_save
339999b511a0 updated for version 7.0148
vimboss
parents: 7
diff changeset
122
1123
c4cd8ad60bee updated for version 7.1a
vimboss
parents: 867
diff changeset
123 if exists("g:did_ruby_ftplugin_functions")
c4cd8ad60bee updated for version 7.1a
vimboss
parents: 867
diff changeset
124 finish
c4cd8ad60bee updated for version 7.1a
vimboss
parents: 867
diff changeset
125 endif
c4cd8ad60bee updated for version 7.1a
vimboss
parents: 867
diff changeset
126 let g:did_ruby_ftplugin_functions = 1
c4cd8ad60bee updated for version 7.1a
vimboss
parents: 867
diff changeset
127
c4cd8ad60bee updated for version 7.1a
vimboss
parents: 867
diff changeset
128 function! RubyBalloonexpr()
c4cd8ad60bee updated for version 7.1a
vimboss
parents: 867
diff changeset
129 if !exists('s:ri_found')
c4cd8ad60bee updated for version 7.1a
vimboss
parents: 867
diff changeset
130 let s:ri_found = executable('ri')
c4cd8ad60bee updated for version 7.1a
vimboss
parents: 867
diff changeset
131 endif
c4cd8ad60bee updated for version 7.1a
vimboss
parents: 867
diff changeset
132 if s:ri_found
c4cd8ad60bee updated for version 7.1a
vimboss
parents: 867
diff changeset
133 let line = getline(v:beval_lnum)
c4cd8ad60bee updated for version 7.1a
vimboss
parents: 867
diff changeset
134 let b = matchstr(strpart(line,0,v:beval_col),'\%(\w\|[:.]\)*$')
c4cd8ad60bee updated for version 7.1a
vimboss
parents: 867
diff changeset
135 let a = substitute(matchstr(strpart(line,v:beval_col),'^\w*\%([?!]\|\s*=\)\?'),'\s\+','','g')
c4cd8ad60bee updated for version 7.1a
vimboss
parents: 867
diff changeset
136 let str = b.a
c4cd8ad60bee updated for version 7.1a
vimboss
parents: 867
diff changeset
137 let before = strpart(line,0,v:beval_col-strlen(b))
c4cd8ad60bee updated for version 7.1a
vimboss
parents: 867
diff changeset
138 let after = strpart(line,v:beval_col+strlen(a))
c4cd8ad60bee updated for version 7.1a
vimboss
parents: 867
diff changeset
139 if str =~ '^\.'
c4cd8ad60bee updated for version 7.1a
vimboss
parents: 867
diff changeset
140 let str = substitute(str,'^\.','#','g')
c4cd8ad60bee updated for version 7.1a
vimboss
parents: 867
diff changeset
141 if before =~ '\]\s*$'
c4cd8ad60bee updated for version 7.1a
vimboss
parents: 867
diff changeset
142 let str = 'Array'.str
c4cd8ad60bee updated for version 7.1a
vimboss
parents: 867
diff changeset
143 elseif before =~ '}\s*$'
c4cd8ad60bee updated for version 7.1a
vimboss
parents: 867
diff changeset
144 " False positives from blocks here
c4cd8ad60bee updated for version 7.1a
vimboss
parents: 867
diff changeset
145 let str = 'Hash'.str
c4cd8ad60bee updated for version 7.1a
vimboss
parents: 867
diff changeset
146 elseif before =~ "[\"'`]\\s*$" || before =~ '\$\d\+\s*$'
c4cd8ad60bee updated for version 7.1a
vimboss
parents: 867
diff changeset
147 let str = 'String'.str
c4cd8ad60bee updated for version 7.1a
vimboss
parents: 867
diff changeset
148 elseif before =~ '\$\d\+\.\d\+\s*$'
c4cd8ad60bee updated for version 7.1a
vimboss
parents: 867
diff changeset
149 let str = 'Float'.str
c4cd8ad60bee updated for version 7.1a
vimboss
parents: 867
diff changeset
150 elseif before =~ '\$\d\+\s*$'
c4cd8ad60bee updated for version 7.1a
vimboss
parents: 867
diff changeset
151 let str = 'Integer'.str
c4cd8ad60bee updated for version 7.1a
vimboss
parents: 867
diff changeset
152 elseif before =~ '/\s*$'
c4cd8ad60bee updated for version 7.1a
vimboss
parents: 867
diff changeset
153 let str = 'Regexp'.str
c4cd8ad60bee updated for version 7.1a
vimboss
parents: 867
diff changeset
154 else
c4cd8ad60bee updated for version 7.1a
vimboss
parents: 867
diff changeset
155 let str = substitute(str,'^#','.','')
c4cd8ad60bee updated for version 7.1a
vimboss
parents: 867
diff changeset
156 endif
c4cd8ad60bee updated for version 7.1a
vimboss
parents: 867
diff changeset
157 endif
c4cd8ad60bee updated for version 7.1a
vimboss
parents: 867
diff changeset
158 let str = substitute(str,'.*\.\s*to_f\s*\.\s*','Float#','')
c4cd8ad60bee updated for version 7.1a
vimboss
parents: 867
diff changeset
159 let str = substitute(str,'.*\.\s*to_i\%(nt\)\=\s*\.\s*','Integer#','')
c4cd8ad60bee updated for version 7.1a
vimboss
parents: 867
diff changeset
160 let str = substitute(str,'.*\.\s*to_s\%(tr\)\=\s*\.\s*','String#','')
c4cd8ad60bee updated for version 7.1a
vimboss
parents: 867
diff changeset
161 let str = substitute(str,'.*\.\s*to_sym\s*\.\s*','Symbol#','')
c4cd8ad60bee updated for version 7.1a
vimboss
parents: 867
diff changeset
162 let str = substitute(str,'.*\.\s*to_a\%(ry\)\=\s*\.\s*','Array#','')
c4cd8ad60bee updated for version 7.1a
vimboss
parents: 867
diff changeset
163 let str = substitute(str,'.*\.\s*to_proc\s*\.\s*','Proc#','')
c4cd8ad60bee updated for version 7.1a
vimboss
parents: 867
diff changeset
164 if str !~ '^\w'
c4cd8ad60bee updated for version 7.1a
vimboss
parents: 867
diff changeset
165 return ''
c4cd8ad60bee updated for version 7.1a
vimboss
parents: 867
diff changeset
166 endif
c4cd8ad60bee updated for version 7.1a
vimboss
parents: 867
diff changeset
167 silent! let res = substitute(system("ri -f simple -T \"".str.'"'),'\n$','','')
1215
1d08aac0aea9 updated for version 7.1b
vimboss
parents: 1123
diff changeset
168 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
169 return ''
c4cd8ad60bee updated for version 7.1a
vimboss
parents: 867
diff changeset
170 endif
c4cd8ad60bee updated for version 7.1a
vimboss
parents: 867
diff changeset
171 return res
c4cd8ad60bee updated for version 7.1a
vimboss
parents: 867
diff changeset
172 else
c4cd8ad60bee updated for version 7.1a
vimboss
parents: 867
diff changeset
173 return ""
c4cd8ad60bee updated for version 7.1a
vimboss
parents: 867
diff changeset
174 endif
c4cd8ad60bee updated for version 7.1a
vimboss
parents: 867
diff changeset
175 endfunction
c4cd8ad60bee updated for version 7.1a
vimboss
parents: 867
diff changeset
176
1215
1d08aac0aea9 updated for version 7.1b
vimboss
parents: 1123
diff changeset
177 function! s:searchsyn(pattern,syn,flags)
1d08aac0aea9 updated for version 7.1b
vimboss
parents: 1123
diff changeset
178 norm! m'
1d08aac0aea9 updated for version 7.1b
vimboss
parents: 1123
diff changeset
179 let i = 0
1d08aac0aea9 updated for version 7.1b
vimboss
parents: 1123
diff changeset
180 let cnt = v:count ? v:count : 1
1d08aac0aea9 updated for version 7.1b
vimboss
parents: 1123
diff changeset
181 while i < cnt
1d08aac0aea9 updated for version 7.1b
vimboss
parents: 1123
diff changeset
182 let i = i + 1
1d08aac0aea9 updated for version 7.1b
vimboss
parents: 1123
diff changeset
183 let line = line('.')
1d08aac0aea9 updated for version 7.1b
vimboss
parents: 1123
diff changeset
184 let col = col('.')
1d08aac0aea9 updated for version 7.1b
vimboss
parents: 1123
diff changeset
185 let pos = search(a:pattern,'W'.a:flags)
1d08aac0aea9 updated for version 7.1b
vimboss
parents: 1123
diff changeset
186 while pos != 0 && s:synname() !~# a:syn
1d08aac0aea9 updated for version 7.1b
vimboss
parents: 1123
diff changeset
187 let pos = search(a:pattern,'W'.a:flags)
1d08aac0aea9 updated for version 7.1b
vimboss
parents: 1123
diff changeset
188 endwhile
1d08aac0aea9 updated for version 7.1b
vimboss
parents: 1123
diff changeset
189 if pos == 0
1d08aac0aea9 updated for version 7.1b
vimboss
parents: 1123
diff changeset
190 call cursor(line,col)
1d08aac0aea9 updated for version 7.1b
vimboss
parents: 1123
diff changeset
191 return
1d08aac0aea9 updated for version 7.1b
vimboss
parents: 1123
diff changeset
192 endif
1d08aac0aea9 updated for version 7.1b
vimboss
parents: 1123
diff changeset
193 endwhile
1d08aac0aea9 updated for version 7.1b
vimboss
parents: 1123
diff changeset
194 endfunction
1d08aac0aea9 updated for version 7.1b
vimboss
parents: 1123
diff changeset
195
1d08aac0aea9 updated for version 7.1b
vimboss
parents: 1123
diff changeset
196 function! s:synname()
1d08aac0aea9 updated for version 7.1b
vimboss
parents: 1123
diff changeset
197 return synIDattr(synID(line('.'),col('.'),0),'name')
1d08aac0aea9 updated for version 7.1b
vimboss
parents: 1123
diff changeset
198 endfunction
1123
c4cd8ad60bee updated for version 7.1a
vimboss
parents: 867
diff changeset
199
530
339999b511a0 updated for version 7.0148
vimboss
parents: 7
diff changeset
200 "
339999b511a0 updated for version 7.0148
vimboss
parents: 7
diff changeset
201 " Instructions for enabling "matchit" support:
339999b511a0 updated for version 7.0148
vimboss
parents: 7
diff changeset
202 "
339999b511a0 updated for version 7.0148
vimboss
parents: 7
diff changeset
203 " 1. Look for the latest "matchit" plugin at
339999b511a0 updated for version 7.0148
vimboss
parents: 7
diff changeset
204 "
1123
c4cd8ad60bee updated for version 7.1a
vimboss
parents: 867
diff changeset
205 " http://www.vim.org/scripts/script.php?script_id=39
530
339999b511a0 updated for version 7.0148
vimboss
parents: 7
diff changeset
206 "
339999b511a0 updated for version 7.0148
vimboss
parents: 7
diff changeset
207 " It is also packaged with Vim, in the $VIMRUNTIME/macros directory.
339999b511a0 updated for version 7.0148
vimboss
parents: 7
diff changeset
208 "
339999b511a0 updated for version 7.0148
vimboss
parents: 7
diff changeset
209 " 2. Copy "matchit.txt" into a "doc" directory (e.g. $HOME/.vim/doc).
339999b511a0 updated for version 7.0148
vimboss
parents: 7
diff changeset
210 "
339999b511a0 updated for version 7.0148
vimboss
parents: 7
diff changeset
211 " 3. Copy "matchit.vim" into a "plugin" directory (e.g. $HOME/.vim/plugin).
339999b511a0 updated for version 7.0148
vimboss
parents: 7
diff changeset
212 "
339999b511a0 updated for version 7.0148
vimboss
parents: 7
diff changeset
213 " 4. Ensure this file (ftplugin/ruby.vim) is installed.
339999b511a0 updated for version 7.0148
vimboss
parents: 7
diff changeset
214 "
339999b511a0 updated for version 7.0148
vimboss
parents: 7
diff changeset
215 " 5. Ensure you have this line in your $HOME/.vimrc:
1123
c4cd8ad60bee updated for version 7.1a
vimboss
parents: 867
diff changeset
216 " filetype plugin on
530
339999b511a0 updated for version 7.0148
vimboss
parents: 7
diff changeset
217 "
339999b511a0 updated for version 7.0148
vimboss
parents: 7
diff changeset
218 " 6. Restart Vim and create the matchit documentation:
339999b511a0 updated for version 7.0148
vimboss
parents: 7
diff changeset
219 "
1123
c4cd8ad60bee updated for version 7.1a
vimboss
parents: 867
diff changeset
220 " :helptags ~/.vim/doc
530
339999b511a0 updated for version 7.0148
vimboss
parents: 7
diff changeset
221 "
339999b511a0 updated for version 7.0148
vimboss
parents: 7
diff changeset
222 " 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
223 " keywords. Try ":echo b:match_words" to be sure.
530
339999b511a0 updated for version 7.0148
vimboss
parents: 7
diff changeset
224 "
1123
c4cd8ad60bee updated for version 7.1a
vimboss
parents: 867
diff changeset
225 " 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
226 " locations of plugin directories, etc., as there are several options, and it
339999b511a0 updated for version 7.0148
vimboss
parents: 7
diff changeset
227 " differs on Windows. Email gsinclair@soyabean.com.au if you need help.
339999b511a0 updated for version 7.0148
vimboss
parents: 7
diff changeset
228 "
339999b511a0 updated for version 7.0148
vimboss
parents: 7
diff changeset
229
339999b511a0 updated for version 7.0148
vimboss
parents: 7
diff changeset
230 " vim: nowrap sw=2 sts=2 ts=8 ff=unix: