From: pmacosta Date: Tue, 7 May 2019 17:28:56 +0000 (-0400) Subject: Use g:pymode_python-defined interpreter if defined and exists, otherwise use existing... X-Git-Url: https://git.madduck.net/etc/vim.git/commitdiff_plain/4931ddd0b1f84910790bebcd86c2147d1ddcf1e1?ds=inline Use g:pymode_python-defined interpreter if defined and exists, otherwise use existing defaults (#666) This is helpful when using custom-compiled interpreters, or alternative Python interpreters in non-standard locations --- diff --git a/plugin/black.vim b/plugin/black.vim index 36825cf..15a13d1 100644 --- a/plugin/black.vim +++ b/plugin/black.vim @@ -37,10 +37,17 @@ if !exists("g:black_skip_string_normalization") endif python3 << endpython3 +import os import sys import vim def _get_python_binary(exec_prefix): + try: + default = vim.eval("g:pymode_python").strip() + except vim.error: + default = "" + if default and os.path.exists(default): + return default if sys.platform[:3] == "win": return exec_prefix / 'python.exe' return exec_prefix / 'bin' / 'python3'