From 44f88f714c53a1c829b552f9d1a9b4a4b2140c07 Mon Sep 17 00:00:00 2001 From: Matthew Brett Date: Sat, 27 Oct 2018 16:44:23 +0100 Subject: [PATCH 1/2] Fix check / load of Python versions The previous code checks for Python 2, unconditionally, with `has('python')`. Unfortunately, this loads Python2 in vim, and then prevents Python3 loading correctly. As a result, if you specify you want Python3 in your vimrc, and you have both Pythons installed into Vim, then you'll get Python2. Fix by checking the vimrc configuration before checking for the presence of Python versions. --- ftplugin/python/pyflakes.vim | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/ftplugin/python/pyflakes.vim b/ftplugin/python/pyflakes.vim index 0e6b79c..d12fbb4 100644 --- a/ftplugin/python/pyflakes.vim +++ b/ftplugin/python/pyflakes.vim @@ -23,24 +23,22 @@ endif if !exists("b:did_python_init") let b:did_python_init = 0 - - if !has('python') && !has('python3') - echoerr "Error: Requires Vim compiled with +python or +python3" - finish - endif " Default to Python 2 - if has('python') - let py_cmd_ver = 'python' - else + let py_cmd_ver = 'python' + let py_cmd_ver_other = 'python3' + if exists('g:pyflakes_prefer_python_version') && + \ g:pyflakes_prefer_python_version == 3 let py_cmd_ver = 'python3' + let py_cmd_ver_other = 'python' endif - if exists('g:pyflakes_prefer_python_version') - if g:pyflakes_prefer_python_version == 3 && has('python3') - let py_cmd_ver = 'python3' - elseif g:pyflakes_prefer_python_version == 2 && has('python') - let py_cmd_ver = 'python' + if !has(py_cmd_ver) + let py_cmd_ver = py_cmd_ver_other + if !has(py_cmd_ver) + echoerr "Error: Requires Vim compiled with +python or +python3" + finish endif endif + if py_cmd_ver == 'python' command! -nargs=1 Python python else From fb1d029b0eab067fcd6301c733753ca348f56d98 Mon Sep 17 00:00:00 2001 From: Matthew Brett Date: Thu, 6 Dec 2018 13:10:32 +0000 Subject: [PATCH 2/2] Comment for Python preference code --- ftplugin/python/pyflakes.vim | 1 + 1 file changed, 1 insertion(+) diff --git a/ftplugin/python/pyflakes.vim b/ftplugin/python/pyflakes.vim index d12fbb4..66e6cf7 100644 --- a/ftplugin/python/pyflakes.vim +++ b/ftplugin/python/pyflakes.vim @@ -26,6 +26,7 @@ if !exists("b:did_python_init") " Default to Python 2 let py_cmd_ver = 'python' let py_cmd_ver_other = 'python3' + " Let user prefer Python 3 if exists('g:pyflakes_prefer_python_version') && \ g:pyflakes_prefer_python_version == 3 let py_cmd_ver = 'python3'