mirror of
https://github.com/neovim/neovim.git
synced 2025-09-28 05:58:33 +00:00
fix(diagnostic): show diagnostics on buffer load #35866
Problem: Diagnostics set on unloaded buffers are not shown when the buffer loads. Solution: Use `once_buf_loaded()` to show the diagnostics on BufRead is the buffer is not yet loaded.
This commit is contained in:

committed by
GitHub

parent
0790e08f52
commit
09266830bd
@@ -1636,10 +1636,7 @@ M.handlers.signs = {
|
|||||||
bufnr = vim._resolve_bufnr(bufnr)
|
bufnr = vim._resolve_bufnr(bufnr)
|
||||||
opts = opts or {}
|
opts = opts or {}
|
||||||
|
|
||||||
if not api.nvim_buf_is_loaded(bufnr) then
|
once_buf_loaded(bufnr, function()
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
-- 10 is the default sign priority when none is explicitly specified
|
-- 10 is the default sign priority when none is explicitly specified
|
||||||
local priority = opts.signs and opts.signs.priority or 10
|
local priority = opts.signs and opts.signs.priority or 10
|
||||||
local get_priority = severity_to_extmark_priority(priority, opts)
|
local get_priority = severity_to_extmark_priority(priority, opts)
|
||||||
@@ -1675,6 +1672,7 @@ M.handlers.signs = {
|
|||||||
})
|
})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end)
|
||||||
end,
|
end,
|
||||||
|
|
||||||
--- @param namespace integer
|
--- @param namespace integer
|
||||||
@@ -1697,10 +1695,7 @@ M.handlers.underline = {
|
|||||||
bufnr = vim._resolve_bufnr(bufnr)
|
bufnr = vim._resolve_bufnr(bufnr)
|
||||||
opts = opts or {}
|
opts = opts or {}
|
||||||
|
|
||||||
if not api.nvim_buf_is_loaded(bufnr) then
|
once_buf_loaded(bufnr, function()
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
local ns = M.get_namespace(namespace)
|
local ns = M.get_namespace(namespace)
|
||||||
if not ns.user_data.underline_ns then
|
if not ns.user_data.underline_ns then
|
||||||
ns.user_data.underline_ns =
|
ns.user_data.underline_ns =
|
||||||
@@ -1736,6 +1731,7 @@ M.handlers.underline = {
|
|||||||
)
|
)
|
||||||
end
|
end
|
||||||
save_extmarks(underline_ns, bufnr)
|
save_extmarks(underline_ns, bufnr)
|
||||||
|
end)
|
||||||
end,
|
end,
|
||||||
hide = function(namespace, bufnr)
|
hide = function(namespace, bufnr)
|
||||||
local ns = M.get_namespace(namespace)
|
local ns = M.get_namespace(namespace)
|
||||||
@@ -1795,10 +1791,7 @@ M.handlers.virtual_text = {
|
|||||||
bufnr = vim._resolve_bufnr(bufnr)
|
bufnr = vim._resolve_bufnr(bufnr)
|
||||||
opts = opts or {}
|
opts = opts or {}
|
||||||
|
|
||||||
if not api.nvim_buf_is_loaded(bufnr) then
|
once_buf_loaded(bufnr, function()
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
if opts.virtual_text then
|
if opts.virtual_text then
|
||||||
if opts.virtual_text.format then
|
if opts.virtual_text.format then
|
||||||
diagnostics = reformat_diagnostics(opts.virtual_text.format, diagnostics)
|
diagnostics = reformat_diagnostics(opts.virtual_text.format, diagnostics)
|
||||||
@@ -1832,7 +1825,12 @@ M.handlers.virtual_text = {
|
|||||||
buffer = bufnr,
|
buffer = bufnr,
|
||||||
group = ns.user_data.virt_text_augroup,
|
group = ns.user_data.virt_text_augroup,
|
||||||
callback = function()
|
callback = function()
|
||||||
render_virtual_text(ns.user_data.virt_text_ns, bufnr, line_diagnostics, opts.virtual_text)
|
render_virtual_text(
|
||||||
|
ns.user_data.virt_text_ns,
|
||||||
|
bufnr,
|
||||||
|
line_diagnostics,
|
||||||
|
opts.virtual_text
|
||||||
|
)
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
@@ -1840,6 +1838,7 @@ M.handlers.virtual_text = {
|
|||||||
render_virtual_text(ns.user_data.virt_text_ns, bufnr, line_diagnostics, opts.virtual_text)
|
render_virtual_text(ns.user_data.virt_text_ns, bufnr, line_diagnostics, opts.virtual_text)
|
||||||
|
|
||||||
save_extmarks(ns.user_data.virt_text_ns, bufnr)
|
save_extmarks(ns.user_data.virt_text_ns, bufnr)
|
||||||
|
end)
|
||||||
end,
|
end,
|
||||||
hide = function(namespace, bufnr)
|
hide = function(namespace, bufnr)
|
||||||
local ns = M.get_namespace(namespace)
|
local ns = M.get_namespace(namespace)
|
||||||
@@ -2054,10 +2053,7 @@ M.handlers.virtual_lines = {
|
|||||||
bufnr = vim._resolve_bufnr(bufnr)
|
bufnr = vim._resolve_bufnr(bufnr)
|
||||||
opts = opts or {}
|
opts = opts or {}
|
||||||
|
|
||||||
if not api.nvim_buf_is_loaded(bufnr) then
|
once_buf_loaded(bufnr, function()
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
local ns = M.get_namespace(namespace)
|
local ns = M.get_namespace(namespace)
|
||||||
if not ns.user_data.virt_lines_ns then
|
if not ns.user_data.virt_lines_ns then
|
||||||
ns.user_data.virt_lines_ns =
|
ns.user_data.virt_lines_ns =
|
||||||
@@ -2101,6 +2097,7 @@ M.handlers.virtual_lines = {
|
|||||||
end
|
end
|
||||||
|
|
||||||
save_extmarks(ns.user_data.virt_lines_ns, bufnr)
|
save_extmarks(ns.user_data.virt_lines_ns, bufnr)
|
||||||
|
end)
|
||||||
end,
|
end,
|
||||||
hide = function(namespace, bufnr)
|
hide = function(namespace, bufnr)
|
||||||
local ns = M.get_namespace(namespace)
|
local ns = M.get_namespace(namespace)
|
||||||
|
Reference in New Issue
Block a user