diff --git a/lua/kickstart/plugins/debug.lua b/lua/kickstart/plugins/debug.lua index b369daae..a66b170c 100644 --- a/lua/kickstart/plugins/debug.lua +++ b/lua/kickstart/plugins/debug.lua @@ -82,5 +82,23 @@ return { -- Install golang specific config require('dap-go').setup() - end, + pythonPath = function() + --The below line will work for virtualenvwrapper, as vim.env.VIRTUAL_ENV points to the active env directory if you use it + --Test the variable by running :lua print(vim.env.VIRTUAL_ENV) and find your path from there if it is defined + if vim.env.VIRTUAL_ENV then return vim.env.VIRTUAL_ENV ..'/bin/python' end + -- debugpy supports launching an application with a different interpreter then the one used to launch debugpy itself. + -- The code below looks for a `venv` or `.venv` folder in the current directly and uses the python within. + -- You could adapt this - to for example use the `VIRTUAL_ENV` environment variable (done above). + local cwd = vim.fn.getcwd() + if vim.fn.executable(cwd .. '/venv/bin/python') == 1 then + return cwd .. '/venv/bin/python' + elseif vim.fn.executable(cwd .. '/.venv/bin/python') == 1 then + return cwd .. '/.venv/bin/python' + else + return '/usr/bin/python3' + end + end; + } + } +end, }