From ac42c83a7005845f56f54f57558922f85a9e36aa Mon Sep 17 00:00:00 2001 From: Daniel Hahler Date: Tue, 14 Apr 2015 22:21:50 +0200 Subject: [PATCH] bootstrap: verify that g:UltiSnipsUsePythonVersion is available Without this, UltiSnips will throw a lot of errors in case it's not available. This does not look at `g:UltiSnipsNoPythonWarning`, because it is not auto-detected, but provided by the user's config. --- autoload/UltiSnips/bootstrap.vim | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/autoload/UltiSnips/bootstrap.vim b/autoload/UltiSnips/bootstrap.vim index d61f261..ecadc22 100644 --- a/autoload/UltiSnips/bootstrap.vim +++ b/autoload/UltiSnips/bootstrap.vim @@ -20,10 +20,18 @@ function! UltiSnips#bootstrap#Bootstrap() endif let g:UltiSnipsUsePythonVersion = "" else - if g:UltiSnipsUsePythonVersion == 2 - let g:_uspy=":py " - else - let g:_uspy=":py3 " + " Use user-provided value, but check if it's available. + " This uses `has()`, because e.g. `exists(":python3")` is always 2. + if g:UltiSnipsUsePythonVersion == 2 && has('python') + let g:_uspy=":python " + elseif g:UltiSnipsUsePythonVersion == 3 && has('python3') + let g:_uspy=":python3 " + endif + if !exists('g:_uspy') + echohl WarningMsg + echom "UltiSnips: the Python version from g:UltiSnipsUsePythonVersion (".g:UltiSnipsUsePythonVersion.") is not available." + echohl None + return endif endif