python lsp considers venv

This commit is contained in:
2026-04-04 16:53:28 +02:00
parent 70b4a808c7
commit 14d005b58e
+12 -1
View File
@@ -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 = {
@@ -46,9 +57,9 @@ return {
vim.lsp.config("pyright", {
settings = {
python = {
pythonPath = get_venv_python(),
analysis = {
typeCheckingMode = "basic",
extraPaths = {}, -- Add extra import paths if needed
},
},
},