What is the best way to make Vim omnicomplete a context for rubies / rails? (i.e. intellisense)

Vim auto complete it seems that he just throws a kitchen sink at me, hoping that one of the words is what I need. If I know the first couple of characters of a member method, I'm fine, but sometimes I can’t remember if the member method is “obj.visible” or “obj.is_visible”, in which case I get 50-1000 options to wade through .

consider the following code:

class MyClass def some_method end def another_method end end def a_global_method(stuff) return stuff + " more stuff" end 

Now if i type

 obj = MyClass.<cx><co> 

I get 50 options starting with '<'. "New" would be a great default. Even if I type n, then cx / co new is not the first option.

Deteriorating:

 obj = MyClass.new obj.<cx><co> 

This gives me 50 options again, and maybe they are all legal, but why not the default 'some_method' and 'another_method'?

But wait, all parameters are not legal:

 obj = MyClass.new obj.a<cx><co> 

This gives me only 2 options, but one of them is 'a_global_method'. Therefore, it is obvious that he does not completely know what a class or module is, at least with my current settings. I could just use it if I still need to type in half the name of the member.

Speaking of which, a summary of my current settings is as follows: rails.vim with the following settings:

 "omnifunc=rubycomplete#Complete is set by rails.vim 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 autocmd FileType ruby,eruby let g:rubycomplete_include_object = 1 autocmd FileType ruby,eruby let g:rubycomplete_include_objectspace = 1 

I have been a loyal vim user for 12 years, but the completion never worked correctly for me. I use Visual Studio at work and often use intellisense as a crutch. Since I don't code on rails often enough to remember each method, a little intellisense love would go a long way.

Is there any plugin that works well? Did I just skip the setup?

+4
source share
1 answer

Have you tried YouCompleteMe ?

Here youcompleteme

+1
source

Source: https://habr.com/ru/post/1437728/


All Articles