diff --git a/term/.config/nvim/lua/plugins/lsp-config.lua b/term/.config/nvim/lua/plugins/lsp-config.lua index b51cb3c..db99b4f 100644 --- a/term/.config/nvim/lua/plugins/lsp-config.lua +++ b/term/.config/nvim/lua/plugins/lsp-config.lua @@ -32,6 +32,17 @@ return { { "neovim/nvim-lspconfig", config = function() + local function get_venv_python() + local cwd = vim.fn.getcwd() + local handles = vim.fn.glob(cwd .. "/.venv*", true, true) + for _, v in ipairs(handles) do + if vim.fn.isdirectory(v) == 1 then + return v .. "/bin/python" + end + end + return vim.fn.exepath("python3") or "python3" + end + -- Lua vim.lsp.config("lua_ls", { settings = { @@ -42,13 +53,13 @@ return { }, }) - -- Python + -- Python vim.lsp.config("pyright", { settings = { python = { + pythonPath = get_venv_python(), analysis = { typeCheckingMode = "basic", - extraPaths = {}, -- Add extra import paths if needed }, }, },