python lsp considers venv
This commit is contained in:
@@ -32,6 +32,17 @@ return {
|
|||||||
{
|
{
|
||||||
"neovim/nvim-lspconfig",
|
"neovim/nvim-lspconfig",
|
||||||
config = function()
|
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
|
-- Lua
|
||||||
vim.lsp.config("lua_ls", {
|
vim.lsp.config("lua_ls", {
|
||||||
settings = {
|
settings = {
|
||||||
@@ -42,13 +53,13 @@ return {
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
-- Python
|
-- Python
|
||||||
vim.lsp.config("pyright", {
|
vim.lsp.config("pyright", {
|
||||||
settings = {
|
settings = {
|
||||||
python = {
|
python = {
|
||||||
|
pythonPath = get_venv_python(),
|
||||||
analysis = {
|
analysis = {
|
||||||
typeCheckingMode = "basic",
|
typeCheckingMode = "basic",
|
||||||
extraPaths = {}, -- Add extra import paths if needed
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user