omni-completion refresh

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

omni-completion refresh

Jarmo
Hi!

I've finally got Ruby code completion working sort of, but not as i'd really like it. Currently it doesn't show the new methods added to some class if code-completion has already used. For example, if i have files like these:

# a.rb
class A
  def my_method
  end
end

# b.rb
require "a"
a = A.new
a. # <C-x><C-o> will show my_method

Now if i open a.rb in a separate buffer and add some new method and save the file then again in the b-buffer omni-completion doesn't show the newly added method. I have to restart vim to make it show me the new method too. Is it possible to make vim reload the omni-completion data?

In my vimrc i have currently these lines:
autocmd FileType ruby,eruby set omnifunc=rubycomplete#Complete
autocmd FileType ruby,eruby let g:rubycomplete_buffer_loading = 1
autocmd FileType ruby,eruby let g:rubycomplete_rails = 1
autocmd FileType ruby,eruby let g:rubycomplete_classes_in_global = 1

Also, when i use modules then the omni-completion doesn't seem to work at all - even if i restart vim:
# a.rb

module MyModule
  class MyClass
    def my_method
    end
  end
end

# b.rb
MyM #<C-x><C-o> shows no matches
MyModule::MyC #<C-x><C-o> shows no matches
a = MyModule::MyClass.new
a. #<C-x><C-o> shows no matches

To conclude i have two problems:
1) how to refresh omni-completion data?
2) how to make omni-completion work with module namespaces?

I'm relatively new to vim so please apologize for my ignorance.

Jarmo

_______________________________________________
vim-ruby-devel mailing list
[hidden email]
http://rubyforge.org/mailman/listinfo/vim-ruby-devel
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: omni-completion refresh

Jarmo
Hi!

Let me add some new findings about omni-completion when modules are in use. Even the following snippet will show "pattern not found":
module A
  class B
    def c

    end
  end
end

a = A::B.new
a.#<C-x><C-o>

By setting @@debug to true in rubycomplete.vim i see these messages when trying to complete for the first time:
input a.
variable
load_buffer_class(a) START
vartype A::B
load_buffer_class(A::B) START
load_buffer_class err: (eval):1:in `get_completions': uninitialized constant VimRubyCompletion::A

For some reason module A is not eval'ed to create the constant. In load_buffer_class the line:
  classdef = get_buffer_entity(name, 's:GetBufferRubyClass("%s")') 

returns nil.

Is there any better way to debug the Ruby code within rubycomplete.vim than with those dprint() statements? Any chance to use ruby-debug there somehow?

Should the code completion even work with today's Ruby? I can see from the github history that there hasn't been much of an action lately with rubycomplete.vim, but that could mean anything of course.

Jarmo

On Sat, Dec 25, 2010 at 7:44 PM, Jarmo <[hidden email]> wrote:
Hi!

I've finally got Ruby code completion working sort of, but not as i'd really like it. Currently it doesn't show the new methods added to some class if code-completion has already used. For example, if i have files like these:

# a.rb
class A
  def my_method
  end
end

# b.rb
require "a"
a = A.new
a. # <C-x><C-o> will show my_method

Now if i open a.rb in a separate buffer and add some new method and save the file then again in the b-buffer omni-completion doesn't show the newly added method. I have to restart vim to make it show me the new method too. Is it possible to make vim reload the omni-completion data?

In my vimrc i have currently these lines:
autocmd FileType ruby,eruby set omnifunc=rubycomplete#Complete
autocmd FileType ruby,eruby let g:rubycomplete_buffer_loading = 1
autocmd FileType ruby,eruby let g:rubycomplete_rails = 1
autocmd FileType ruby,eruby let g:rubycomplete_classes_in_global = 1

Also, when i use modules then the omni-completion doesn't seem to work at all - even if i restart vim:
# a.rb

module MyModule
  class MyClass
    def my_method
    end
  end
end

# b.rb
MyM #<C-x><C-o> shows no matches
MyModule::MyC #<C-x><C-o> shows no matches
a = MyModule::MyClass.new
a. #<C-x><C-o> shows no matches

To conclude i have two problems:
1) how to refresh omni-completion data?
2) how to make omni-completion work with module namespaces?

I'm relatively new to vim so please apologize for my ignorance.

Jarmo


_______________________________________________
vim-ruby-devel mailing list
[hidden email]
http://rubyforge.org/mailman/listinfo/vim-ruby-devel
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: omni-completion refresh

Mark Guzman
Jarmo,
  I've got a few changes in a branch called rubycomplete_updates that should handle the namespacing issue.
With regards to file reloading, I have some options I've been playing with involving moving a lot of the processing outside of the Vim process.
  --mg

On Dec 26, 2010, at 12:58 AM, Jarmo wrote:

Hi!

Let me add some new findings about omni-completion when modules are in use. Even the following snippet will show "pattern not found":
module A
  class B
    def c

    end
  end
end

a = A::B.new
a.#<C-x><C-o>

By setting @@debug to true in rubycomplete.vim i see these messages when trying to complete for the first time:
input a.
variable
load_buffer_class(a) START
vartype A::B
load_buffer_class(A::B) START
load_buffer_class err: (eval):1:in `get_completions': uninitialized constant VimRubyCompletion::A

For some reason module A is not eval'ed to create the constant. In load_buffer_class the line:
  classdef = get_buffer_entity(name, 's:GetBufferRubyClass("%s")') 

returns nil.

Is there any better way to debug the Ruby code within rubycomplete.vim than with those dprint() statements? Any chance to use ruby-debug there somehow?

Should the code completion even work with today's Ruby? I can see from the github history that there hasn't been much of an action lately with rubycomplete.vim, but that could mean anything of course.

Jarmo

On Sat, Dec 25, 2010 at 7:44 PM, Jarmo <[hidden email]> wrote:
Hi!

I've finally got Ruby code completion working sort of, but not as i'd really like it. Currently it doesn't show the new methods added to some class if code-completion has already used. For example, if i have files like these:

# a.rb
class A
  def my_method
  end
end

# b.rb
require "a"
a = A.new
a. # <C-x><C-o> will show my_method

Now if i open a.rb in a separate buffer and add some new method and save the file then again in the b-buffer omni-completion doesn't show the newly added method. I have to restart vim to make it show me the new method too. Is it possible to make vim reload the omni-completion data?

In my vimrc i have currently these lines:
autocmd FileType ruby,eruby set omnifunc=rubycomplete#Complete
autocmd FileType ruby,eruby let g:rubycomplete_buffer_loading = 1
autocmd FileType ruby,eruby let g:rubycomplete_rails = 1
autocmd FileType ruby,eruby let g:rubycomplete_classes_in_global = 1

Also, when i use modules then the omni-completion doesn't seem to work at all - even if i restart vim:
# a.rb

module MyModule
  class MyClass
    def my_method
    end
  end
end

# b.rb
MyM #<C-x><C-o> shows no matches
MyModule::MyC #<C-x><C-o> shows no matches
a = MyModule::MyClass.new
a. #<C-x><C-o> shows no matches

To conclude i have two problems:
1) how to refresh omni-completion data?
2) how to make omni-completion work with module namespaces?

I'm relatively new to vim so please apologize for my ignorance.

Jarmo

_______________________________________________
vim-ruby-devel mailing list
[hidden email]
http://rubyforge.org/mailman/listinfo/vim-ruby-devel


_______________________________________________
vim-ruby-devel mailing list
[hidden email]
http://rubyforge.org/mailman/listinfo/vim-ruby-devel
Loading...