123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121 |
- local M = {}
- M.config = function()
- lvim.builtin.dap = {
- active = false,
- on_config_done = nil,
- breakpoint = {
- text = lvim.icons.ui.Bug,
- texthl = "LspDiagnosticsSignError",
- linehl = "",
- numhl = "",
- },
- breakpoint_rejected = {
- text = lvim.icons.ui.Bug,
- texthl = "LspDiagnosticsSignHint",
- linehl = "",
- numhl = "",
- },
- stopped = {
- text = lvim.icons.ui.BoldArrowRight,
- texthl = "LspDiagnosticsSignInformation",
- linehl = "DiagnosticUnderlineInfo",
- numhl = "LspDiagnosticsSignInformation",
- },
- ui = {
- auto_open = true,
- },
- }
- end
- M.setup = function()
- local dap = require "dap"
- 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 = { "<cmd>lua require'dap'.toggle_breakpoint()<cr>", "Toggle Breakpoint" },
- b = { "<cmd>lua require'dap'.step_back()<cr>", "Step Back" },
- c = { "<cmd>lua require'dap'.continue()<cr>", "Continue" },
- C = { "<cmd>lua require'dap'.run_to_cursor()<cr>", "Run To Cursor" },
- d = { "<cmd>lua require'dap'.disconnect()<cr>", "Disconnect" },
- g = { "<cmd>lua require'dap'.session()<cr>", "Get Session" },
- i = { "<cmd>lua require'dap'.step_into()<cr>", "Step Into" },
- o = { "<cmd>lua require'dap'.step_over()<cr>", "Step Over" },
- u = { "<cmd>lua require'dap'.step_out()<cr>", "Step Out" },
- p = { "<cmd>lua require'dap'.pause()<cr>", "Pause" },
- r = { "<cmd>lua require'dap'.repl.toggle()<cr>", "Toggle Repl" },
- s = { "<cmd>lua require'dap'.continue()<cr>", "Start" },
- q = { "<cmd>lua require'dap'.close()<cr>", "Quit" },
- U = { "<cmd>lua require'dapui'.toggle()<cr>", "Toggle UI" },
- }
- if lvim.builtin.dap.on_config_done then
- lvim.builtin.dap.on_config_done(dap)
- end
- end
- M.setup_ui = function()
- local dap = require "dap"
- local dapui = require "dapui"
- dapui.setup {
- expand_lines = true,
- icons = { expanded = "", collapsed = "", circular = "" },
- mappings = {
- -- Use a table to apply multiple mappings
- expand = { "<CR>", "<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", "<Esc>" },
- },
- },
- }
- 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
|