dotfiles/nvim/lua/lsp/server_settings/pylsp.lua

32 lines
1.3 KiB
Lua

local pylsp_settings = {
configurationSources = { "flake8" }, -- tool's config files to override settings from
plugins = {
ruff = { enabled = true }, -- Settings come from $XDG_CONFIG_HOME/ruff/ruff.toml
flake8 = { enabled = true },
pylint = { enabled = true },
pylsp_mypy = { enabled = true },
pycodestyle = { enabled = false }, -- covered in flake8
pyflakes = { enabled = false }, -- covered in flake8
},
}
local venv_dir = vim.fn.finddir(".venv/", vim.fn.expand("%:p:h") .. ";")
local python_exec = vim.fn.findfile("python3", venv_dir .. "/bin;")
if venv_dir ~= "" and python_exec ~= "" then
pylsp_settings.plugins.jedi = {environment = python_exec}
end
local flake8_exec = vim.fn.findfile("flake8", venv_dir .. "/bin;")
if flake8_exec ~= "" then
pylsp_settings.plugins.flake8.executable = flake8_exec
end
local pylint_exec = vim.fn.findfile("pylint", venv_dir .. "/bin;")
if pylint_exec ~= "" then
pylsp_settings.plugins.pylint.executable = pylint_exec
end
local mypy_exec = vim.fn.findfile("mypy", venv_dir .. "/bin;")
if mypy_exec ~= "" or python_exec ~= "" then
pylsp_settings.plugins.pylsp_mypy.overrides = {"--python-executable", python_exec, true}
end
return { settings = { pylsp = pylsp_settings } }