From 4e33ed3b1cc090994b75ac1aa63eec21b46d2a82 Mon Sep 17 00:00:00 2001 From: Nicholas Ciechanowski <55490546+ALameLlama@users.noreply.github.com> Date: Sat, 20 Jul 2024 01:37:09 +1000 Subject: [PATCH] feat(test): add vim-test (#1112) * feat(test): add vim-test * fix(test): vim-test options * feat(test): add type annotation and nil safety * fix(test): remove wrapping {} --- lua/astrocommunity/test/vim-test/README.md | 5 ++++ lua/astrocommunity/test/vim-test/init.lua | 32 ++++++++++++++++++++++ 2 files changed, 37 insertions(+) create mode 100644 lua/astrocommunity/test/vim-test/README.md create mode 100644 lua/astrocommunity/test/vim-test/init.lua diff --git a/lua/astrocommunity/test/vim-test/README.md b/lua/astrocommunity/test/vim-test/README.md new file mode 100644 index 000000000..8fa3318f0 --- /dev/null +++ b/lua/astrocommunity/test/vim-test/README.md @@ -0,0 +1,5 @@ +# vim-test + +Run your tests at the speed of thought + +**Repository:** diff --git a/lua/astrocommunity/test/vim-test/init.lua b/lua/astrocommunity/test/vim-test/init.lua new file mode 100644 index 000000000..f2f310fee --- /dev/null +++ b/lua/astrocommunity/test/vim-test/init.lua @@ -0,0 +1,32 @@ +---@type LazySpec +return { + "vim-test/vim-test", + cmd = { "TestNearest", "TestFile", "TestLast", "TestClass", "TestSuite", "TestVisit" }, + dependencies = { + { + "AstroNvim/astrocore", + ---@param opts AstroCoreOpts + opts = function(_, opts) + local maps = assert(opts.mappings) + + local prefix = "T" + maps.n[prefix] = { desc = require("astroui").get_icon("VimTest", 1, true) .. "Testing" } + + maps.n[prefix .. "n"] = { ":TestNearest", desc = "Test Nearest" } + maps.n[prefix .. "f"] = { ":TestFile", desc = "Test File" } + maps.n[prefix .. "l"] = { ":TestLast", desc = "Test Last" } + maps.n[prefix .. "c"] = { ":TestClass", desc = "Test Class" } + maps.n[prefix .. "s"] = { ":TestSuite", desc = "Test Suite" } + maps.n[prefix .. "v"] = { ":TestVisit", desc = "Test Visit" } + + -- Set the strategy to open results in a vertical split + if not opts.options then opts.options = {} end + if not opts.options.g then opts.options.g = {} end + opts.options.g["test#strategy"] = "neovim" + opts.options.g["test#neovim#term_position"] = "vert" + end, + }, + { "AstroNvim/astroui", opts = { icons = { VimTest = "󰙨" } } }, + }, + event = { "VeryLazy" }, +}