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 -- Python dap.adapters.python = { type = "executable", command = vim.fn.stdpath("data") .. "/mason/bin/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, }, } -- C/C++/Rust dap.adapters.lldb = { type = "executable", command = vim.fn.stdpath("data") .. "/mason/packages/codelldb/codelldb", -- adjust as needed, must be absolute 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 dap.configurations.rust = dap.configurations.cpp -- JavaScript dap.adapters.firefox = { type = "executable", command = "node", args = { vim.fn.stdpath("data") .. "/mason/packages/firefox-debug-adapter/dist/adapter.bundle.js" }, } dap.configurations.typescript = { { name = "Debug with Librewolf", type = "firefox", request = "launch", reAttach = true, url = "http://localhost:3000", webRoot = "${workspaceFolder}", firefoxExecutable = "/usr/bin/librewolf", }, } dap.configurations.javascript = { { name = "Debug with Librewolf", type = "firefox", request = "launch", reAttach = true, url = "http://localhost:3000", webRoot = "${workspaceFolder}", firefoxExecutable = "/usr/bin/librewolf", }, } -- Bash dap.adapters.bashdb = { type = "executable", command = vim.fn.stdpath("data") .. "/mason/packages/bash-debug-adapter/bash-debug-adapter", name = "bashdb", } dap.configurations.sh = { { type = "bashdb", request = "launch", name = "Launch file", showDebugOutput = true, pathBashdb = vim.fn.stdpath("data") .. "/mason/packages/bash-debug-adapter/extension/bashdb_dir/bashdb", pathBashdbLib = vim.fn.stdpath("data") .. "/mason/packages/bash-debug-adapter/extension/bashdb_dir", trace = true, file = "${file}", program = "${file}", cwd = "${workspaceFolder}", pathCat = "bat", pathBash = "/bin/zash", pathMkfifo = "mkfifo", pathPkill = "pkill", args = {}, env = {}, terminalKind = "integrated", }, }