feat(action): add type into qf entry when calling entry_to_qf function (#2897)

This commit is contained in:
Liu
2024-02-24 22:24:24 +08:00
committed by GitHub
parent 6868df51d2
commit 2e1e382df4
2 changed files with 10 additions and 1 deletions

View File

@@ -912,6 +912,7 @@ local entry_to_qf = function(entry)
lnum = vim.F.if_nil(entry.lnum, 1), lnum = vim.F.if_nil(entry.lnum, 1),
col = vim.F.if_nil(entry.col, 1), col = vim.F.if_nil(entry.col, 1),
text = text, text = text,
type = entry.qf_type,
} }
end end

View File

@@ -1121,12 +1121,12 @@ end
function make_entry.gen_from_diagnostics(opts) function make_entry.gen_from_diagnostics(opts)
opts = opts or {} opts = opts or {}
local type_diagnostic = vim.diagnostic.severity
local signs = (function() local signs = (function()
if opts.no_sign then if opts.no_sign then
return return
end end
local signs = {} local signs = {}
local type_diagnostic = vim.diagnostic.severity
for _, severity in ipairs(type_diagnostic) do for _, severity in ipairs(type_diagnostic) do
local status, sign = pcall(function() local status, sign = pcall(function()
-- only the first char is upper all others are lowercalse -- only the first char is upper all others are lowercalse
@@ -1183,6 +1183,13 @@ function make_entry.gen_from_diagnostics(opts)
} }
end end
local errlist_type_map = {
[type_diagnostic.ERROR] = "E",
[type_diagnostic.WARN] = "W",
[type_diagnostic.INFO] = "I",
[type_diagnostic.HINT] = "N",
}
return function(entry) return function(entry)
return make_entry.set_default_entry_mt({ return make_entry.set_default_entry_mt({
value = entry, value = entry,
@@ -1193,6 +1200,7 @@ function make_entry.gen_from_diagnostics(opts)
lnum = entry.lnum, lnum = entry.lnum,
col = entry.col, col = entry.col,
text = entry.text, text = entry.text,
qf_type = errlist_type_map[type_diagnostic[entry.type]],
}, opts) }, opts)
end end
end end