mirror of
https://gitlab.com/baco/dotconf.git
synced 2024-06-18 13:57:04 +00:00
The previous name was a little bit to repetitive. It was confusing with so many things called the same, in the same file.
43 lines
1.7 KiB
Lua
43 lines
1.7 KiB
Lua
local pylsp_settings = {
|
|
configurationSources = {"flake8", "pycodestyle"}, -- config files to read from, not plugins enabled
|
|
plugins = {
|
|
flake8 = {
|
|
enabled = true,
|
|
maxLineLength = 79,
|
|
-- ignore = {"E501", "W293", "W391"}, -- Those are also checked by pylint
|
|
},
|
|
pylint = {
|
|
enabled = true,
|
|
args = {
|
|
"--max-line-length=79",
|
|
"--disable=missing-docstring,invalid-name,redefined-outer-name,logging-format-interpolation",
|
|
"--disable=line-too-long,trailing-whitespace,trailing-newlines", -- Checked by flake8
|
|
}
|
|
},
|
|
pylsp_mypy = {enabled = true},
|
|
pycodestyle = {enabled = false}, -- covered in flake8
|
|
pyflakes = {enabled = false}, -- covered in flake8
|
|
-- mccabe = {enabled = false}, -- not covered in flake8 by default; PyLSP doesn't handle the option
|
|
}
|
|
}
|
|
|
|
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 } }
|