if vim.g.did_load_dap_plugin then return end vim.g.did_load_dap_plugin = true local dap, dapui = require("dap"), require("dapui") -- UI hooks 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 require('which-key').add({ { "", function() require("dap").continue() end, desc = "debugger: Start" }, { "", function() require("dap").pause() end, desc = "debugger: pause" }, { "", function() require("dap").toggle_breakpoint() end, desc = "debugger: toggle breakpoint" }, { "", function() require("dap").step_over() end, desc = "debugger: step over" }, { "", function() require("dap").step_into() end, desc = "debugger: step into" }, { "", function() require("dap").terminate() end, desc = "debugger: Stop" }, -- Shift+F { "", function() require("dap").step_out() end, desc = "debugger: step out" }, -- Shift+F11 { "", -- Shift+F9 function() vim.ui.input({ prompt = "Condition: " }, function(condition) if condition then require("dap").set_breakpoint(condition) end end) end, desc = "debugger: Conditional Breakpoint" }, { "", function() require("dap").restart_frame() end, desc = "debugger: restart" }, -- Control+F5 { "d", group = "[d]ebug", icon="" }, { "db", function() require("dap").toggle_breakpoint() end, desc = "[d]ebugger: toggle [b]reakpoint (F9)" }, { "dB", function() require("dap").clear_breakpoints() end, desc = "[d]ebugger: clear [B]reakpoints" }, { "dc", function() require("dap").continue() end, desc = "[d]ebugger: start/[c]ontinue (F5)" }, { "dC", function() vim.ui.input({ prompt = "Condition: " }, function(condition) if condition then require("dap").set_breakpoint(condition) end end) end, desc = "[d]ebugger: [C]onditional breakpoint (S-F9)" }, { "di", function() require("dap").step_into() end, desc = "[d]ebugger: step [i]nto (F11)" }, { "do", function() require("dap").step_over() end, desc = "[d]ebugger: step [o]ver (F10)" }, { "dO", function() require("dap").step_out() end, desc = "[d]ebugger: step [O]ut (S-F11)" }, { "dq", function() require("dap").close() end, desc = "[d]ebugger: [q]uit" }, { "dQ", function() require("dap").terminate() end, desc = "[d]ebugger: force [Q]uit(S-F5)" }, { "dp", function() require("dap").pause() end, desc = "[d]ebugger: [p]ause (F6)" }, { "dr", function() require("dap").restart_frame() end, desc = "[d]ebugger: [r]estart (C-F5)" }, { "dR", function() require("dap").repl.toggle() end, desc = "[d]ebugger: toggle [R]EPL" }, { "ds", function() require("dap").run_to_cursor() end, desc = "[d]ebugger: run to cur[s]or" }, { "dE", function() vim.ui.input({ prompt = "Expression: " }, function(expr) if expr then require("dapui").eval(expr, { enter = true }) end end) end, desc = "[d]ebugger: [E]valuate input", }, -- DapUI { "du", function() require("dapui").toggle() end, desc = "[d]ebugger: toggle [u]i" }, { "dh", function() require("dap.ui.widgets").hover() end, desc = "[d]ebugger: [h]over" }, { mode = "v", "dE", function() require("dapui").eval() end, desc = "[d]ebugger: [E]valuate input" }, }) vim.fn.sign_define('DapBreakpoint', { text="", texthl="white" }) vim.fn.sign_define('DapBreakpointCondition', { text='', texthl="white" }) vim.fn.sign_define('DapBreakpointRejected', { text='', texthl="bright_red" }) vim.fn.sign_define('DapLogPoint', { text='󰛿', texthl="white" }) vim.fn.sign_define('DapStopped', { text='󰁕', texthl="orange" })