From 303dae83db202ba00ca1fb60c553412a1031da60 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Crist=C3=B3bal=20Gajardo=20Vera?= Date: Sun, 1 Sep 2024 19:05:43 -0400 Subject: [PATCH] feat(neotest): add watch keybindings --- lua/astrocommunity/test/neotest/init.lua | 25 ++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/lua/astrocommunity/test/neotest/init.lua b/lua/astrocommunity/test/neotest/init.lua index bd2bc7099..1f44a2a63 100644 --- a/lua/astrocommunity/test/neotest/init.lua +++ b/lua/astrocommunity/test/neotest/init.lua @@ -1,4 +1,6 @@ local prefix = "T" +local watch_prefix = prefix .. "W" + return { "nvim-neotest/neotest", lazy = true, @@ -26,6 +28,29 @@ return { [prefix .. "O"] = { function() require("neotest").output_panel.toggle() end, desc = "Output window" }, ["]T"] = { function() require("neotest").jump.next() end, desc = "Next test" }, ["[T"] = { function() require("neotest").jump.prev() end, desc = "previous test" }, + + [watch_prefix] = { desc = " Watch" }, + [watch_prefix .. "t"] = { + function() require("neotest").watch.toggle() end, + desc = "Toggle watch test", + }, + [watch_prefix .. "f"] = { + function() require("neotest").watch.toggle(vim.fn.expand "%") end, + desc = "Toggle watch all test in file", + }, + [watch_prefix .. "p"] = { + function() require("neotest").watch.toggle(vim.fn.getcwd()) end, + desc = "Toggle watch all tests in project", + }, + [watch_prefix .. "S"] = { + function() + --- NOTE: The proper type of the argument is missing in the documentation + ---@see https://github.com/nvim-neotest/neotest/blob/master/doc/neotest.txt#L626 + ---@diagnostic disable-next-line: missing-parameter + require("neotest").watch.stop() + end, + desc = "Stop all watches", + }, }, }, },