aboutsummaryrefslogtreecommitdiffstats
path: root/lua/pi/test_menu.lua
diff options
context:
space:
mode:
authorElvis Claros Castro <elvis@claros.ar>2024-07-12 11:18:14 -0300
committerElvis Claros Castro <elvis@claros.ar>2024-07-12 11:18:14 -0300
commitea0f4bf8ffade657b1d45152dbc183d4679e75c4 (patch)
treecc1fb023bc308e019ddce33a4b0aed39f56805dc /lua/pi/test_menu.lua
parent1fd0af14d592d612c2aaab7717c04c8806ba3daa (diff)
downloadnvim-conf-ea0f4bf8ffade657b1d45152dbc183d4679e75c4.tar.gz
nvim-conf-ea0f4bf8ffade657b1d45152dbc183d4679e75c4.zip
Feat: PI
Diffstat (limited to 'lua/pi/test_menu.lua')
-rw-r--r--lua/pi/test_menu.lua50
1 files changed, 50 insertions, 0 deletions
diff --git a/lua/pi/test_menu.lua b/lua/pi/test_menu.lua
new file mode 100644
index 0000000..afe3a9e
--- /dev/null
+++ b/lua/pi/test_menu.lua
@@ -0,0 +1,50 @@
+local hydra = require "hydra"
+
+local hint = [[
+ Vim Tests
+ _n_: Near test _h_: Harpoon ^
+ _f_: Current file _s_: Test Suit ^
+ _l_: Test Last _g_: Visit
+ _w_: Watch last Test _p_: stop watch
+ ^ ^ _<Esc>_ ^
+]]
+local auto_cmd_id = nil
+local stopAutoCommand = function()
+ if auto_cmd_id ~= nil then
+ vim.api.nvim_del_autocmd(auto_cmd_id)
+ auto_cmd_id = nil
+ end
+end
+local startAutoCommand = function()
+ stopAutoCommand()
+ auto_cmd_id = vim.api.nvim_create_autocmd({ "BufWritePost" }, {
+ pattern = { "*.php", "*.feature", "*.yaml" },
+ command = "TestLast",
+ })
+end
+
+hydra {
+ name = "vimtest",
+ hint = hint,
+ mode = "n",
+ config = {
+ color = "teal",
+ invoke_on_body = true,
+ hint = {
+ border = "rounded",
+ position = "bottom",
+ },
+ },
+ body = "<leader>t",
+ heads = {
+ { "n", ":TestNearest<CR>" },
+ { "h", ":TestNearest -strategy=harpoon<CR>" },
+ { "f", ":TestFile<CR>" },
+ { "s", ":TestSuit<CR>" },
+ { "l", ":TestLast<CR>" },
+ { "g", ":TestVisit<CR>" },
+ { "w", startAutoCommand },
+ { "p", stopAutoCommand },
+ { "<Esc>", nil, { exit = true } },
+ },
+}