From 1d5ca0aa2971d2485575ed7c5efad17144cb3fb1 Mon Sep 17 00:00:00 2001 From: pablu Date: Sun, 22 Mar 2026 18:04:35 +0100 Subject: Initial commit --- dot_config/nvim/lua/plugins/dap.lua | 77 +++++++++++++++++++++++++++++++++++++ 1 file changed, 77 insertions(+) create mode 100644 dot_config/nvim/lua/plugins/dap.lua (limited to 'dot_config/nvim/lua/plugins/dap.lua') diff --git a/dot_config/nvim/lua/plugins/dap.lua b/dot_config/nvim/lua/plugins/dap.lua new file mode 100644 index 0000000..6d63dfa --- /dev/null +++ b/dot_config/nvim/lua/plugins/dap.lua @@ -0,0 +1,77 @@ +return { + "mfussenegger/nvim-dap", + event = "VeryLazy", + dependencies = { + "rcarriga/nvim-dap-ui", + "nvim-neotest/nvim-nio", + "jay-babu/mason-nvim-dap.nvim", + "theHamsta/nvim-dap-virtual-text", + }, + config = function() + local mason_dap = require("mason-nvim-dap") + local dap = require("dap") + local ui = require("dapui") + local dap_virtual_text = require("nvim-dap-virtual-text") + + -- Dap Virtual Text + dap_virtual_text.setup() + + mason_dap.setup({ + ensure_installed = { "python" }, + automatic_installation = true, + handlers = { + function(config) + require("mason-nvim-dap").default_setup(config) + end, + }, + }) + + -- Configurations + 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, + }, + }, + } + + -- Dap UI + + ui.setup() + + vim.fn.sign_define("DapBreakpoint", { text = "🐞" }) + + dap.listeners.before.attach.dapui_config = function() + ui.open() + end + dap.listeners.before.launch.dapui_config = function() + ui.open() + end + dap.listeners.before.event_terminated.dapui_config = function() + ui.close() + end + dap.listeners.before.event_exited.dapui_config = function() + ui.close() + end + end +} -- cgit 1.3.1