feat(LSP): Reorganise PyLSP blocks of code

Although the block of code moved is programmatic configuration taking
place before the actual on/off of settings (which could be interpreted
as metadata config), the block of code in question had nothing to do
with the setting of other LSPs than PyLSP.

The whole block is for pre-installing plugins for PyLSP server, or its
plugins'.
This commit is contained in:
Dionisio E Alonso 2024-02-26 10:00:09 -03:00
parent 41115cdd19
commit d89fbb2f40
2 changed files with 26 additions and 26 deletions

View File

@ -1,29 +1,3 @@
--if vim.fn.exists(":PylspInstall") then
-- vim.cmd("PylspInstall pylsp-mypy")
--end
-- https://github.com/williamboman/mason.nvim/discussions/908
local pylsp = require("mason-registry").get_package("python-lsp-server")
pylsp:on("install:success", function ()
local mason_package_path = function(package)
local path = vim.fn.resolve(vim.fn.stdpath("data") .. "/mason/packages/" .. package)
return path
end
local path = mason_package_path("python-lsp-server")
local command = path .. "/venv/bin/python"
local install_cmd = { command, "-m", "pip", "install" }
local pylsp_plugins = { "python-lsp-ruff", "pylsp-mypy" }
vim.schedule(function()
vim.fn.system(vim.list_extend(install_cmd, pylsp_plugins))
end)
local flake8_plugins = { "flake8-pyproject", "flake8-pylint" }
vim.schedule(function()
vim.fn.system(vim.list_extend(install_cmd, flake8_plugins))
end)
end)
local opts = {}
opts.pylsp = require("lsp.server_settings.pylsp")
opts.hls = require("lsp.server_settings.hls")

View File

@ -1,3 +1,29 @@
--if vim.fn.exists(":PylspInstall") then
-- vim.cmd("PylspInstall pylsp-mypy")
--end
-- https://github.com/williamboman/mason.nvim/discussions/908
local pylsp = require("mason-registry").get_package("python-lsp-server")
pylsp:on("install:success", function ()
local mason_package_path = function(package)
local path = vim.fn.resolve(vim.fn.stdpath("data") .. "/mason/packages/" .. package)
return path
end
local path = mason_package_path("python-lsp-server")
local command = path .. "/venv/bin/python"
local install_cmd = { command, "-m", "pip", "install" }
local pylsp_plugins = { "python-lsp-ruff", "pylsp-mypy" }
vim.schedule(function()
vim.fn.system(vim.list_extend(install_cmd, pylsp_plugins))
end)
local flake8_plugins = { "flake8-pyproject", "flake8-pylint" }
vim.schedule(function()
vim.fn.system(vim.list_extend(install_cmd, flake8_plugins))
end)
end)
local pylsp_settings = {
configurationSources = { "flake8" }, -- tool's config files to override settings from
plugins = {