aboutsummaryrefslogtreecommitdiffstats
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
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)
-rw-r--r--README.md3
-rw-r--r--lua/nvim-lsp-installer/servers/pylsp/README.md9
-rw-r--r--lua/nvim-lsp-installer/servers/pylsp/init.lua28
3 files changed, 39 insertions, 1 deletions
diff --git a/README.md b/README.md
index 57f62be7..26098b3b 100644
--- a/README.md
+++ b/README.md
@@ -198,7 +198,7 @@ lsp_installer.settings({
| Puppet | `puppet` |
| PureScript | `purescriptls` |
| Python | `jedi_language_server` |
-| Python | `pylsp` |
+| Python [(docs)][pylsp] | `pylsp` |
| Python | `pyright` |
| ReScript | `rescriptls` |
| Rome | `rome` |
@@ -226,6 +226,7 @@ lsp_installer.settings({
[eslint]: ./lua/nvim-lsp-installer/servers/eslint/README.md
[tflint]: ./lua/nvim-lsp-installer/servers/tflint/README.md
[tsserver]: ./lua/nvim-lsp-installer/servers/tsserver/README.md
+[pylsp]: ./lua/nvim-lsp-installer/servers/pylsp/README.md
## Custom servers
diff --git a/lua/nvim-lsp-installer/servers/pylsp/README.md b/lua/nvim-lsp-installer/servers/pylsp/README.md
new file mode 100644
index 00000000..ce756de3
--- /dev/null
+++ b/lua/nvim-lsp-installer/servers/pylsp/README.md
@@ -0,0 +1,9 @@
+# Pylsp
+
+## Installing pylsp plugins
+Pylsp has [third party plugins](https://github.com/python-lsp/python-lsp-server#3rd-party-plugins) which are not installed by default.
+
+In order for these plugins to work with the `pylsp` server managed by this plugin, they need to be installed in the same [virtual environment](https://docs.python.org/3/library/venv.html) as `pylsp`. For these reasons, there's a convenient `:PylspInstall <packages>` command that does this for you, for example:
+```vim
+:PylspInstall pyls-flake8 pylsp-mypy pyls-isort
+```
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