check for pyrightconfig.json in dap
This commit is contained in:
parent
b87bbaee74
commit
b9cf3aadef
@ -98,6 +98,25 @@ return {
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local function getVenvFromJson(jsonfile)
|
||||||
|
if not vim.fn.filereadable(jsonfile) then
|
||||||
|
return nil
|
||||||
|
end
|
||||||
|
local f = io.open(jsonfile, 'r')
|
||||||
|
if not f then
|
||||||
|
return nil
|
||||||
|
end
|
||||||
|
local data = f:read('*a')
|
||||||
|
f:close()
|
||||||
|
if data then
|
||||||
|
local jdata = vim.json.decode(data)
|
||||||
|
if jdata['venvPath'] ~= nil and jdata['venv'] ~= nil then
|
||||||
|
return jdata['venvPath'] .. '/' .. jdata['venv']
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return nil
|
||||||
|
end
|
||||||
|
|
||||||
local function getPythonEnv()
|
local function getPythonEnv()
|
||||||
local venv = os.getenv('VIRTUAL_ENV')
|
local venv = os.getenv('VIRTUAL_ENV')
|
||||||
if venv ~= nil then
|
if venv ~= nil then
|
||||||
@ -109,6 +128,12 @@ return {
|
|||||||
end
|
end
|
||||||
|
|
||||||
local cwd = vim.fn.getcwd()
|
local cwd = vim.fn.getcwd()
|
||||||
|
|
||||||
|
local jsonVenv = getVenvFromJson(cwd .. '/pyrightconfig.json')
|
||||||
|
if jsonVenv ~= nil then
|
||||||
|
return jsonVenv
|
||||||
|
end
|
||||||
|
|
||||||
if vim.fn.executable(cwd .. '/venv/' .. getVenvSuffix()) == 1 then
|
if vim.fn.executable(cwd .. '/venv/' .. getVenvSuffix()) == 1 then
|
||||||
return cwd .. '/venv/' .. getVenvSuffix()
|
return cwd .. '/venv/' .. getVenvSuffix()
|
||||||
elseif vim.fn.executable(cwd .. '/.venv/' .. getVenvSuffix()) == 1 then
|
elseif vim.fn.executable(cwd .. '/.venv/' .. getVenvSuffix()) == 1 then
|
||||||
|
Loading…
x
Reference in New Issue
Block a user