From bc14e02a1ff43f1a69d2a6755faeec8a5ec26ac9 Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Sun, 16 Apr 2023 21:35:38 +0200 Subject: [PATCH] feat: added extra for dap --- lua/lazyvim/config/init.lua | 7 ++ lua/lazyvim/plugins/extras/dap/core.lua | 92 +++++++++++++++++++++++++ 2 files changed, 99 insertions(+) create mode 100644 lua/lazyvim/plugins/extras/dap/core.lua diff --git a/lua/lazyvim/config/init.lua b/lua/lazyvim/config/init.lua index 24c19aa7..71bdb54f 100644 --- a/lua/lazyvim/config/init.lua +++ b/lua/lazyvim/config/init.lua @@ -19,6 +19,13 @@ local defaults = { }, -- icons used by other plugins icons = { + dap = { + Stopped = { " ", "DiagnosticWarn", "DapStoppedLine" }, + Breakpoint = " ", + BreakpointCondition = " ", + BreakpointRejected = { " ", "DiagnosticError" }, + LogPoint = ".>", + }, diagnostics = { Error = " ", Warn = " ", diff --git a/lua/lazyvim/plugins/extras/dap/core.lua b/lua/lazyvim/plugins/extras/dap/core.lua new file mode 100644 index 00000000..48a5875e --- /dev/null +++ b/lua/lazyvim/plugins/extras/dap/core.lua @@ -0,0 +1,92 @@ +return { + "mfussenegger/nvim-dap", + + dependencies = { + + -- fancy UI for the debugger + { + "rcarriga/nvim-dap-ui", + -- stylua: ignore + keys = { + { "du", function() require("dapui").toggle({ }) end, desc = "Dap UI" } + }, + opts = {}, + config = function(_, opts) + local dap = require("dap") + local dapui = require("dapui") + dapui.setup(opts) + 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, + }, + + -- virtual text for the debugger + { + "theHamsta/nvim-dap-virtual-text", + opts = {}, + }, + + -- which key integration + { + "folke/which-key.nvim", + opts = { + defaults = { + ["d"] = { name = "+debug" }, + ["da"] = { name = "+adapters" }, + }, + }, + }, + + -- mason.nvim integration + { + "jay-babu/mason-nvim-dap.nvim", + dependencies = "mason.nvim", + opts = { + -- Makes a best effort to setup the various debuggers with + -- reasonable debug configurations + automatic_setup = true, + + -- You can provide additional configuration to the handlers, + -- see mason-nvim-dap README for more information + handlers = {}, + + -- You'll need to check that you have the required things installed + -- online, please don't ask me how to install them :) + ensure_installed = { + -- Update this to ensure that you have the debuggers for the langs you want + }, + }, + }, + }, + + -- stylua: ignore + keys = { + { "db", function() require("dap").toggle_breakpoint() end, desc = "Toggle Breakpoint" }, + { "dB", function() require("dap").set_breakpoint(vim.fn.input('Breakpoint condition: ')) end, desc = "Breakpoint Condition" }, + { "dc", function() require("dap").continue() end, desc = "Continue" }, + { "do", function() require("dap").step_over() end, desc = "Step Over" }, + { "di", function() require("dap").step_into() end, desc = "Step Into" }, + { "dw", function() require("dap.ui.widgets").hover() end, desc = "Widgets" }, + { "dr", function() require("dap").repl.open() end, desc = "Repl" }, + }, + + config = function() + local Config = require("lazyvim.config") + vim.api.nvim_set_hl(0, "DapStoppedLine", { default = true, link = "Visual" }) + + for name, sign in pairs(Config.icons.dap) do + sign = type(sign) == "table" and sign or { sign } + vim.fn.sign_define( + "Dap" .. name, + { text = sign[1], texthl = sign[2] or "DiagnosticInfo", linehl = sign[3], numhl = sign[3] } + ) + end + end, +}