From 1b1db2631ceba0648597e43bb1211bb205f4244e Mon Sep 17 00:00:00 2001 From: sgoudham Date: Mon, 13 Feb 2023 03:29:27 +0000 Subject: [PATCH] feat(nvim): add more dap keybinds and highlights --- dot_config/nvim/lua/plugins/dap.lua | 106 ++++++++++++++-------------- 1 file changed, 54 insertions(+), 52 deletions(-) diff --git a/dot_config/nvim/lua/plugins/dap.lua b/dot_config/nvim/lua/plugins/dap.lua index e81522c..db8c7aa 100644 --- a/dot_config/nvim/lua/plugins/dap.lua +++ b/dot_config/nvim/lua/plugins/dap.lua @@ -14,12 +14,13 @@ end return { { "jayp0521/mason-nvim-dap.nvim", + lazy = false, config = function() local dap = require("dap") local mason_dap = require("mason-nvim-dap") mason_dap.setup({ - ensure_installed = { "python", "codelldb" }, + ensure_installed = { "python", "codelldb", "java-debug-adapter", "java-test" }, automatic_setup = true, }) mason_dap.setup_handlers({ @@ -67,69 +68,70 @@ return { -- apply suggestions from catppuccin theme local sign = vim.fn.sign_define - sign("DapBreakpoint", { text = "●", texthl = "DapBreakpoint", linehl = "", numhl = "" }) + sign("DapBreakpoint", { text = "●", texthl = "DapBreakpoint", linehl = "DapBreakpointLinehl", numhl = "" }) + sign("DapStopped", { text = "", texthl = "Error", linehl = "DapStoppedLinehl", numhl = "" }) sign("DapBreakpointCondition", { text = "●", texthl = "DapBreakpointCondition", linehl = "", numhl = "" }) sign("DapLogPoint", { text = "◆", texthl = "DapLogPoint", linehl = "", numhl = "" }) end, + -- stylua: ignore keys = { { "bb", vim.cmd.DapToggleBreakpoint, desc = "Toggle Breakpoint" }, - { - "bf", - function() - require("dap").list_breakpoints() - end, - desc = "List Breakpoints", - }, - { - "bc", - function() - require("dap").clear_breakpoints() - end, - desc = "Clear Breakpoints", - }, + { "bf", function() require("dap").list_breakpoints() end, desc = "List Breakpoints", }, + { "bc", function() require("dap").clear_breakpoints() end, desc = "Clear Breakpoints", }, { "dc", vim.cmd.DapContinue, desc = "Start / Continue" }, + { "dj", function() require("dap").step_over() end, desc = "Step Over", }, + { "dk", function() require("dap").step_into() end, desc = "Step Into", }, + { "do", function() require("dap").step_out() end, desc = "Step Out", }, + { "dd", function() require("dap").disconnect() end, desc = "Disconnect", }, + { "dr", function() require("dap").restart() end, desc = "Restart", }, + + { "du", function() require("dapui").toggle({}) end, desc = "Toggle UI", }, + { "dt", function() require("dap.repl").toggle() end, desc = "Toggle REPL", }, + }, + dependencies = { + "williamboman/mason.nvim", { - "dj", - function() - require("dap").step_over() - end, - desc = "Step Over", - }, - { - "dk", - function() - require("dap").step_into() - end, - desc = "Step Into", - }, - { - "do", - function() - require("dap").step_out() - end, - desc = "Step Out", - }, - { - "dd", - function() - require("dap").disconnect() + "mfussenegger/nvim-dap", + config = function() + local dap, dapui = require("dap"), require("dapui") + 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, - desc = "Disconnect", }, - { - "du", - function() - require("dapui").toggle({}) - end, - desc = "Toggle UI", + "rcarriga/nvim-dap-ui", + opts = { + -- stylua: ignore + layouts = { + { + elements = { + { id = "stacks", size = 0.15, }, + { id = "repl", size = 0.05, }, + { id = "scopes", size = 0.40, }, + -- { id = "breakpoints", size = 0.25, }, + { id = "watches", size = 0.40, }, + }, + position = "left", + size = 40, + }, + { + elements = { + { id = "console", size = 1, }, + }, + position = "bottom", + size = 10, + }, + }, + }, }, - }, - dependencies = { - "williamboman/mason.nvim", - "mfussenegger/nvim-dap", - { "rcarriga/nvim-dap-ui", config = true }, { "theHamsta/nvim-dap-virtual-text", config = true }, }, },