mirror of
https://github.com/LazyVim/LazyVim.git
synced 2025-06-24 01:38:54 +02:00
fix(neotest): better integration with trouble: no longer steals focus and hides when all ok
This commit is contained in:
parent
5c1656729a
commit
2e308d5440
1 changed files with 32 additions and 1 deletions
|
@ -27,7 +27,7 @@ return {
|
||||||
quickfix = {
|
quickfix = {
|
||||||
open = function()
|
open = function()
|
||||||
if require("lazyvim.util").has("trouble.nvim") then
|
if require("lazyvim.util").has("trouble.nvim") then
|
||||||
vim.cmd("Trouble quickfix")
|
require("trouble").open({ mode = "quickfix", focus = false })
|
||||||
else
|
else
|
||||||
vim.cmd("copen")
|
vim.cmd("copen")
|
||||||
end
|
end
|
||||||
|
@ -46,6 +46,37 @@ return {
|
||||||
},
|
},
|
||||||
}, neotest_ns)
|
}, neotest_ns)
|
||||||
|
|
||||||
|
if require("lazyvim.util").has("trouble.nvim") then
|
||||||
|
opts.consumers = opts.consumers or {}
|
||||||
|
-- Refresh and auto close trouble after running tests
|
||||||
|
---@type neotest.Consumer
|
||||||
|
opts.consumers.trouble = function(client)
|
||||||
|
client.listeners.results = function(adapter_id, results, partial)
|
||||||
|
if partial then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
local tree = assert(client:get_position(nil, { adapter = adapter_id }))
|
||||||
|
|
||||||
|
local failed = 0
|
||||||
|
for pos_id, result in pairs(results) do
|
||||||
|
if result.status == "failed" and tree:get_key(pos_id) then
|
||||||
|
failed = failed + 1
|
||||||
|
end
|
||||||
|
end
|
||||||
|
vim.schedule(function()
|
||||||
|
local trouble = require("trouble")
|
||||||
|
if trouble.is_open() then
|
||||||
|
trouble.refresh()
|
||||||
|
if failed == 0 then
|
||||||
|
trouble.close()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
return {}
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
if opts.adapters then
|
if opts.adapters then
|
||||||
local adapters = {}
|
local adapters = {}
|
||||||
for name, config in pairs(opts.adapters or {}) do
|
for name, config in pairs(opts.adapters or {}) do
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue