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
usage: add something similar to the following to your vimrc and place rbcomplete in your autoload directory
autocmd FileType ruby,eruby set omnifunc=rubycomplete#Completeif you want buffer/rails/global completion you must add the following:autocmd FileType ruby,eruby let g:rubycomplete_buffer_loading = 1if you want rails support add the following in additionautocmd FileType ruby,eruby let g:rubycomplete_rails = 1if you want classes included in global completions add the following autocmd FileType ruby,eruby let g:rubycomplete_classes_in_global = 1open a ruby file, add some object call, say Array. and hit CTRL-X CTRL-O.
Obligatory screenshot
November 8th, 2006 at 06:00 PM eiffel, I'm gona need a good bit more to actually be able to help you. The ruby version is only one part. The errors would be a good start. As would the os. Also check here , I'm compiling some troubleshooting tips.
November 8th, 2006 at 06:00 PM Thanks segfault! I tried to disable rails support and it works fine but I need rails support. Next week I'll move to rails 1.1 and then I'll check it again.
November 8th, 2006 at 06:00 PM jxde,
I'll take a crack at making it rails 1.0 compatible. While I'm at it I'll also see about having it optionally connect to the db so we can complete the actual model fields.
November 8th, 2006 at 06:00 PM Aron,
Thats on my list. It's a bug with ruby support in vim. If you attempt to access a vim buffer from ruby it crashes.
--mark
November 8th, 2006 at 06:00 PM does not work with my ruby version 1.8.4, when i press Ctl + X, Ctl + O , it return many errors
November 8th, 2006 at 06:00 PM kybu,
I need a little more info. What version of ruby is that compiled against. Also, are you trying to complete in a code block? Feel free to email me also.
November 8th, 2006 at 06:00 PM Hi,
I tried auto complete feature in vim 7.0, but I got this error, whenever I press C-X C-O:
Error detected while processing function rubycomplete#Complete:
line 22:
NoMethodError: undefined method `line_number' for 27:Fixnum
This happens with default vim installation and also with your lates version of rubycomplete.vim.
November 8th, 2006 at 06:00 PM segfault
How is your progress coming along on making vim + ruby Rails 1.0/1.1+ compatible.
I'm very interested in your work with regards to having vim connect to the db so that it can auto complete the acutal model fields.
James
November 8th, 2006 at 06:00 PM jxde,
I assume your trying to complete while editing a file thats part of a rails project. In addition I am infering that you have rails support turned on. rubycomplete is trying to load the rails environment and the requires are failing. From the path I take it your doing this on a *nix system. Double check the rails installation, or disable rails support. Send along more info and I will try to replicate the problem on my end.
November 8th, 2006 at 06:00 PM works nicely with supertab: http://www.vim.org/scripts/script.php?script_id=182
thanks alot
November 8th, 2006 at 06:00 PM Thank you!
November 8th, 2006 at 06:00 PM I tried auto complete and got this error:
Error detected while processing function rubycomplete#Complete:
line 22:
MissingSourceFile: /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:21:in `require__': No such file to load -- console_app
Please help me
November 8th, 2006 at 06:00 PM Hello,
I also get:
Error detected while processing function rubycomplete#Complete:
line 22:
NoMethodError: undefined method `line_number' for 27:Fixnum
...when pressing <C-X><C-O>.
I was trying the "Verifying Installation" process at:
http://wiki.rubygarden.org/Ruby/page/show/VimRubySupport
...when it happened. I.e., I was inside a method definition, after a '.'.
This is vim 7.0 on Solaris 8 with ruby 1.8.4.
Looks like a common-enough problem; any wisdom?
December 17th, 2007 at 02:51 AM professionalize braccianite arsenicism bewitching corycavamine protochordate extricably jacami The Fraud Detectives http://www.housesofmichigan.com/