Add new neotest functions mapping

main
Ensar Sarajčić 2024-12-04 18:43:45 +01:00
parent e30b23fd96
commit d224acf4eb
1 changed files with 16 additions and 18 deletions

View File

@ -71,42 +71,40 @@ return require("lazy").setup({
},
})
local last = nil
-- Map test running commands
local opts = { silent = true }
vim.keymap.set("n", "<Leader>tn", function()
last = nil
neotest.run.run()
end, opts)
vim.keymap.set("n", "<Leader>tdn", function()
last = { strategy = "dap", suite = false }
neotest.run.run(last)
neotest.run.run({ strategy = "dap", suite = false })
end, opts)
vim.keymap.set("n", "<Leader>tf", function()
last = vim.fn.expand("%")
neotest.run.run(last)
neotest.run.run(vim.fn.expand("%"))
end, opts)
vim.keymap.set("n", "<Leader>tdf", function()
last = { vim.fn.expand("%"), strategy = "dap", suite = false }
neotest.run.run(last)
neotest.run.run({ vim.fn.expand("%"), strategy = "dap", suite = false })
end, opts)
vim.keymap.set("n", "<Leader>ts", function()
last = { suite = true }
neotest.run.run(last)
neotest.run.run({ suite = true })
end, opts)
vim.keymap.set("n", "<Leader>tds", function()
last = { strategy = "dap", suite = true }
neotest.run.run(last)
neotest.run.run({ strategy = "dap", suite = true })
end, opts)
vim.keymap.set("n", "<Leader>tl", function()
if last then
neotest.run.run(last)
else
neotest.run.run()
end
neotest.run.run_last()
end, opts)
vim.keymap.set("n", "<Leader>tp", neotest.output_panel.open, opts)
vim.keymap.set("n", "<Leader>ton", function()
neotest.output.open({ enter = true })
end, opts)
vim.keymap.set("n", "<Leader>tof", function()
neotest.output.open({ enter = true, position_id = vim.fn.expand("%") })
end, opts)
vim.keymap.set("n", "<Leader>tol", function()
neotest.output.open({ enter = true, last_run = true })
end, opts)
vim.keymap.set("n", "<Leader>tos", neotest.output_panel.open, opts)
end,
},
"nvim-neotest/nvim-nio",