Files
2025-07-31 20:01:39 +02:00

24 lines
580 B
Lua

local M = {}
local util = require("lspconfig.util")
local path = util.path
M.get_python_path = function(workspace)
-- Use activated virtualenv.
if vim.env.VIRTUAL_ENV then
return path.join(vim.env.VIRTUAL_ENV, "bin", "python")
end
-- Find and use virtualenv in workspace directory.
for _, pattern in ipairs({ "*", ".*" }) do
local match = vim.fn.glob(path.join(workspace, pattern, "pyvenv.cfg"))
if match ~= "" then
return path.join(path.dirname(match), "bin", "python")
end
end
return nil
end
return M