Abdo
Abdo

Reputation: 14061

Migrating to Vim from RubyMine - Interpreted Auto completion

Up until last week, I had been using RubyMine for my Rails development. I know it has a vim plugin but I have been working on migrating my development to vim and tmux. I don't want to keep using the mouse and VIM gives me a lot more flexibility. I have found plugins and workarounds for almost all the features I care about except the "interpreted auto complete" functionality in my first screenshot below. RubyMine interprets the whole rails application and offers sorted-by-relevance suggestions (as you can see, it's showing me instance variables and methods for the class in question and the modules it includes) THEN it shows (less relevant) methods available on the Object class. It also shows the method signature when there's one.

Also, in my second screenshot, you can see how RubyMine offers autocompletion for core Ruby classes.

Compare this to the bottommost screenshot. I do have completion but there's no way to find what I'm looking for. I'm using ctags , YouCompleteMe, vim-rails, vim-ruby and I also tried installing eclim to see if it makes a difference.

Is there a plugin I've missed that can enhance my auto completion? It doesn't look like RubyMine is doing something super crazy. pry can give me the same 'power' if it were running in the same 'context'.

First Screenshot (RubyMine interpreted auto complete):

enter image description here

Second Screenshot (RubyMine core Ruby classes auto complete):

enter image description here

Third Screenshot (vim omnifunc + ctags):

enter image description here

Upvotes: 4

Views: 2665

Answers (1)

Abdo
Abdo

Reputation: 14061

Important Note This solution only works for Ruby 1.9+

I forked 'vim-ruby' at https://github.com/zxiest/vim-ruby and modified it as such:

  • Method signatures now appear in completion.
  • I disabled sorting by name for methods.

Plugins and Settings

vim-rails I'm using vim-rails https://github.com/tpope/vim-rails

supertab I'm using supertab https://github.com/ervandew/supertab instead of YouCompleteMe (mentioned in my question) although YouCompleteMe is super fast and automatic but there are currently some compatibility issues between my it and my vim-ruby fork.

vim-easytags I'm using vim-easytags https://github.com/xolox/vim-easytags

Add this to your ~/.vimrc

:set tags=./tags;
:let g:easytags_dynamic_files = 1

Make sure to touch ./tags in your project directory.

Issue :UpdateTags -R **/*.* from vim in order for easytags to generate your tags file.

Remap omnicomplete

In order for omnicomplete to pop up, by default, we have to hit <C-X><C-O>. I remapped this to <C-Space> by inserting the following in my ~/.vimrc:

inoremap <C-@> <C-x><C-o>

I now press tab when I want supertab to complete my code and Ctrl+Space when I want omnicomplete to trigger and show method signatures for me. There's definitely a better way to integrate this (i.e. getting supertab to call omnicomplete after a dot)

And here goes the screenshot! Notice that method sorting being off allowed my custom resize method to appear on top and the signatures now appear in the completion (as well as in the editor when enter is pressed!)

enter image description here

Upvotes: 4

Related Questions