nvim/lua/custom/plugins/neotest.lua
Jeremie Fraeys 02e26b00b7
Some checks are pending
Check Lua Formatting in MyRepo / Stylua Check (push) Waiting to run
chore(nvim): reinitialize with working config
2026-02-07 21:06:45 -05:00

137 lines
3.3 KiB
Lua

return {
{
'nvim-neotest/neotest',
dependencies = {
'nvim-lua/plenary.nvim',
'nvim-neotest/nvim-nio',
'nvim-treesitter/nvim-treesitter',
'nvim-neotest/neotest-python',
'alfaix/neotest-gtest',
'andythigpen/nvim-coverage',
},
keys = {
{
'<leader>tn',
function()
local neotest = require('neotest')
neotest.summary.open({ enter = false })
neotest.run.run()
end,
desc = 'Test: Run nearest',
},
{
'<leader>tf',
function()
local neotest = require('neotest')
neotest.summary.open({ enter = false })
neotest.run.run(vim.fn.expand('%'))
end,
desc = 'Test: Run file',
},
{
'<leader>ta',
function()
local neotest = require('neotest')
neotest.summary.open({ enter = false })
neotest.run.run(vim.fn.getcwd())
end,
desc = 'Test: Run all (cwd)',
},
{
'<leader>td',
function()
local neotest = require('neotest')
neotest.summary.open({ enter = false })
neotest.run.run({ strategy = 'dap' })
end,
desc = 'Test: Debug nearest',
},
{
'<leader>tx',
function()
require('neotest').run.stop()
end,
desc = 'Test: Stop',
},
{
'<leader>ts',
function()
require('neotest').summary.toggle()
end,
desc = 'Test: Toggle summary',
},
{
'<leader>to',
function()
require('neotest').output.open({ enter = true, auto_close = false })
end,
desc = 'Test: Show output',
},
{
'<leader>tw',
function()
require('neotest').watch.toggle(vim.fn.expand('%'))
end,
desc = 'Test: Watch file',
},
{
']t',
function()
require('neotest').jump.next({ status = 'failed' })
end,
desc = 'Test: Next failed',
},
{
'[t',
function()
require('neotest').jump.prev({ status = 'failed' })
end,
desc = 'Test: Prev failed',
},
{
'<leader>tC',
function()
local ok, coverage = pcall(require, 'coverage')
if ok then
coverage.toggle()
end
end,
desc = 'Test: Toggle coverage',
},
{
'<leader>tL',
function()
local ok, coverage = pcall(require, 'coverage')
if ok then
coverage.load(true)
end
end,
desc = 'Test: Load coverage',
},
},
config = function()
local neotest = require('neotest')
neotest.setup({
adapters = {
require('neotest-python')({
runner = 'pytest',
dap = { justMyCode = false },
}),
require('neotest-gtest').setup({
debug_adapter = 'codelldb',
}),
},
output = { open_on_run = false },
summary = { open = 'botright vsplit | vertical resize 60' },
})
local ok_cov, coverage = pcall(require, 'coverage')
if ok_cov then
coverage.setup({
auto_reload = true,
})
end
end,
},
}