feat(debug): add lazy dap setup

This commit is contained in:
Bryan Ramos 2026-04-30 13:28:31 -04:00
parent f11e6a02db
commit d41a3d64a7
4 changed files with 153 additions and 3 deletions

View file

@ -12,15 +12,21 @@
"log-highlight.nvim": { "branch": "main", "commit": "ca88628f6dd3b9bb46f9a7401669e24cf7de47a4" },
"lualine.nvim": { "branch": "master", "commit": "131a558e13f9f28b15cd235557150ccb23f89286" },
"mason-lspconfig.nvim": { "branch": "main", "commit": "0c2823e0418f3d9230ff8b201c976e84de1cb401" },
"mason-nvim-dap.nvim": { "branch": "main", "commit": "9a10e096703966335bd5c46c8c875d5b0690dade" },
"mason.nvim": { "branch": "main", "commit": "cb8445f8ce85d957416c106b780efd51c6298f89" },
"neo-tree.nvim": { "branch": "main", "commit": "19d20a99bf0061a5ecc4343d2f09fa713306c965" },
"nui.nvim": { "branch": "main", "commit": "de740991c12411b663994b2860f1a4fd0937c130" },
"nvim-cmp": { "branch": "main", "commit": "a1d504892f2bc56c2e79b65c6faded2fd21f3eca" },
"nvim-dap": { "branch": "master", "commit": "45a69eba683a2c448dd9ecfc4de89511f0646b5f" },
"nvim-dap-ui": { "branch": "master", "commit": "1a66cabaa4a4da0be107d5eda6d57242f0fe7e49" },
"nvim-dap-virtual-text": { "branch": "master", "commit": "fbdb48c2ed45f4a8293d0d483f7730d24467ccb6" },
"nvim-lspconfig": { "branch": "master", "commit": "f7e89f3d19fb436e1fbeff3bf4291eef35da94e3" },
"nvim-navic": { "branch": "master", "commit": "f5eba192f39b453675d115351808bd51276d9de5" },
"nvim-nio": { "branch": "master", "commit": "21f5324bfac14e22ba26553caf69ec76ae8a7662" },
"nvim-treesitter": { "branch": "main", "commit": "df7489eeea351bece7fd0f9c825be5cb6a1438f0" },
"nvim-web-devicons": { "branch": "master", "commit": "4fc505ac7bd7692824a142e96e5f529c133862f8" },
"plenary.nvim": { "branch": "master", "commit": "74b06c6c75e4eeb3108ec01852001636d85a932b" },
"telescope-dap.nvim": { "branch": "master", "commit": "783366bd6c1e7fa0a5c59c07db37f49c805a28df" },
"telescope.nvim": { "branch": "0.1.x", "commit": "a0bbec21143c7bc5f8bb02e0005fa0b982edc026" },
"todo-comments.nvim": { "branch": "main", "commit": "31e3c38ce9b29781e4422fc0322eb0a21f4e8668" },
"treesitter-parser-registry": { "branch": "main", "commit": "6eb15358bb9fc88f0d3401d8538d56652e9bdf3c" },

145
lua/plugins/debug.lua Normal file
View file

@ -0,0 +1,145 @@
local dap_adapters = {
"python",
"codelldb",
"bash",
"js",
}
return {
{
"mfussenegger/nvim-dap",
dependencies = {
"williamboman/mason.nvim",
"jay-babu/mason-nvim-dap.nvim",
"nvim-neotest/nvim-nio",
"rcarriga/nvim-dap-ui",
"theHamsta/nvim-dap-virtual-text",
"nvim-telescope/telescope-dap.nvim",
},
cmd = {
"DapContinue",
"DapDisconnect",
"DapInstall",
"DapLoadLaunchJSON",
"DapNew",
"DapRestartFrame",
"DapSetLogLevel",
"DapShowLog",
"DapStepInto",
"DapStepOut",
"DapStepOver",
"DapTerminate",
"DapToggleBreakpoint",
"DapUninstall",
},
keys = {
{ "<leader>db", function() require("dap").toggle_breakpoint() end, desc = "Toggle Breakpoint" },
{ "<leader>dB", function() require("dap").set_breakpoint(vim.fn.input("Breakpoint condition: ")) end, desc = "Conditional Breakpoint" },
{ "<leader>dc", function() require("dap").continue() end, desc = "Continue" },
{ "<leader>di", function() require("dap").step_into() end, desc = "Step Into" },
{ "<leader>do", function() require("dap").step_over() end, desc = "Step Over" },
{ "<leader>dO", function() require("dap").step_out() end, desc = "Step Out" },
{ "<leader>dr", function() require("dap").repl.toggle() end, desc = "Toggle REPL" },
{ "<leader>dl", function() require("dap").run_last() end, desc = "Run Last" },
{ "<leader>du", function() require("dapui").toggle() end, desc = "Toggle Debug UI" },
{ "<leader>dt", function() require("dap").terminate() end, desc = "Terminate" },
{ "<leader>de", function() require("dapui").eval() end, mode = { "n", "v" }, desc = "Evaluate" },
{ "<leader>ds", function() require("telescope").extensions.dap.configurations() end, desc = "Debug Configurations" },
{ "<leader>dS", function() require("telescope").extensions.dap.list_breakpoints() end, desc = "Debug Breakpoints" },
},
config = function()
local dap = require("dap")
local dapui = require("dapui")
require("mason").setup()
require("mason-nvim-dap").setup({
ensure_installed = dap_adapters,
automatic_installation = false,
handlers = {},
})
require("nvim-dap-virtual-text").setup({
commented = true,
})
dapui.setup({
layouts = {
{
elements = {
{ id = "scopes", size = 0.45 },
{ id = "breakpoints", size = 0.15 },
{ id = "stacks", size = 0.25 },
{ id = "watches", size = 0.15 },
},
position = "right",
size = 50,
},
{
elements = {
{ id = "repl", size = 0.5 },
{ id = "console", size = 0.5 },
},
position = "bottom",
size = 10,
},
},
})
vim.fn.sign_define("DapBreakpoint", { text = "B", texthl = "DiagnosticSignError" })
vim.fn.sign_define("DapBreakpointCondition", { text = "C", texthl = "DiagnosticSignWarn" })
vim.fn.sign_define("DapLogPoint", { text = "L", texthl = "DiagnosticSignInfo" })
vim.fn.sign_define("DapStopped", { text = ">", texthl = "DiagnosticSignWarn", linehl = "Visual" })
vim.fn.sign_define("DapBreakpointRejected", { text = "R", texthl = "DiagnosticSignError" })
dap.listeners.before.attach.dapui_config = function()
dapui.open()
end
dap.listeners.before.launch.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
dap.adapters["pwa-node"] = {
type = "server",
host = "localhost",
port = "${port}",
executable = {
command = vim.fn.stdpath("data") .. "/mason/bin/js-debug-adapter",
args = { "${port}" },
},
}
local js_configurations = {
{
type = "pwa-node",
request = "launch",
name = "Node: Launch file",
program = "${file}",
cwd = "${workspaceFolder}",
console = "integratedTerminal",
},
{
type = "pwa-node",
request = "attach",
name = "Node: Attach process",
processId = require("dap.utils").pick_process,
cwd = "${workspaceFolder}",
},
}
dap.configurations.javascript = js_configurations
dap.configurations.typescript = js_configurations
dap.configurations.javascriptreact = js_configurations
dap.configurations.typescriptreact = js_configurations
pcall(function()
require("telescope").load_extension("dap")
end)
end,
},
}

View file

@ -1,3 +1 @@
return {
{ "jay-babu/mason-nvim-dap.nvim", enabled = false },
}
return {}

View file

@ -82,6 +82,7 @@ return {
{ "<leader>G", group = "Git"},
{ "<leader>f", group = "Files"},
{ "<leader>c", group = "Code"},
{ "<leader>d", group = "Debug"},
{ "<leader>g", group = "Goto"},
},
},