Properly use uv environments

This commit is contained in:
2026-03-02 15:11:16 +01:00
parent 8f11e727db
commit d3471e3dc8

View File

@@ -1,3 +1,17 @@
local function uv_script_interpreter(script_path)
local result = vim.system({ "uv", "python", "find", "--script", script_path }, { text = true }):wait()
if result.code == 0 then
return vim.fn.trim(result.stdout)
end
end
local function uv_interpreter()
local result = vim.system({ "uv", "python", "find" }, { text = true }):wait()
if result.code == 0 then
return vim.fn.trim(result.stdout)
end
end
return { return {
settings = { settings = {
basedpyright = { basedpyright = {
@@ -5,5 +19,14 @@ return {
typeCheckingMode = "standard", typeCheckingMode = "standard",
}, },
}, },
python = {},
}, },
before_init = function(_, config)
local script = vim.api.nvim_buf_get_name(0)
local python = uv_script_interpreter(script)
if not python then
python = uv_interpreter()
end
config.settings.python.pythonPath = python
end,
} }