sponsor Vim development Vim logo Vim Book Ad

RubyProxy : Makes most of vims functions available to ruby via a proxy.

 script karma  Rating 21/6, Downloaded by 235    Comments, bugs, improvements  Vim wiki

created by
Edgar Klerks
 
script type
utility
 
description
RubyProxy
RubyProxy acts as a proxy between ruby and vim, so that most of vims functions are usable in ruby. Only the functions, which accepts lists and dictionary won't work. And functions, which returns Dictionaries. It can work with functions that return lists now (including depth n with n > 1).  Floats are a problem, because the string function won't accept it in VIM 7.2.

There is a example added in  RubyProxy.vim, to show to use this class.

USAGE

You need to prefix every vim function with the letter V (from VIM). E.g:

withProxy:

withProxy accepts a block and makes the proxy available in the scope of the block.

Every function from :help functions can be called.
If you want to use a certain function, the function name must be prefixed with V to avoid clashes with ruby's functions.

EXAMPLE:

ruby withProxy { |p| puts p.Vconfirm("Test","&Yes\n&No")}

This will show you a dialog box and return one if someone clicked Yes and 2 where someone clicked No.

Another example (with a function, which returns lists):

withProxy {|p| p.Vgetbufline(1,1,10).each {|x| puts ("hello" + x)}}

This appends hello to the first 10 lines from buffer 1 and echo the lines.

TODO:

Adding support for dictionaries.
Adding support for floats. (It is built in, but the string function won't accept floats)
Adding data conversions from Ruby to Vim. Now it only accepts list, strings or numbers.

This approach would probably be pretty easy to adopt for other languages, so create more plugin for different languages.

See the wiki for more information. Or for some information in Dutch, see here: http://www.i-bytes.nl/code
 
install details
Just put it into your plugin directory.
You need if_ruby enabled, otherwise you cannot use the plugin.
Your ruby installation needs yaml installed.
 

rate this script Life Changing Helpful Unfulfilling 
script versions (upload new version)

Click on the package to download.

package script version date Vim version user release notes
RubyProxy.vim 0.21 2010-09-24 7.0 Edgar Klerks Added support for multilevel lists.
Cleaned up script (make use of script variables.).
RubyProxy.vim 0.2 2010-09-24 7.0 Edgar Klerks Added support for data conversion from Ruby to Vim, currently supports: List, String, Number. Dictionary and Floats coming soon. This version is not yet fully tested. But it seems to support multidepth lists.
RubyProxy.vim 0.1 2010-09-23 7.0 Edgar Klerks Initial upload
ip used for rating: 54.161.181.49

If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to the maillist. Help Bram help Uganda.
   
SourceForge.net Logo