feat(autocommands): remove make diagnostics
This commit is contained in:
@@ -61,55 +61,3 @@ vim.api.nvim_create_autocmd("FileType", {
|
|||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
|
||||||
local make_group = vim.api.nvim_create_augroup("make_diagnostics", {})
|
|
||||||
local make_namespace = vim.api.nvim_create_namespace("make_diagnostics")
|
|
||||||
-- Create diagnostics after running :make
|
|
||||||
vim.api.nvim_create_autocmd("QuickFixCmdPost", {
|
|
||||||
callback = function(ctx)
|
|
||||||
if ctx.match ~= "make" then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
local diagnostics = vim.diagnostic.fromqflist(vim.fn.getqflist())
|
|
||||||
local buf_diag = {}
|
|
||||||
for _, d in ipairs(diagnostics) do
|
|
||||||
if not d.bufnr then
|
|
||||||
goto continue
|
|
||||||
end
|
|
||||||
|
|
||||||
if not buf_diag[d.bufnr] then
|
|
||||||
buf_diag[d.bufnr] = {}
|
|
||||||
end
|
|
||||||
|
|
||||||
table.insert(buf_diag[d.bufnr], d)
|
|
||||||
|
|
||||||
::continue::
|
|
||||||
end
|
|
||||||
|
|
||||||
for bufnr, d in pairs(buf_diag) do
|
|
||||||
vim.diagnostic.set(make_namespace, bufnr, d)
|
|
||||||
end
|
|
||||||
end,
|
|
||||||
group = make_group,
|
|
||||||
})
|
|
||||||
-- Clear old make diagnostics before running :make
|
|
||||||
vim.api.nvim_create_autocmd("QuickFixCmdPre", {
|
|
||||||
callback = function(ctx)
|
|
||||||
if ctx.match ~= "make" then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
local diagnostics = vim.diagnostic.fromqflist(vim.fn.getqflist())
|
|
||||||
local bufs = {}
|
|
||||||
for _, d in ipairs(diagnostics) do
|
|
||||||
if d.bufnr then
|
|
||||||
table.insert(bufs, d.bufnr)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
for _, bufnr in ipairs(bufs) do
|
|
||||||
vim.diagnostic.reset(make_namespace, bufnr)
|
|
||||||
end
|
|
||||||
end,
|
|
||||||
group = make_group,
|
|
||||||
})
|
|
||||||
|
|||||||
Reference in New Issue
Block a user