vim 7 ruby omni completion
Mon, Apr 10, 2006I'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
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 additionautocmd 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