Sunday, March 17, 2013

UltiSnips requires multibyte support enabled in Vim

UltiSnips, a Vim plugin, is "an implementation of TextMates Snippets for the Vim Text Editor," according to its author. I had some trouble getting it running in Cygwin, especially with an error on a Vim variable &encoding thrown by the plugin's Python code, so I hope this post will help others avoid my problems.

Make sure that
  1. Python 2.6.x or better is installed for Cygwin,
  2. vim is compiled with the +python or +python3 configuration flag (as appropriate), and
  3. vim is compiled with the +multi_byte config flag.

You can check vim's configuration flags by running this command in a Cygwin shell:
$ vim --version | grep -E '(python|multi)'
You should see something like
+mouse_xterm +multi_byte +multi_lang -mzscheme +netbeans_intg -osfiletype
+path_extra -perl +persistent_undo +postscript +printer -profile +python
-python3 +quickfix +reltime +rightleft +ruby +scrollbind +signs +smartindent
Linking: gcc   -L.   -L/usr/local/lib -o vim.exe             -lm -lncurses            -L/usr/lib/python2.7/config -lpython2.7 -lruby191 -lrt

The + signs on the +python and +multi_byte flags indicates Vim was compiled with Python and multibyte support.

The UltiSnips Vim plugin wraps a Python application to do the heavy lifting. It will fail if Python is not available.

In addition, if vim is not configured for multibyte code, then the Python code will fail on an empty Vim variable &encoding. See line 18 in this example:



Happy vimming!

Saturday, March 16, 2013

Wow, that was f***ing fast!

Today I noticed a small error in a graphic included in section 5.2 of the Edge RailsGuide Getting Started with Rails. I raised an issue on the Rails Github project, figuring, OK, I've made my little contribution to the March of Open Source Goodness.

I was pleasantly surprised when Rails maintainer Steve Klabnik responded moments later that I had indeed caught a bug, as he'd done a couple of days before on another issue I'd raised (does this guy never leave his keyboard?). In the earlier case, the error was on my part, a semantic mismatch between using Rails 3.2.12 with the edge docs intended for the new Rails 4.0.0.

This time, after I read Steve's speedy response, I gave the RailsGuide page a reload, thinking, "OK, it' probably be a couple of days before that change gets committed."

I was astonished to see that not only had Steve committed a fix for the error, he'd used my screen grab to fix it. Major grin :)

Coming from a waterfall-ish project world where changes can take weeks and months to find their way to end users, I'd call this delight "moving at the speed of Rails".