return { "jayp0521/mason-nvim-dap.nvim", cond = false, opts = { ensure_installed = { "python", "codelldb", }, automatic_install = true, }, dependencies = { "williamboman/mason.nvim", "rcarriga/nvim-dap-ui", "mfussenegger/nvim-dap", { "simrat39/rust-tools.nvim", ft = "rust" }, { "mfussenegger/nvim-dap-python", ft = "python" }, "theHamsta/nvim-dap-virtual-text", "williamboman/mason.nvim", }, keys = { { "dd", function() require("dap").toggle_breakpoint() end, desc = "Set breakpoint", }, { "dD", function() require("dap").set_breakpoint(vim.fn.input("Breakpoint condition: ")) end, desc = "Set Breakpoint with Condition", }, { "dpm", function() require("dap-python").test_method() end, desc = "Test [M]ethod", }, { "dpc", function() require("dap-python").test_class() end, desc = "Test [C]lass", }, { "dps", function() require("dap-python").debug_selection() end, desc = "Debug [S]election", }, { "dt", function() require("dapui").toggle() end, desc = "[T]oggle DAP-UI", }, { "dc", function() require("dap").continue() end, desc = "Launch Debug Sessions and Resume Execution", }, { "di", function() require("dap").step_into() end, desc = "Step [I]nto Code", }, { "do", function() require("dap").step_over() end, desc = "Step [O]ver Code", }, { "dO", function() require("dap").step_out() end, desc = "Step [O]ut of Code", }, { "dT", function() require("dap").terminate() end, desc = "[T]erminate", }, { "dl", function() require("dap").run_last() end, desc = "Run [L]ast", }, { "dh", function() require("dap.ui.widgets").hover() end, desc = "[H]over", }, { "dP", function() require("dap.ui.widgets").preview() end, desc = "[P]review", }, { "df", function() local widgets = require("dap.ui.widgets") widgets.centered_float(widgets.frames) end, desc = "[F]rames", }, { "ds", function() local widgets = require("dap.ui.widgets") widgets.centered_float(widgets.scopes) end, desc = "[S]copes", }, { "", function() require("dap").continue() end, desc = "DAP Continue", }, { "", function() require("dap").step_over() end, desc = "DAP Step Over", }, { "", function() require("dap").step_into() end, desc = "DAP Step Into", }, { "", function() require("dap").step_out() end, desc = "DAP Step Out", }, }, config = function() local dap = require("dap") local dapui = require("dapui") vim.fn.sign_define("DapBreakpoint", { text = "", texthl = "DiagnosticSignError", linehl = "", numhl = "" }) 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 local mason_registry = require("mason-registry") dapui.setup() require("nvim-dap-virtual-text").setup({}) -- Python local debugpy = mason_registry.get_package("debugpy") local debugpy_path = debugpy:get_install_path() .. "/venv/bin/python" require("dap-python").setup(debugpy_path) local codelldb = mason_registry.get_package("codelldb") local codelldb_path = codelldb:get_install_path() .. "/codelldb" local liblldb_path = codelldb:get_install_path() .. "/extension/lldb/lib/liblldb.so" -- Rust require("rust-tools").setup({ dap = { adapter = require("rust-tools.dap").get_codelldb_adapter(codelldb_path, liblldb_path), }, }) -- dap.configurations.rust = {} -- C/C++ -- FIX: not working dap.adapters.lldb = { type = "executable", command = codelldb_path, name = "lldb", } dap.configurations.cpp = { { name = "Launch", type = "lldb", request = "launch", program = function() return vim.fn.input("Path to executable: ", vim.fn.getcwd() .. "/", "file") end, cwd = "${workspaceFolder}", stopOnEntry = false, args = {}, -- 💀 -- if you change `runInTerminal` to true, you might need to change the yama/ptrace_scope setting: -- -- echo 0 | sudo tee /proc/sys/kernel/yama/ptrace_scope -- -- Otherwise you might get the following error: -- -- Error on launch: Failed to attach to the target process -- -- But you should be aware of the implications: -- https://www.kernel.org/doc/html/latest/admin-guide/LSM/Yama.html -- runInTerminal = false, }, } -- If you want to use this for Rust and C, add something like this: dap.configurations.c = dap.configurations.cpp end, }