From d3471e3dc8847e5e7b8e25c3ea75270d39d00888 Mon Sep 17 00:00:00 2001 From: Tim Huizinga Date: Mon, 2 Mar 2026 15:11:16 +0100 Subject: [PATCH] Properly use uv environments --- nvim/dot-config/nvim/lsp/basedpyright.lua | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/nvim/dot-config/nvim/lsp/basedpyright.lua b/nvim/dot-config/nvim/lsp/basedpyright.lua index 533039c..710624c 100644 --- a/nvim/dot-config/nvim/lsp/basedpyright.lua +++ b/nvim/dot-config/nvim/lsp/basedpyright.lua @@ -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 { settings = { basedpyright = { @@ -5,5 +19,14 @@ return { 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, }