Better autocomplete in VIM

13,642

Solution 1

Relatively satisfied with stock Vim's omnicomplete + vim-ruby and vim-rails having completion abilities on par with NetBeans but with all the bells&whistles of Vim and much lower resource requirements, of course.

From my .vimrc concerning completion options :

autocmd FileType ruby,eruby let g:rubycomplete_buffer_loading = 1 
autocmd FileType ruby,eruby let g:rubycomplete_classes_in_global = 1
autocmd FileType ruby,eruby let g:rubycomplete_rails = 1

Solution 2

One thing that I have had a bit of luck with Rubymotion is YouCompleteMe and enabling tag Support. you will need a lot of ram(YCM uses ~2GB when indexing a large tag file) because the tags that rubymotion uses are about 40k tags.

The downside is that the rubymotion people don't seem to want to review pull requests and provide any feedback so I am not sure if they will add the needed things to the rake task that creates the tag files for ycm to work correctly out of the box.

To get it to work you need to set the tags files correct

set tags=./tags;,tags;

and then you need to setup ycm to complete off tags.

let g:ycm_collect_identifiers_from_tags_files = 1

you need to make the ctags file compatible with ycm as well. This pull request does that. You need to add a language field to the ctags creation and then change bridgesupport to ruby.

pull request for that

after that you need to run rake ctags in the root of your project.

If you don't want to modify the project.rb file you could probably create your own rake task that does pretty much the same thing.

Share:
13,642
Warren Wright
Author by

Warren Wright

Updated on September 14, 2022

Comments

  • Warren Wright
    Warren Wright over 1 year

    All,

    I have been working with vim for some time now, and love everything about it - there is only one thing I really miss from IDEs like RubyMine, and that is advanced autocompletion.

    For reference, here is my standard VIM setup: https://github.com/wrwright/.vim

    I have tried ctags with omnicomplete + supertab, and the one major element I miss is the ability to bring up a context sensitive list of attributes/constants/methods. For example, as I learn RubyMotion, I'd love to have some help remembering iOS SDK constants/attributes/methods, but my VIM autocomplete stops with suggesting class names..or if it does suggest methods/attributes, it lists a ton of methods/attributes that don't even apply to the class I'm working with.

    I'd like to (simple example) be able to type UIColor.bl and have it autocomplete with UIColor.blueColor (or suggest if there are multiple options that start with "bl" that are properties of UIColor.

    RubyMine does this very well, and if I can get VIM to be similarly smart with autocomplete it would be heavenly (and a great boon while learning RubyMotion/iOS Development.

    I have also tried SnipMate (and even a RubyMotion tailored variation at https://github.com/rcyrus/snipmate-snippets-rubymotion), but that doesn't seem to offer the features I'm looking for either.

  • Warren Wright
    Warren Wright about 11 years
    I appreciate the response and the link, romainl.
  • Warren Wright
    Warren Wright almost 11 years
    I've been running similarly since you posted this, and thanks. I do have on my radar to try out youcompleteme, however, at some point.
  • Emile Vrijdags
    Emile Vrijdags over 5 years
    @geoffharcourt I haven't voted it down, but my 2 cents on why: because the statements made seem pretty narrow minded. First, what is the definition of IDE vs text editor? I don't know.. I think the line is pretty blurry, and because one or the other there are some expectations to be made? And of course it relies on community to provide support.. it is an open source project without money backing it and essentially 1 developer, which is imho more the reason that it is what it is, in contrary to the editor/IDE distinction. And: for C/C++ with the right plugins, completi works as good as any IDE.