return { "nvim-neotest/neotest", event = "VeryLazy", dependencies = { "nvim-lua/plenary.nvim", "nvim-treesitter/nvim-treesitter", "antoinemadec/FixCursorHold.nvim", "nvim-neotest/nvim-nio", -- Adapters "olimorris/neotest-phpunit", "praem90/neotest-docker-phpunit.nvim", "nvim-neotest/neotest-go", }, config = function() local neotest = require("neotest") local keymap = vim.keymap -- Environment setup vim.env.PROJECT_ROOT = vim.fn.getcwd() .. "/backend/" vim.env.ENV_PATH = vim.fn.getcwd() .. "/backend/.env" -- Container toggle state local current_container = "app-fpm" -- Test running keymaps keymap.set("n", "tr", function() neotest.run.run() end, { desc = "Run nearest test" }) keymap.set("n", "tf", function() neotest.run.run(vim.fn.expand("%")) end, { desc = "Run all tests in file" }) keymap.set("n", "tR", function() neotest.run.run_last() end, { desc = "Run last test" }) keymap.set("n", "tS", function() neotest.run.stop() end, { desc = "Stop running tests" }) keymap.set("n", "ta", function() neotest.run.attach() end, { desc = "Attach to running test" }) -- Watch mode keymap.set("n", "tw", function() neotest.watch.toggle(vim.fn.expand("%")) end, { desc = "Toggle watch mode for file" }) -- Output keymaps keymap.set("n", "to", function() neotest.output.open({ enter = true, short = false }) end, { desc = "Open test output" }) keymap.set("n", "tO", function() neotest.output_panel.toggle() end, { desc = "Toggle output panel" }) -- UI keymaps keymap.set("n", "ts", function() neotest.summary.toggle() end, { desc = "Toggle summary pane" }) -- Navigation keymaps keymap.set("n", "[t", function() neotest.jump.prev({ status = "failed" }) end, { desc = "Jump to previous failed test" }) keymap.set("n", "]t", function() neotest.jump.next({ status = "failed" }) end, { desc = "Jump to next failed test" }) -- Setup neotest function local cwd = vim.fn.getcwd() local app_path = cwd .. "/app/api" local subscription_path = cwd .. "/subscription/api" -- Config table that we can modify local docker_config = { default = { container = current_container, volume = (current_container == "subscription-fpm" and subscription_path or app_path) .. ":/var/www", standalone = false, }, } local function setup_neotest() neotest.setup({ adapters = { require("neotest-docker-phpunit").setup({ phpunit_cmd = "neotest-docker-phpunit", docker_phpunit = docker_config, }), require("neotest-go")({ root = function() return './backend' end, experimental = { test_table = true, }, args = { "-count=1", "-timeout=60s" }, }), }, output = { enabled = true, open_on_run = false, }, output_panel = { enabled = true, open = "botright split | resize 15", }, quickfix = { enabled = true, open = false, }, status = { enabled = true, virtual_text = true, signs = true, }, floating = { border = "rounded", max_height = 0.8, max_width = 0.9, }, }) end -- Initial setup setup_neotest() -- Container toggle keybind keymap.set("n", "tc", function() if current_container == "app-fpm" then current_container = "subscription-fpm" else current_container = "app-fpm" end -- Update the config table directly docker_config.default.container = current_container docker_config.default.volume = (current_container == "subscription-fpm" and subscription_path or app_path) .. ":/var/www" vim.notify("Switched to container: " .. current_container, vim.log.levels.INFO) end, { desc = "Toggle container (app/subscription)" }) end, }