local function nt(fn) return function() fn(require("neotest")) end end return { { "nvim-neotest/neotest", cond = vim.g.profile == "full", dependencies = { "nvim-neotest/nvim-nio", "nvim-lua/plenary.nvim", "nvim-treesitter/nvim-treesitter", "rouge8/neotest-rust", "fredrikaverpil/neotest-golang", "marilari88/neotest-vitest", "nvim-neotest/neotest-jest", "nvim-neotest/neotest-python", "V13Axel/neotest-pest", "olimorris/neotest-phpunit", }, keys = { { "tt", nt(function(n) n.run.run() end), desc = "Run nearest test" }, { "tf", nt(function(n) n.run.run(vim.fn.expand("%")) end), desc = "Run test file" }, { "ts", nt(function(n) n.summary.toggle() end), desc = "Test summary" }, { "to", nt(function(n) n.output.open({ enter = true }) end), desc = "Test output" }, { "td", nt(function(n) n.run.run({ strategy = "dap" }) end), desc = "Debug nearest test" }, { "tA", nt(function(n) n.run.run(vim.uv.cwd()) end), desc = "Run all tests" }, { "tl", nt(function(n) n.run.run_last() end), desc = "Run last test" }, { "tO", nt(function(n) n.output_panel.toggle() end), desc = "Test output panel" }, { "tW", nt(function(n) n.watch.toggle(vim.fn.expand("%")) end), desc = "Watch test file" }, }, config = function() -- One-line test errors in the diagnostics of neotest's own namespace. vim.diagnostic.config({ virtual_text = { format = function(d) return (d.message:gsub("%s+", " "):gsub("^%s+", "")) end, }, }, vim.api.nvim_create_namespace("neotest")) require("neotest").setup({ discovery = { enabled = true, concurrent = 0 }, running = { concurrent = true }, summary = { animated = true }, consumers = { -- neotest has no "discovery done" event, so debounce the per-file events into a progress message. discovery_progress = function(client) local count, msg_id = 0, nil local timer = vim.uv.new_timer() local function progress(text, status) msg_id = vim.api.nvim_echo({ { text } }, true, { kind = "progress", source = "neotest", title = "Neotest", status = status, id = msg_id, }) end client.listeners.discover_positions = function() count = count + 1 progress(("Discovering tests: %d files"):format(count), "running") timer:stop() timer:start( 800, 0, vim.schedule_wrap(function() progress(("Discovered tests in %d files"):format(count), "success") count, msg_id = 0, nil end) ) end return {} end, }, adapters = { require("neotest-rust"), require("neotest-golang")({}), require("neotest-vitest"), require("neotest-jest")({}), require("neotest-python")({ dap = { justMyCode = false } }), require("neotest-pest"), require("neotest-phpunit"), }, }) end, }, }