Search code examples
ruby-on-railsrubyvimomnicomplete

Problem with Ruby OmniComplete in Vim 7.3 finding matches at one line but not 2 lines down


Im trying to figure out why ruby omnicompl only works sometimes for me.

Omnicomplete working Here it's working as expected.

Trying to same operation on the same ivar 2 lines down But when I try the same thing on the same ivar 2 lines down I get "Pattern not found"

Both are done the same way, typing out @current_user_session.fiCtrl+X+O

I checked tpopes rails.vim github page for open/closed issues and tried to google it without luck.

My macvim and vim is compiled with +ruby

:echo &omnifunc returns rubycomplete#Complete

:Rails! returns rails.vim 4.3 (Rails-controller)

I have my complete vimdir on github for reference.


Solution

  • one would imagine that it's because in img2 it's now below the setting of the variable (@current_user_session = UserSession.find).

    which means that as this is now an instance it's looking for instance methods, whereas before it was returning the class method.

    e.g.

    User.find # => fine
    
    
    user = User.find
    user.find # => Method not found
    

    to demo the difference run these:

    User.methods.sort
    User.find.methods.sort
    

    you'll see that it's quite different. put bluntly you're trying to look up 'find' for a user you have. "'tom'.find" doesn't make any sense.