Recently Iβve had to adjust a bunch of my dotfiles to support some old (Centos 5) systems which means that I am using a Vim that has Python 2.4 build inβ¦ needless to say, it breaks some of my dotfiles π
So hereβs some tips on patching Vim version issues.
First, checking if you have Python in your Vim and which version you are using. It returns a version similar to how Vim does it with itβs version. So 204 is the result for Python 2.4, 207 for Python 2.7 and so on.
[vim]
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Check python version if available
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
if has(βpythonβ)
python import vim; from sys import version_info as v; vim.command(βlet python_version=%dβ % (v[0] * 100 + v[1]))
else
let python_version=0
endif
[/vim]
Now we can make plugins/bundles dependend on versions:
[vim]
if python_version >= 205
β Ultisnips requires Vim 2.5 or higher due to the with_statement
Bundle βSirVer/ultisnipsβ
else
Bundle βMarcWeber/vim-addon-mw-utilsβ
Bundle βtomtom/tlib_vimβ
Bundle βgarbas/vim-snipmateβ
endif
[/vim]
And checking for the Vim version to see if features are available:
[vim]
if version >= 703
set undofile
set undodir=~/.vim/undo
set undolevels=10000
call system(βmkdir β . expand(β~/.vim/undoβ))
endif
[/vim]
Thatβs it, the examples can be found in my Vim config: https://github.com/WoLpH/dotfiles/blob/master/_vimrc