RubyProxy


Ⅰ. 插件描述

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

Ⅱ. 基本信息

创建日期:  2010-09-23
使用用户:  1
Github星:  2
插件作者:  Edgar Klerks

Ⅲ. 安装方法

使用Vundle管理器安装

在你的.vimrc下添加:
Plugin '/rubyproxy'
… 然后在Vim中运行以下命令:
:source %
:PluginInstall

对于Vundle版本 < 0.10.2,请用上面的Bundle替换Plugin。

使用NeoBundle管理器安装

在你的.vimrc下添加:
NeoBundle '/rubyproxy'
… 然后在Vim中运行以下命令:
:source %
:NeoBundleInstall

使用VimPlug管理器安装

在你的.vimrc下添加:
Plug '/rubyproxy'
… 然后在Vim中运行以下命令:
:source %
:PlugInstall

使用Pathogen管理器安装

在终端中运行以下命令:
cd ~/.vim/bundle
git clone https://github.com/vim-scripts/RubyProxy

Ⅳ. 文档说明

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","&Yesn&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

添加新评论