local M = {} M.config = function() lvim.builtin.dap = { active = true, on_config_done = nil, breakpoint = { text = lvim.icons.ui.Bug, texthl = "DiagnosticSignError", linehl = "", numhl = "", }, breakpoint_rejected = { text = lvim.icons.ui.Bug, texthl = "DiagnosticSignError", linehl = "", numhl = "", }, stopped = { text = lvim.icons.ui.BoldArrowRight, texthl = "DiagnosticSignWarn", linehl = "Visual", numhl = "DiagnosticSignWarn", }, ui = { auto_open = true, config = { expand_lines = true, icons = { expanded = "", collapsed = "", circular = "" }, mappings = { -- Use a table to apply multiple mappings expand = { "", "<2-LeftMouse>" }, open = "o", remove = "d", edit = "e", repl = "r", toggle = "t", }, layouts = { { elements = { { id = "scopes", size = 0.33 }, { id = "breakpoints", size = 0.17 }, { id = "stacks", size = 0.25 }, { id = "watches", size = 0.25 }, }, size = 0.33, position = "right", }, { elements = { { id = "repl", size = 0.45 }, { id = "console", size = 0.55 }, }, size = 0.27, position = "bottom", }, }, floating = { max_height = 0.9, max_width = 0.5, -- Floats will be treated as percentage of your screen. border = vim.g.border_chars, -- Border style. Can be 'single', 'double' or 'rounded' mappings = { close = { "q", "" }, }, }, }, }, } end M.setup = function() local status_ok, dap = pcall(require, "dap") if not status_ok then return end if lvim.use_icons then vim.fn.sign_define("DapBreakpoint", lvim.builtin.dap.breakpoint) vim.fn.sign_define("DapBreakpointRejected", lvim.builtin.dap.breakpoint_rejected) vim.fn.sign_define("DapStopped", lvim.builtin.dap.stopped) end lvim.builtin.which_key.mappings["d"] = { name = "Debug", t = { "lua require'dap'.toggle_breakpoint()", "Toggle Breakpoint" }, b = { "lua require'dap'.step_back()", "Step Back" }, c = { "lua require'dap'.continue()", "Continue" }, C = { "lua require'dap'.run_to_cursor()", "Run To Cursor" }, d = { "lua require'dap'.disconnect()", "Disconnect" }, g = { "lua require'dap'.session()", "Get Session" }, i = { "lua require'dap'.step_into()", "Step Into" }, o = { "lua require'dap'.step_over()", "Step Over" }, u = { "lua require'dap'.step_out()", "Step Out" }, p = { "lua require'dap'.pause()", "Pause" }, r = { "lua require'dap'.repl.toggle()", "Toggle Repl" }, s = { "lua require'dap'.continue()", "Start" }, q = { "lua require'dap'.close()", "Quit" }, U = { "lua require'dapui'.toggle()", "Toggle UI" }, } if lvim.builtin.dap.on_config_done then lvim.builtin.dap.on_config_done(dap) end end M.setup_ui = function() local status_ok, dap = pcall(require, "dap") if not status_ok then return end local dapui = require "dapui" dapui.setup(lvim.builtin.dap.ui.config) if lvim.builtin.dap.ui.auto_open then 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 end end return M