PATCH: determine word to be completed like Readline

Doug Kearns dougkearns at
Sun May 7 07:44:41 EDT 2006


I was having some problems completing single element array literals:

[a].<C-x><C-o> # we need a shorthand for the completion point

This was being fed to the completion case expression as "a." rather
than "[a].".

Excuse me if I'm overlooking some obvious issues; I've only just started
to have a look at your script now. ;-) But I was wondering if it would
be better to keep rubycomplete.vim closer to irb/completion.rb?

For example, is there a reason we couldn't simplify determining the word
to be completed by feeding get_completions(), essentially the irb
readline completion proc, _exactly_ the same input that it would be
receiving from Readline in irb? (See patch below.) Then, as
rubycomplete.vim is improved, we could, very simply, feed those
improvements back into irb/complete.rb and vice versa?

You've added Range literal completion which should be included in irb
and I can also see some simple improvements we could make to the
Readline.basic_word_break_characters pattern.

Would this cost us anything in terms of functionality?

I guess the ultimate solution would be to find a way to use
IRB::InputCompletor::CompletionProc directly...


PS. Why are there two when clauses for Array?

Index: autoload/rubycomplete.vim
RCS file: /var/cvs/vim-ruby/vim-ruby/autoload/rubycomplete.vim,v
retrieving revision 1.25
diff -u -r1.25 rubycomplete.vim
--- autoload/rubycomplete.vim	7 May 2006 07:48:11 -0000	1.25
+++ autoload/rubycomplete.vim	7 May 2006 11:36:19 -0000
@@ -321,20 +321,10 @@
   input = VIM::Buffer.current.line
   cpos = VIM::Window.current.cursor[1] - 1
-  input = input[0..cpos] if cpos != 0
+  input = input[0..cpos]
   input += base
-  rip = input.rindex(/\s/,cpos)
-  if rip
-    input = input[rip..input.length]
-  end
-  asn = /^.*(\+|\-|\*|=|\(|\[)=?(\s*[A-Za-z0-9_:@.-]*)(\s*(\{|\+|\-|\*|\%|\/)?\s*).*/
-  if asn.match(input)
-    input = $2
-  end
-  input.strip!
+  input = input.sub(/.*[ \t\n\"\\'`><=;|&{(]/, '') # Readline.basic_word_break_characters
   message = nil
   receiver = nil
   candidates = []

More information about the vim-ruby-devel mailing list