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 -- Map test running commands
local opts = { silent = true } local opts = { silent = true }
vim.keymap.set("n", "<Leader>tn", function() vim.keymap.set("n", "<Leader>tn", function()
last = nil
neotest.run.run() neotest.run.run()
end, opts) end, opts)
vim.keymap.set("n", "<Leader>tdn", function() vim.keymap.set("n", "<Leader>tdn", function()
last = { strategy = "dap", suite = false } neotest.run.run({ strategy = "dap", suite = false })
neotest.run.run(last)
end, opts) end, opts)
vim.keymap.set("n", "<Leader>tf", function() vim.keymap.set("n", "<Leader>tf", function()
last = vim.fn.expand("%") neotest.run.run(vim.fn.expand("%"))
neotest.run.run(last)
end, opts) end, opts)
vim.keymap.set("n", "<Leader>tdf", function() vim.keymap.set("n", "<Leader>tdf", function()
last = { vim.fn.expand("%"), strategy = "dap", suite = false } neotest.run.run({ vim.fn.expand("%"), strategy = "dap", suite = false })
neotest.run.run(last)
end, opts) end, opts)
vim.keymap.set("n", "<Leader>ts", function() vim.keymap.set("n", "<Leader>ts", function()
last = { suite = true } neotest.run.run({ suite = true })
neotest.run.run(last)
end, opts) end, opts)
vim.keymap.set("n", "<Leader>tds", function() vim.keymap.set("n", "<Leader>tds", function()
last = { strategy = "dap", suite = true } neotest.run.run({ strategy = "dap", suite = true })
neotest.run.run(last)
end, opts) end, opts)
vim.keymap.set("n", "<Leader>tl", function() vim.keymap.set("n", "<Leader>tl", function()
if last then neotest.run.run_last()
neotest.run.run(last)
else
neotest.run.run()
end
end, opts) end, opts)
vim.keymap.set("n", "<Leader>tp", neotest.output_panel.open, 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, end,
}, },
"nvim-neotest/nvim-nio", "nvim-neotest/nvim-nio",