Oh, that's intesting. I was assuming that vim code completion worked
by statically analyzing the ruby sources. But if it works with QtRuby
it must mean it is running code and doing introspection. Nearly all
method calls in QtRuby are trapped by method_missing() and then
forwarded as C++ invocations. So that means that the Ruby methods
don't really exist as such, they are not defined with rb_define_method
() or as Ruby code.
irb(main):002:0> Qt::Widget.instance_methods.sort
=> ["==", "===", "=~", "QT_TRANSLATE_NOOP", "QT_TR_NOOP", "SIGNAL",
"SLOT", "__id__", "__send__", "acceptDrops", "acceptDrops=",
"accessibleDescription", "accessibleDescription=","accessibleName",
"accessibleName=", "actions", "activateWindow", "activeWindow?",
"addAction", "addActions", "adjustSize", "attribute=",
"autoFillBackground", "autoFillBackground=", "backgroundRole",
"backgroundRole=", "baseSize", "baseSize=", "blockSignals", "childAt",
"children", "childrenRect", "childrenRegion", "class", "className",
"class_name", "clear
...
So vim must be making Ruby method calls like the above to know about
QtRuby methods (instance_methods() queries the 'Smoke' library runtime
to find the names of the Qt C++ methods).
-- Richard
···
On May 29, 5:03 pm, lolveley <lolve...@yahoo.fr> wrote:
richard.j.d...@gmail.com a écrit :
> On May 29, 8:22 am, lolveley <lolve...@yahoo.fr> wrote:
>> Hello,
>> I have a little/big problem with vim and ruby.
>> little because almost all works fine : on debian I installed
>> vim,vim-ruby,ruby1.8,qt4-qtruby, and Qt.
>> on vim I have the syntax coloring that's working, and a program like "print
>> require 'Qt4' " returns true : Qt4 is recognized.
>> but I have not the completion for Qt : if I enter "a=Qt:: " +CTRL X+CTRL O,
>> I have the messsage "pattern not found" .
>> on vim I have:
>> :set ofu? => omnifunc=rubycomplete#Complete
>> :set ft? => filetype=ruby
>> :filetype => all 3 are ON
>> can you help me to have the completion?
>> or maybe I have made a mistake, an oversight.
> Code completion with QtRuby will only work if you are interacting with
> running code with a tool such as irb. It won't work with static
> environments like vim. So I would run irb as well as vim to try things
> out, and also use the command line 'rbqtapi' tool to introspect the
> QtRuby api.
> -- Richard
well, it's amazing : I have succeeded in having the completion of Qt
classes and methods by typing : let g:rubycomplete_buffer_loading=1.