aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWilliam Boman <william@redwill.se>2021-10-17 19:17:23 +0200
committerGitHub <noreply@github.com>2021-10-17 19:17:23 +0200
commit5c1d368e7fe693b87322ba45c023da5b378feba9 (patch)
tree2bf8868bd5e4aaaae012759afe991748316a983a
parentsqlls: fix cmd (diff)
downloadmason-5c1d368e7fe693b87322ba45c023da5b378feba9.tar
mason-5c1d368e7fe693b87322ba45c023da5b378feba9.tar.gz
mason-5c1d368e7fe693b87322ba45c023da5b378feba9.tar.bz2
mason-5c1d368e7fe693b87322ba45c023da5b378feba9.tar.lz
mason-5c1d368e7fe693b87322ba45c023da5b378feba9.tar.xz
mason-5c1d368e7fe693b87322ba45c023da5b378feba9.tar.zst
mason-5c1d368e7fe693b87322ba45c023da5b378feba9.zip
installers/pip3: add setting for adding extra install args (#151)
-rw-r--r--README.md8
-rw-r--r--doc/nvim-lsp-installer.txt8
-rw-r--r--lua/nvim-lsp-installer/installers/pip3.lua13
-rw-r--r--lua/nvim-lsp-installer/installers/std.lua2
-rw-r--r--lua/nvim-lsp-installer/process.lua2
-rw-r--r--lua/nvim-lsp-installer/settings.lua14
6 files changed, 37 insertions, 10 deletions
diff --git a/README.md b/README.md
index 7b910080..bf09cb7f 100644
--- a/README.md
+++ b/README.md
@@ -226,6 +226,14 @@ local DEFAULT_SETTINGS = {
},
},
+ pip = {
+ -- These args will be added to `pip install` calls. Note that setting extra args might impact intended behavior
+ -- and is not recommended.
+ --
+ -- Example: { "--proxy", "https://proxyserver" }
+ install_args = {},
+ },
+
-- Controls to which degree logs are written to the log file. It's useful to set this to vim.log.levels.DEBUG when
-- debugging issues with server installations.
log_level = vim.log.levels.INFO,
diff --git a/doc/nvim-lsp-installer.txt b/doc/nvim-lsp-installer.txt
index 6cf7da8c..f9b05d56 100644
--- a/doc/nvim-lsp-installer.txt
+++ b/doc/nvim-lsp-installer.txt
@@ -170,6 +170,14 @@ The following settings are applied by default. >
},
},
+ pip = {
+ -- These args will be added to `pip install` calls. Note that setting extra args might impact intended behavior
+ -- and is not recommended.
+ --
+ -- Example: { "--proxy", "https://proxyserver" }
+ install_args = {},
+ },
+
-- Controls to which degree logs are written to the log file. It's useful to set this to vim.log.levels.DEBUG when
-- debugging issues with server installations.
log_level = vim.log.levels.INFO,
diff --git a/lua/nvim-lsp-installer/installers/pip3.lua b/lua/nvim-lsp-installer/installers/pip3.lua
index 7c8ee7e7..8ae3d2db 100644
--- a/lua/nvim-lsp-installer/installers/pip3.lua
+++ b/lua/nvim-lsp-installer/installers/pip3.lua
@@ -4,19 +4,19 @@ local installers = require "nvim-lsp-installer.installers"
local std = require "nvim-lsp-installer.installers.std"
local platform = require "nvim-lsp-installer.platform"
local process = require "nvim-lsp-installer.process"
+local settings = require "nvim-lsp-installer.settings"
local M = {}
local REL_INSTALL_DIR = "venv"
-local function create_installer(python_executable, pip_executable, packages)
+local function create_installer(python_executable, packages)
return installers.pipe {
std.ensure_executables {
{
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 {})
@@ -30,7 +30,10 @@ local function create_installer(python_executable, pip_executable, packages)
-- 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, pip_executable), vim.list_extend({ "install", "-U" }, pkgs))
+
+ local install_command = { "-m", "pip", "install", "-U" }
+ vim.list_extend(install_command, settings.current.pip.install_args)
+ c.run(M.executable(server.root_dir, "python"), vim.list_extend(install_command, pkgs))
c.spawn(callback)
end,
@@ -38,8 +41,8 @@ local function create_installer(python_executable, pip_executable, packages)
end
function M.packages(packages)
- local py3 = create_installer("python3", "pip3", packages)
- local py = create_installer("python", "pip", packages)
+ local py3 = create_installer("python3", packages)
+ local py = create_installer("python", 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
diff --git a/lua/nvim-lsp-installer/installers/std.lua b/lua/nvim-lsp-installer/installers/std.lua
index c94cde2f..b9e6f74f 100644
--- a/lua/nvim-lsp-installer/installers/std.lua
+++ b/lua/nvim-lsp-installer/installers/std.lua
@@ -10,7 +10,7 @@ local M = {}
function M.download_file(url, out_file)
return installers.when {
unix = function(server, callback, context)
- context.stdio_sink.stdout(("Downloading file %q..."):format(url))
+ context.stdio_sink.stdout(("Downloading file %q...\n"):format(url))
process.attempt {
jobs = {
process.lazy_spawn("wget", {
diff --git a/lua/nvim-lsp-installer/process.lua b/lua/nvim-lsp-installer/process.lua
index 1b272f65..999b1a52 100644
--- a/lua/nvim-lsp-installer/process.lua
+++ b/lua/nvim-lsp-installer/process.lua
@@ -230,7 +230,7 @@ end
function M.attempt(opts)
local jobs, on_finish, on_iterate = opts.jobs, opts.on_finish, opts.on_iterate
if #jobs == 0 then
- error "process.attempt(...) need at least one job."
+ error "process.attempt(...) needs at least one job."
end
local spawn, on_job_exit
diff --git a/lua/nvim-lsp-installer/settings.lua b/lua/nvim-lsp-installer/settings.lua
index 7a61510f..0eff752a 100644
--- a/lua/nvim-lsp-installer/settings.lua
+++ b/lua/nvim-lsp-installer/settings.lua
@@ -20,6 +20,14 @@ local DEFAULT_SETTINGS = {
},
},
+ pip = {
+ -- These args will be added to `pip install` calls. Note that setting extra args might impact intended behavior
+ -- and is not recommended.
+ --
+ -- Example: { "--proxy", "https://proxyserver" }
+ install_args = {},
+ },
+
-- Controls to which degree logs are written to the log file. It's useful to set this to vim.log.levels.DEBUG when
-- debugging issues with server installations.
log_level = vim.log.levels.INFO,
@@ -37,10 +45,10 @@ local DEFAULT_SETTINGS = {
local M = {}
+M.current = DEFAULT_SETTINGS
+
function M.set(opts)
- M.current = vim.tbl_deep_extend("force", DEFAULT_SETTINGS, opts)
+ M.current = vim.tbl_deep_extend("force", M.current, opts)
end
-M.current = DEFAULT_SETTINGS
-
return M