diff options
| author | William Boman <william@redwill.se> | 2021-10-12 22:32:57 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-10-12 22:32:57 +0200 |
| commit | f02fe8e4afb3d44c41844ecff7c8192e0ce50c30 (patch) | |
| tree | 1d7f48dbbe3bc0a0442bffe819d00d3259ae3998 /lua/nvim-lsp-installer | |
| parent | clangd: check platform on linux (diff) | |
| download | mason-f02fe8e4afb3d44c41844ecff7c8192e0ce50c30.tar mason-f02fe8e4afb3d44c41844ecff7c8192e0ce50c30.tar.gz mason-f02fe8e4afb3d44c41844ecff7c8192e0ce50c30.tar.bz2 mason-f02fe8e4afb3d44c41844ecff7c8192e0ce50c30.tar.lz mason-f02fe8e4afb3d44c41844ecff7c8192e0ce50c30.tar.xz mason-f02fe8e4afb3d44c41844ecff7c8192e0ce50c30.tar.zst mason-f02fe8e4afb3d44c41844ecff7c8192e0ce50c30.zip | |
installers/pip3: attempt python executable first on Windows (#148)
Diffstat (limited to 'lua/nvim-lsp-installer')
| -rw-r--r-- | lua/nvim-lsp-installer/installers/pip3.lua | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/lua/nvim-lsp-installer/installers/pip3.lua b/lua/nvim-lsp-installer/installers/pip3.lua index 084f102f..7c8ee7e7 100644 --- a/lua/nvim-lsp-installer/installers/pip3.lua +++ b/lua/nvim-lsp-installer/installers/pip3.lua @@ -9,11 +9,14 @@ local M = {} local REL_INSTALL_DIR = "venv" -function M.packages(packages) +local function create_installer(python_executable, pip_executable, packages) return installers.pipe { std.ensure_executables { - { "python3", "python3 was not found in path. Refer to https://www.python.org/downloads/." }, - { "pip3", "pip3 was not found in path." }, + { + python_executable, + ("%s was not found in path. Refer to https://www.python.org/downloads/."):format(python_executable), + }, + { pip_executable, ("%s was not found in path."):format(pip_executable) }, }, function(server, callback, context) local pkgs = Data.list_copy(packages or {}) @@ -22,18 +25,24 @@ function M.packages(packages) stdio_sink = context.stdio_sink, } - c.run("python3", { "-m", "venv", REL_INSTALL_DIR }) + c.run(python_executable, { "-m", "venv", REL_INSTALL_DIR }) if context.requested_server_version then -- The "head" package is the recipient for the requested version. It's.. by design... don't ask. pkgs[1] = ("%s==%s"):format(pkgs[1], context.requested_server_version) end - c.run(M.executable(server.root_dir, "pip3"), vim.list_extend({ "install", "-U" }, pkgs)) + c.run(M.executable(server.root_dir, pip_executable), vim.list_extend({ "install", "-U" }, pkgs)) c.spawn(callback) end, } end +function M.packages(packages) + local py3 = create_installer("python3", "pip3", packages) + local py = create_installer("python", "pip", packages) + return installers.first_successful(platform.is_win and { py, py3 } or { py3, py }) -- see https://github.com/williamboman/nvim-lsp-installer/issues/128 +end + function M.executable(root_dir, executable) return path.concat { root_dir, REL_INSTALL_DIR, platform.is_win and "Scripts" or "bin", executable } end |
