From aaac1f04614943dfaf90a23024d1b9b18ced9a6c Mon Sep 17 00:00:00 2001 From: Ariel D'Alessandro Date: Tue, 19 Jul 2022 23:09:41 +0200 Subject: Add more hydras --- lua/alpha/dap.lua | 87 +++++++++++++++++++++++++++++---------------------- lua/alpha/plugins.lua | 1 + 2 files changed, 50 insertions(+), 38 deletions(-) (limited to 'lua/alpha') diff --git a/lua/alpha/dap.lua b/lua/alpha/dap.lua index 326ab60..6215f95 100644 --- a/lua/alpha/dap.lua +++ b/lua/alpha/dap.lua @@ -53,43 +53,54 @@ dap.listeners.after.event_initialized["dapui_config"] = function() dapui.open({}) end --- command to start debugging --- run dap continue and enable the keybindings --- when finish delete all keybindings - --- TODO create a hydra for debug - -local bindings = { - { mode = "n", lhs = "dd", rhs = dap.continue }, - { mode = "n", lhs = "dbp", rhs = dap.toggle_breakpoint }, - { mode = "n", lhs = "dl", rhs = dap.step_into }, - { mode = "n", lhs = "dj", rhs = dap.step_over }, - { mode = "n", lhs = "dk", rhs = dap.step_out }, - { mode = "n", lhs = "dc", rhs = dap.run_to_cursor }, - { mode = "v", lhs = "dv", rhs = dapui.eval }, - { mode = "n", lhs = "dcb", rhs = function () - vim.ui.input({prompt = "Condition: "}, function (condition) - dap.toggle_breakpoint(condition) - end) - end }, -} - -vim.keymap.set("n", "dst", function() - dap.continue() - for _, bind in pairs(bindings) do - vim.keymap.set(bind.mode, bind.lhs, bind.rhs, { noremap = true }) - end -end, { noremap = true }) - -vim.keymap.set("n", "dsp", function() - dap.terminate() - dapui.close({}) - dap.clear_breakpoints() +local hydra = require("hydra") +local hint = [[ + Nvim DAP + _d_: Start/Continue _j_: StepOver _k_: StepOut _l_: StepInto ^ + _bp_: Toogle Breakpoint _cb_: Conditional Breakpoint ^ + _c_: Run To Cursor _tt_: Go Debug Test + _sp_: Stop Debbuging + ^^ __ +]] +hydra({ + name = "dap", + hint = hint, + mode = "n", + config = { + color = "amaranth", + invoke_on_body = true, + hint = { + border = "rounded", + position = "bottom", + }, + }, + body = "d", + heads = { + { "d", dap.continue }, + { "bp", dap.toggle_breakpoint }, + { "l", dap.step_into }, + { "j", dap.step_over }, + { "k", dap.step_out }, + { "c", dap.run_to_cursor }, + { "tt", dap_go.debug_test }, + { + "cb", + function() + vim.ui.input({ prompt = "Condition: " }, function(condition) + dap.toggle_breakpoint(condition) + end) + end, + }, - for _, bind in pairs(bindings) do - vim.keymap.del(bind.mode, bind.lhs) - end -end, { noremap = true }) + { + "sp", + function() + dap.terminate() + dapui.close({}) + dap.clear_breakpoints() + end, + }, --- can be skipped since I can do it running the continue and promt to use the "Debug test" -vim.keymap.set("n", "dtt", dap_go.debug_test, { noremap = true }) + { "", nil, { exit = true } }, + }, +}) diff --git a/lua/alpha/plugins.lua b/lua/alpha/plugins.lua index cc17db0..a332ff8 100644 --- a/lua/alpha/plugins.lua +++ b/lua/alpha/plugins.lua @@ -149,6 +149,7 @@ return require("packer").startup(function(use) "nvim-treesitter/nvim-treesitter", "antoinemadec/FixCursorHold.nvim", "nvim-neotest/neotest-go", + "nvim-neotest/neotest-plenary", "nvim-neotest/neotest-vim-test", }, }) -- cgit v1.2.3