refactor(tests): pr changes

This commit is contained in:
Jonas Holst Damtoft 2023-05-22 20:31:27 +02:00
parent 1e566b49b5
commit b5318d6635
2 changed files with 10 additions and 22 deletions

View file

@ -52,6 +52,7 @@ vim.api.nvim_create_autocmd("FileType", {
"startuptime", "startuptime",
"tsplayground", "tsplayground",
"checkhealth", "checkhealth",
"neotest-output",
}, },
callback = function(event) callback = function(event)
vim.bo[event.buf].buflisted = false vim.bo[event.buf].buflisted = false

View file

@ -1,39 +1,26 @@
return { return {
{
"nvim-neotest/neotest",
dependencies = {
-- which key integration
{ {
"folke/which-key.nvim", "folke/which-key.nvim",
optional = true,
opts = { opts = {
defaults = { defaults = {
["<leader>t"] = { name = "+test" }, ["<leader>t"] = { name = "+test" },
}, },
}, },
}, },
}, {
"nvim-neotest/neotest",
config = function(_, opts) config = function(_, opts)
-- get neotest namespace (api call creates or returns namespace)
local neotest_ns = vim.api.nvim_create_namespace("neotest") local neotest_ns = vim.api.nvim_create_namespace("neotest")
vim.diagnostic.config({ vim.diagnostic.config({
virtual_text = { virtual_text = {
format = function(diagnostic) format = function(diagnostic)
-- Replace newline and tab characters with space for more compact diagnostics
local message = diagnostic.message:gsub("\n", " "):gsub("\t", " "):gsub("%s+", " "):gsub("^%s+", "") local message = diagnostic.message:gsub("\n", " "):gsub("\t", " "):gsub("%s+", " "):gsub("^%s+", "")
return message return message
end, end,
}, },
}, neotest_ns) }, neotest_ns)
local group = vim.api.nvim_create_augroup("lazyvim_neotest_close_with_q", { clear = true })
vim.api.nvim_create_autocmd("FileType", {
group = group,
pattern = {
"neotest-output",
},
callback = function(event)
vim.bo[event.buf].buflisted = false
vim.keymap.set("n", "q", "<cmd>close<cr>", { buffer = event.buf, silent = true })
end,
})
require("neotest").setup(opts) require("neotest").setup(opts)
end, end,