vim api

Jeff Rose jeff at rosejn.net
Thu Dec 8 19:28:24 EST 2005


Thanks for getting back so quickly...

On Fri, 2005-12-09 at 11:08 +1100, Gavin Sinclair wrote:
> On 12/9/05, Jeff Rose <jeff at rosejn.net> wrote:
> > Hello everyone,
> >   I just asked the vim-dev list, but then I realized this might be a
> > better place.  I've been working on a vim plugin using the ruby module,
> > and its required learning and using a fair amount of vim script.  Anyone
> > know why at least the rest of the built-in functions haven't been
> > included in the ruby API?  It would make it a lot easier to jump in and
> > write useful scripts...
> 
> Hi Jeff,
> 
> Not that I don't welcome the question, but the vim-dev mailing list is
> actually more appropriate.  I doubt anyone on this list has the
> expertise to improve the Ruby API within Vim, nor the authority in Vim
> development to make it happen.
> 
> Here's my take on your actual question.  As far as I know, there is
> not a single significant vim plugin out there written using the Ruby
> module.  You are at the cutting edge.  Probably other people have
> tried, but seen how limited the API is and given up.

Well, maybe this will be the first plugin of significance :-)  I think
I'm just about ready to release what I've put together.  After hearing
so much hubub about this TextMate editor for OSX and its snippet
feature, I decided to check it out on a powerbook I've got at school.
(Good write-up of the features described here by the main developer:
http://macromates.com/blog/archives/2005/08/25/the-power-of-snippets/ )
The snippets are very cool, and I found out that the definitions are
open source and available in a subversion repository.  So, after way too
much time I've implemented a vim plugin using the ruby bindings to
provide the same functionality in vim.  It parses the snippet
definitions from the TextMate bundle format, and then lets you tab
through regions of a snippet entering text.  So far I've got variable
substitution, backtick expansion, mirroring, tabstops, and default
values up and running...  In gvim it runs as fast as you type.

As an example, you type "foo.each<tab>" and it spits out 
"foo.each {|element| element. }" where the first element is selected.
You type in whatever you want to replace element with and hit tab.  It
mirrors your change to the second element, and then places the cursor
after the dot.  All virtually instant so once you learn the tab triggers
snippets of code like this just pop out and you fill in the gaps.
They've already got bundles for something like 50 languages, and even
rails has its own bundle to speed up coding. 

> The other problem with using the Ruby API, of course, is that it's not
> typically available in the Vim that people run -- they need to compile
> Vim themselves with the +ruby option.  So your potential audience is
> limited.
> 
> I'd love to see Vim implement better Ruby support, but it's probably
> not seen as a priority.  After all, are people even using the Perl,
> Python, and TCL APIs?  There's great potential for all these things,
> but there's a catch-22 going on: people won't write the plugins until
> the support is there; the support won't be there until there's a clear
> demand.

Yeah, that seems like a typical problem.  Until rails came along as a
"gateway app" I think ruby had a similar dilemma in getting people to
exert the energy to try it out.  Maybe with some more work these
snippets (snippetMagic is the current name, but maybe I should put an
"r" or "ruby" in there to make it explicit... :-) can act as a catalyst
for ruby support in vim.

> So my advice is to persist on the vim-dev list and do whatever you can
> to improve the Ruby API.
Ok, I'll talk to those folks.  There is a set of things that would
really help for writing plugins, and I'd be willing to implement it...

> Also, if you know of any plugins written in Ruby/Python/etc., I'd be
> interested to hear of them.
It would be great to have some extra eyes on this snippets plugin.  This
is the first time I've tried something like this so there are most
likely better ways to do some things.  If anyone is interested in
helping out or just beta testing it would be fantastic.

> 
> Cheers,
> Gavin

Thanks for all the work you've done with the current ruby support.

-Jeff
> 
> _______________________________________________
> vim-ruby-devel mailing list
> vim-ruby-devel at rubyforge.org
> http://rubyforge.org/mailman/listinfo/vim-ruby-devel



More information about the vim-ruby-devel mailing list