Migrating to Vim from RubyMine - Interpreted Auto completion

本小妞迷上赌 提交于 2019-12-09 07:28:59

问题


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):

Second Screenshot (RubyMine core Ruby classes auto complete):

Third Screenshot (vim omnifunc + ctags):


回答1:


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!)



来源:https://stackoverflow.com/questions/26914063/migrating-to-vim-from-rubymine-interpreted-auto-completion

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!