diff options
| author | Ariel D'Alessandro <dalessandro.ariel@gmail.com> | 2023-09-01 11:33:10 +0200 |
|---|---|---|
| committer | Ariel D'Alessandro <dalessandro.ariel@gmail.com> | 2023-09-01 11:33:10 +0200 |
| commit | f4fe416201cc9d1cba5dfa3fec0879601fb85ae7 (patch) | |
| tree | d5660de66768722b327999fd894f1e1ba2a8649b /lua/alpha | |
| parent | 72c8f0deb1e8b3f069076a317d1f2d8abd97fae4 (diff) | |
| download | nvim-conf-f4fe416201cc9d1cba5dfa3fec0879601fb85ae7.tar.gz nvim-conf-f4fe416201cc9d1cba5dfa3fec0879601fb85ae7.zip | |
refactor my tests to be more automatic and do not depend on project config
Diffstat (limited to 'lua/alpha')
| -rw-r--r-- | lua/alpha/test_menu.lua | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/lua/alpha/test_menu.lua b/lua/alpha/test_menu.lua new file mode 100644 index 0000000..5b3e5a5 --- /dev/null +++ b/lua/alpha/test_menu.lua @@ -0,0 +1,48 @@ +local hydra = require "hydra" + +local hint = [[ + Vim Tests + _n_: Near test _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>" }, + { "f", ":TestFile<CR>" }, + { "s", ":TestSuit<CR>" }, + { "l", ":TestLast<CR>" }, + { "g", ":TestVisit<CR>" }, + { "w", startAutoCommand }, + { "p", stopAutoCommand }, + { "<Esc>", nil, { exit = true } }, + }, +} |