From 6bcd7438e609a07f8b3bca9d6b91cdc228c87f45 Mon Sep 17 00:00:00 2001 From: Mark Emmons Date: Sat, 12 Nov 2022 06:36:22 -0600 Subject: [PATCH] feat(summary): 'debug' and 'debug_marked' mappings (#151) --- doc/neotest.txt | 6 +++++- lua/neotest/config/init.lua | 4 ++++ lua/neotest/consumers/summary/component.lua | 8 ++++++++ 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/doc/neotest.txt b/doc/neotest.txt index 278007aa..2171483c 100644 --- a/doc/neotest.txt +++ b/doc/neotest.txt @@ -148,7 +148,9 @@ Default values: output = "o", prev_failed = "K", run = "r", + debug = "d", run_marked = "R", + debug_marked = "D", short = "O", stop = "u", target = "t" @@ -244,8 +246,10 @@ Fields~ {jumpto} `(string|string[])` Jump to the selected position {stop} `(string|string[])` Stop selected position {run} `(string|string[])` Run selected position +{debug} `(string|string[])` Debug selected position {mark} `(string|string[])` Mark the selected position {run_marked} `(string|string[])` Run the marked positions for selected suite. +{debug_marked} `(string|string[])` Debug the marked positions for selected suite. {clear_marked} `(string|string[])` Clear the marked positions for selected suite. {target} `(string|string[])` Target a position to be the only shown position for its adapter {clear_target} `(string|string[])` Clear the target position for the selected adapter @@ -544,4 +548,4 @@ Fields~ {status} `(string)` Only jump to positions with given status - vim:tw=78:ts=8:noet:ft=help:norl: \ No newline at end of file + vim:tw=78:ts=8:noet:ft=help:norl: diff --git a/lua/neotest/config/init.lua b/lua/neotest/config/init.lua index d041a421..ffe0a3ff 100644 --- a/lua/neotest/config/init.lua +++ b/lua/neotest/config/init.lua @@ -86,8 +86,10 @@ define_highlights() ---@field jumpto string|string[] Jump to the selected position ---@field stop string|string[] Stop selected position ---@field run string|string[] Run selected position +---@field debug string|string[] Debug selected position ---@field mark string|string[] Mark the selected position ---@field run_marked string|string[] Run the marked positions for selected suite. +---@field debug_marked string|string[] Debug the marked positions for selected suite. ---@field clear_marked string|string[] Clear the marked positions for selected suite. ---@field target string|string[] Target a position to be the only shown position for its adapter ---@field clear_target string|string[] Clear the target position for the selected adapter @@ -194,8 +196,10 @@ local default_config = { jumpto = "i", stop = "u", run = "r", + debug = "d", mark = "m", run_marked = "R", + debug_marked = "D", clear_marked = "M", target = "t", clear_target = "T", diff --git a/lua/neotest/consumers/summary/component.lua b/lua/neotest/consumers/summary/component.lua index 00e64a57..533518b3 100644 --- a/lua/neotest/consumers/summary/component.lua +++ b/lua/neotest/consumers/summary/component.lua @@ -204,6 +204,10 @@ function SummaryComponent:_render(canvas, tree, expanded, focused, indent) neotest.run.run({ position.id, adapter = self.adapter_id }) end) + canvas:add_mapping("debug", function() + neotest.run.run({ position.id, adapter = self.adapter_id, strategy = "dap" }) + end) + canvas:add_mapping("mark", function() self.marked[position.id] = not self.marked[position.id] neotest.summary.render() @@ -213,6 +217,10 @@ function SummaryComponent:_render(canvas, tree, expanded, focused, indent) neotest.summary.run_marked({ adapter = self.adapter_id }) end) + canvas:add_mapping("debug_marked", function() + neotest.summary.run_marked({ adapter = self.adapter_id, strategy = "dap" }) + end) + canvas:add_mapping("clear_marked", function() neotest.summary.clear_marked({ adapter = self.adapter_id }) end)