python lsp considers venv
This commit is contained in:
@@ -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
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user