&encoding
thrown by the plugin's Python code, so I hope this post will help others avoid my problems.Make sure that
- Python 2.6.x or better is installed for Cygwin,
- vim is compiled with the
+python
or+python3
configuration flag (as appropriate), and - 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:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ vim | |
Error detected while processing /home/Philip/.vim/bundle/ultisnips/plugin/UltiSnips.vim: | |
line 232: | |
Traceback (most recent call last): | |
File "<string>", line 1, in <module> | |
File "/home/Philip/.vim/bundle/ultisnips/plugin/UltiSnips/__init__.py", line 13, in <module> | |
from UltiSnips._diff import diff, guess_edit | |
File "/home/Philip/.vim/bundle/ultisnips/plugin/UltiSnips/_diff.py", line 7, in <module> | |
from UltiSnips import _vim | |
File "/home/Philip/.vim/bundle/ultisnips/plugin/UltiSnips/_vim.py", line 320, in <module> | |
if not int(eval('has("langmap")')): | |
File "/home/Philip/.vim/bundle/ultisnips/plugin/UltiSnips/_vim.py", line 107, in eval | |
rv = vim.eval(as_vimencoding(s)) | |
File "/home/Philip/.vim/bundle/ultisnips/plugin/UltiSnips/compatibility.py", line 85, in as_vimencoding | |
return _vim_enc(s) | |
File "/home/Philip/.vim/bundle/ultisnips/plugin/UltiSnips/compatibility.py", line 24, in _vim_enc | |
return s.encode(vim.eval("&encoding")) | |
TypeError: encode() argument 1 must be string, not None | |
line 233: | |
Traceback (most recent call last): | |
File "<string>", line 1, in <module> | |
NameError: name 'UltiSnips_Manager' is not defined | |
line 234: | |
Traceback (most recent call last): | |
File "<string>", line 1, in <module> | |
NameError: name 'UltiSnips_Manager' is not defined | |
line 235: | |
Traceback (most recent call last): | |
File "<string>", line 1, in <module> | |
NameError: name 'UltiSnips_Manager' is not defined | |
Press ENTER or type command to continue |
Happy vimming!