91 lines
3.3 KiB
Lua
91 lines
3.3 KiB
Lua
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 = {
|
|
{ "<leader>tt", nt(function(n) n.run.run() end), desc = "Run nearest test" },
|
|
{ "<leader>tf", nt(function(n) n.run.run(vim.fn.expand("%")) end), desc = "Run test file" },
|
|
{ "<leader>ts", nt(function(n) n.summary.toggle() end), desc = "Test summary" },
|
|
{ "<leader>to", nt(function(n) n.output.open({ enter = true }) end), desc = "Test output" },
|
|
{ "<leader>td", nt(function(n) n.run.run({ strategy = "dap" }) end), desc = "Debug nearest test" },
|
|
{ "<leader>tA", nt(function(n) n.run.run(vim.uv.cwd()) end), desc = "Run all tests" },
|
|
{ "<leader>tl", nt(function(n) n.run.run_last() end), desc = "Run last test" },
|
|
{ "<leader>tO", nt(function(n) n.output_panel.toggle() end), desc = "Test output panel" },
|
|
{ "<leader>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,
|
|
},
|
|
}
|