1
1
" Vim plug-in
2
2
" Maintainer: Peter Odding <peter@peterodding.com>
3
- " Last Change: June 3 , 2010
3
+ " Last Change: June 8 , 2010
4
4
" URL: http://peterodding.com/code/vim/pyref
5
5
" License: MIT
6
- " Version: 0.4
6
+ " Version: 0.5
7
7
8
8
" Support for automatic update using the GLVS plug-in.
9
9
" GetLatestVimScripts: 3104 1 :AutoInstall: pyref.zip
@@ -132,7 +132,12 @@ function! s:PyRef() " {{{1
132
132
let lines = []
133
133
echoerr " pyref.vim: Failed to read index file! (" . indexfile . " )"
134
134
endtry
135
- if s: JumpToEntry (lines , ' ^\(module-\|exceptions\.\)\?' . pattern . ' \t' )
135
+ if s: JumpToEntry (lines , ' ^\C\(module-\|exceptions\.\)\?' . pattern . ' \t' )
136
+ return
137
+ endif
138
+
139
+ " Search for a substring match on word boundaries.
140
+ if s: JumpToEntry (lines , ' \C\<' . pattern . ' \>.*\t' )
136
141
return
137
142
endif
138
143
@@ -149,7 +154,7 @@ function! s:PyRef() " {{{1
149
154
endfor
150
155
151
156
" Search for a substring match in the index.
152
- if s: JumpToEntry (lines , pattern)
157
+ if s: JumpToEntry (lines , ' \C ' . pattern . ' .*\t ' )
153
158
return
154
159
endif
155
160
@@ -160,7 +165,7 @@ function! s:PyRef() " {{{1
160
165
let parts = split (ident, ' \.' )
161
166
while len (parts) > 1
162
167
call remove (parts, 0 )
163
- let pattern = join (parts, ' \.' ) . ' $'
168
+ let pattern = ' \C\< ' . join (parts, ' \.' ) . ' $'
164
169
if s: JumpToEntry (lines , pattern)
165
170
return
166
171
endif
@@ -175,12 +180,15 @@ endfunction
175
180
" to recognize calls to methods of objects that are one of Python's standard
176
181
" types: strings, lists, dictionaries and file handles.
177
182
let s: object_methods = [
178
- \ [' library/stdtypes.html#str.%s' , ' \.\@<=\(capitalize\|center\|count\|decode\|encode\|endswith\|expandtabs\|find\|format\|index\|isalnum\|isalpha\|isdigit\|islower\|isspace\|istitle\|isupper\|join\|ljust\|lower\|lstrip\|partition\|replace\|rfind\|rindex\|rjust\|rpartition\|rsplit\|rstrip\|split\|splitlines\|startswith\|strip\|swapcase\|title\|translate\|upper\|zfill\)$' ],
179
- \ [' tutorial/datastructures.html#more-on-lists' , ' \.\@<=\(append\|count\|extend\|index\|insert\|pop\|remove\|reverse\|sort\)$' ],
180
- \ [' library/stdtypes.html#dict.%s' , ' \.\@<=\(clear\|copy\|fromkeys\|get\|has_key\|items\|iteritems\|iterkeys\|itervalues\|keys\|pop\|popitem\|setdefault\|update\|values\)$' ],
181
- \ [' library/stdtypes.html#file.%s' , ' \.\@<=\(close\|closed\|encoding\|errors\|fileno\|flush\|isatty\|mode\|name\|newlines\|next\|read\|readinto\|readline\|readlines\|seek\|softspace\|tell\|truncate\|write\|writelines\|xreadlines\)$' ]]
183
+ \ [' library/stdtypes.html#str.%s' , ' \C\ .\@<=\(capitalize\|center\|count\|decode\|encode\|endswith\|expandtabs\|find\|format\|index\|isalnum\|isalpha\|isdigit\|islower\|isspace\|istitle\|isupper\|join\|ljust\|lower\|lstrip\|partition\|replace\|rfind\|rindex\|rjust\|rpartition\|rsplit\|rstrip\|split\|splitlines\|startswith\|strip\|swapcase\|title\|translate\|upper\|zfill\)$' ],
184
+ \ [' tutorial/datastructures.html#more-on-lists' , ' \C\ .\@<=\(append\|count\|extend\|index\|insert\|pop\|remove\|reverse\|sort\)$' ],
185
+ \ [' library/stdtypes.html#dict.%s' , ' \C\ .\@<=\(clear\|copy\|fromkeys\|get\|has_key\|items\|iteritems\|iterkeys\|itervalues\|keys\|pop\|popitem\|setdefault\|update\|values\)$' ],
186
+ \ [' library/stdtypes.html#file.%s' , ' \C\ .\@<=\(close\|closed\|encoding\|errors\|fileno\|flush\|isatty\|mode\|name\|newlines\|next\|read\|readinto\|readline\|readlines\|seek\|softspace\|tell\|truncate\|write\|writelines\|xreadlines\)$' ]]
182
187
183
188
function ! s: JumpToEntry (lines , pattern) " {{{1
189
+ if &verbose
190
+ echomsg " pyref.vim: Trying to match" string (a: pattern )
191
+ endif
184
192
let index = match (a: lines , a: pattern )
185
193
if index >= 0
186
194
let url = split (a: lines [index ], ' \t' )[1 ]
0 commit comments