mirror of https://gitlab.com/baco/dotconf.git
feat(LSP): Refactor alternative executables for linters
Test for new executables, for different checkers, for Python LSP only if the virtual environment directory has been found. The previous behavior could have found executables for such linters on different places, as they could have been appearing outside a virtual environment directory (if the `venv_dir` variable tested as an empty string). Such behavior could lead to undefined behaviors.
This commit is contained in:
parent
8418e53327
commit
8d626d2188
|
@ -36,21 +36,23 @@ local pylsp_settings = {
|
|||
}
|
||||
|
||||
local venv_dir = vim.fn.finddir(".venv/", vim.fn.expand("%:p:h") .. ";")
|
||||
local python_exec = vim.fn.findfile("python", venv_dir .. "/bin;")
|
||||
if venv_dir ~= "" and python_exec ~= "" then
|
||||
if venv_dir ~= "" then
|
||||
local python_exec = vim.fn.findfile("python", venv_dir .. "/bin;")
|
||||
if 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
|
||||
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
|
||||
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
|
||||
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
|
||||
end
|
||||
|
||||
return { settings = { pylsp = pylsp_settings } }
|
||||
|
|
Loading…
Reference in New Issue