summaryrefslogtreecommitdiff
path: root/lua/user/dap.lua
diff options
context:
space:
mode:
Diffstat (limited to 'lua/user/dap.lua')
-rw-r--r--lua/user/dap.lua36
1 files changed, 32 insertions, 4 deletions
diff --git a/lua/user/dap.lua b/lua/user/dap.lua
index b51dfd7..fb95eee 100644
--- a/lua/user/dap.lua
+++ b/lua/user/dap.lua
@@ -13,16 +13,44 @@ if not dap_ui_status_ok then
return
end
-if not dap_install_status_ok then
- return
-end
-
dap_install.setup({
installation_path = vim.fn.stdpath('data') .. "/dapinstall/",
})
dap_install.config("python", {})
+--dap setup
+
+dap.adapters.python = {
+ type = 'executable';
+ command = 'python';
+ args = { '-m', 'debugpy.adapter' };
+}
+dap.configurations.python = {
+ {
+ -- The first three options are required by nvim-dap
+ type = 'python'; -- the type here established the link to the adapter definition: `dap.adapters.python`
+ request = 'launch';
+ name = "Launch file";
+
+ -- Options below are for debugpy, see https://github.com/microsoft/debugpy/wiki/Debug-configuration-settings for supported options
+
+ program = "${file}"; -- This configuration will launch the current file if used.
+ pythonPath = function()
+ -- 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.
+ 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/python'
+ end
+ end;
+ },
+}
-- dapui.setup()
dapui.setup({
icons = { expanded = "▾", collapsed = "▸" },