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!

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.