aboutsummaryrefslogtreecommitdiffstats
path: root/lua/nvim-lsp-installer/servers/pylsp/init.lua
diff options
context:
space:
mode:
authorFymyte <34305318+Fymyte@users.noreply.github.com>2021-12-08 00:48:06 +0100
committerGitHub <noreply@github.com>2021-12-08 00:48:06 +0100
commitfecd93079da2fa5c278d5f11e681872e0406b37e (patch)
tree8c9ae6e2cc0f9c1f87e0bfeb80fa6cf9a645c503 /lua/nvim-lsp-installer/servers/pylsp/init.lua
parentinitial healthcheck integration (#321) (diff)
downloadmason-fecd93079da2fa5c278d5f11e681872e0406b37e.tar
mason-fecd93079da2fa5c278d5f11e681872e0406b37e.tar.gz
mason-fecd93079da2fa5c278d5f11e681872e0406b37e.tar.bz2
mason-fecd93079da2fa5c278d5f11e681872e0406b37e.tar.lz
mason-fecd93079da2fa5c278d5f11e681872e0406b37e.tar.xz
mason-fecd93079da2fa5c278d5f11e681872e0406b37e.tar.zst
mason-fecd93079da2fa5c278d5f11e681872e0406b37e.zip
add :PylspInstall command for managing 3rd party pylsp plugins (#318)
Diffstat (limited to 'lua/nvim-lsp-installer/servers/pylsp/init.lua')
-rw-r--r--lua/nvim-lsp-installer/servers/pylsp/init.lua28
1 files changed, 28 insertions, 0 deletions
diff --git a/lua/nvim-lsp-installer/servers/pylsp/init.lua b/lua/nvim-lsp-installer/servers/pylsp/init.lua
index e3da8e21..9905dd68 100644
--- a/lua/nvim-lsp-installer/servers/pylsp/init.lua
+++ b/lua/nvim-lsp-installer/servers/pylsp/init.lua
@@ -1,5 +1,7 @@
local server = require "nvim-lsp-installer.server"
local pip3 = require "nvim-lsp-installer.installers.pip3"
+local process = require "nvim-lsp-installer.process"
+local notify = require "nvim-lsp-installer.notify"
return function(name, root_dir)
return server.Server:new {
@@ -10,6 +12,32 @@ return function(name, root_dir)
installer = pip3.packages { "python-lsp-server[all]" },
default_options = {
cmd = { pip3.executable(root_dir, "pylsp") },
+ commands = {
+ PylspInstall = {
+ function(...)
+ -- `nargs+` requires at least one argument -> no empty table
+ local plugins = { ... }
+ local plugins_str = table.concat(plugins, ", ")
+ notify(("Installing %q..."):format(plugins_str))
+ process.spawn(
+ pip3.executable(root_dir, "pip"),
+ {
+ args = vim.list_extend({ "install", "-U", "--disable-pip-version-check" }, plugins),
+ stdio_sink = process.simple_sink(),
+ },
+ vim.schedule_wrap(function(success)
+ if success then
+ notify(("Successfully installed %q"):format(plugins_str))
+ else
+ notify("Failed to install requested plugins.", vim.log.levels.ERROR)
+ end
+ end)
+ )
+ end,
+ description = "Installs the provided packages in the same venv as pylsp.",
+ ["nargs=+"] = true,
+ },
+ },
},
}
end