new rubycomplete (0.7)

September 19th, 2006

I've finally mangled rubycomplete into a state fit for release. The following features have been added/improved:
  • Improved handling/completion of incomplete code (code with syntax errors)
  • Much improved rails view support
  • Matching controller/model/view Rails helpers now included with rails completions
  • rubycomplete no longer appears in the completion lists
  • Kernel methods now included in completions (print, open, etc...)
  • In-buffer modules now included in completion lists
You can get the file from the usual place. In case someone reading this isn't aware rubycomplete is an omni-completion function for vim. It provides intellisense-esque completion of elements in the editor. More information is availible from the site.
I've been helping a few people in #rubyonrails who were having trouble getting rubycomplete to run. Some of them were getting omnifunc not set errors. The source of the problem is most likely the existance of a ~/.vim/ftplugin/ruby.vim file. Its existance prevents the vim runtime version of the file from running and setting the omnifunc variable properly. If you run into this either remove the file or set the omnifunc in the ftplugin file. You can find more info on the settings for rubycomplete and setting it up here.

The other issue involves custom ruby installations on OSX. It seems that the distributed OSX Vim 7 loads the default OSX ruby installation, which doesn't have rubygems installed. So you may see a rubygems error. I'm working on a solution for this problem.

vim 7 ruby omni completion

April 10th, 2006

I've hacked irb/completion into something resembling an omni-completion function for vim 7. It currently works for me. I looked at pycomplete.vim and ccomplete.vim to create it. There is a bit of work ahead as far as variable-type detection and require's are concerned. If you're feeling your oats and want to hack away at it, you'll find it here (rubycomplete.vim (0.7)). If you want to see the old versions check the release history. It was originally called rbcomplete.vim, but a discussion on the vim-dev mailing list led to a rename matching the filetype definitions. There are probably many improvements possible, I'll see how much I can make it do in the next few weeks. I've joined up with the vim-ruby project, so you can find the file in their cvs repository.

features:
  • completion of ruby constants/globals
  • in class completion of class members
  • class method completion
  • [attempted] detection of variable types
  • optional live completion of buffer elements (classes, modules)
  • optional automatic inclusion of requires for completion
  • optional detection of rails and completion of rails methods
  • kernel method completion
  • completion in rails views
n.b.: rubycomplete evaluates code in vim, this could have side effects. As of version 0.6 rubycomplete no longer defaults to evaluating live buffers. This functionality can be toggled back on (I suggest you do so, as it increases the usefullness of the script). As a note loading rails takes a little bit so you will need to be patient when initially completing rails classes.

usage: add something similar to the following to your vimrc and place rbcomplete in your autoload directory

autocmd FileType ruby,eruby set omnifunc=rubycomplete#Complete
if you want buffer/rails/global completion you must add the following:
autocmd FileType ruby,eruby let g:rubycomplete_buffer_loading = 1
if you want rails support add the following in addition
autocmd FileType ruby,eruby let g:rubycomplete_rails = 1
if you want classes included in global completions add the following
autocmd FileType ruby,eruby let g:rubycomplete_classes_in_global = 1

open a ruby file, add some object call, say Array. and hit CTRL-X CTRL-O.

Obligatory screenshot
rbcomplete.vim screenshot