From 28ebd31fb9b256fb7545ff4eb9ef49398025dbaa Mon Sep 17 00:00:00 2001 From: Fabio Montefuscolo Date: Thu, 4 Apr 2024 14:35:22 +0200 Subject: [PATCH] feat: attach to debug py --- mappings.lua | 12 +++++++++++- plugins.lua | 8 +++++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/mappings.lua b/mappings.lua index 9228976..4e7586e 100644 --- a/mappings.lua +++ b/mappings.lua @@ -35,7 +35,17 @@ M.dap_python = { n = { ["dpr"] = { function() - require('dap-python').test_method() + local dap = require('dap') + dap.run({ + type = 'python', + request = 'attach', + name = 'Debugpy', + justMyCode = false, + connect = { + host = '127.0.0.1', + port = 5678, + } + }) end } } diff --git a/plugins.lua b/plugins.lua index e664cc0..3e8bcb5 100644 --- a/plugins.lua +++ b/plugins.lua @@ -16,6 +16,12 @@ local plugins = { dap.listeners.after.event_initialized["dapui_config"] = function() dapui.open() end + dap.listeners.before.event_terminated["dapui_config"] = function() + dapui.close() + end + dap.listeners.before.event_exited["dapui_config"] = function() + dapui.close() + end end }, { @@ -34,7 +40,7 @@ local plugins = { config = function(_, opts) local pyenv = os.getenv("VIRTUAL_ENV") or "/usr" local path = pyenv .. "/bin/python3" - require("dap-python").setup(path) + require("dap-python").setup(path, opts) require("core.utils").load_mappings("dap_python") end, },