mirror of
https://github.com/neovim/neovim.git
synced 2025-09-28 14:08:32 +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)
|
||||
opts = opts or {}
|
||||
|
||||
if not api.nvim_buf_is_loaded(bufnr) then
|
||||
return
|
||||
end
|
||||
|
||||
once_buf_loaded(bufnr, function()
|
||||
-- 10 is the default sign priority when none is explicitly specified
|
||||
local priority = opts.signs and opts.signs.priority or 10
|
||||
local get_priority = severity_to_extmark_priority(priority, opts)
|
||||
@@ -1675,6 +1672,7 @@ M.handlers.signs = {
|
||||
})
|
||||
end
|
||||
end
|
||||
end)
|
||||
end,
|
||||
|
||||
--- @param namespace integer
|
||||
@@ -1697,10 +1695,7 @@ M.handlers.underline = {
|
||||
bufnr = vim._resolve_bufnr(bufnr)
|
||||
opts = opts or {}
|
||||
|
||||
if not api.nvim_buf_is_loaded(bufnr) then
|
||||
return
|
||||
end
|
||||
|
||||
once_buf_loaded(bufnr, function()
|
||||
local ns = M.get_namespace(namespace)
|
||||
if not ns.user_data.underline_ns then
|
||||
ns.user_data.underline_ns =
|
||||
@@ -1736,6 +1731,7 @@ M.handlers.underline = {
|
||||
)
|
||||
end
|
||||
save_extmarks(underline_ns, bufnr)
|
||||
end)
|
||||
end,
|
||||
hide = function(namespace, bufnr)
|
||||
local ns = M.get_namespace(namespace)
|
||||
@@ -1795,10 +1791,7 @@ M.handlers.virtual_text = {
|
||||
bufnr = vim._resolve_bufnr(bufnr)
|
||||
opts = opts or {}
|
||||
|
||||
if not api.nvim_buf_is_loaded(bufnr) then
|
||||
return
|
||||
end
|
||||
|
||||
once_buf_loaded(bufnr, function()
|
||||
if opts.virtual_text then
|
||||
if opts.virtual_text.format then
|
||||
diagnostics = reformat_diagnostics(opts.virtual_text.format, diagnostics)
|
||||
@@ -1832,7 +1825,12 @@ M.handlers.virtual_text = {
|
||||
buffer = bufnr,
|
||||
group = ns.user_data.virt_text_augroup,
|
||||
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
|
||||
@@ -1840,6 +1838,7 @@ M.handlers.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)
|
||||
end)
|
||||
end,
|
||||
hide = function(namespace, bufnr)
|
||||
local ns = M.get_namespace(namespace)
|
||||
@@ -2054,10 +2053,7 @@ M.handlers.virtual_lines = {
|
||||
bufnr = vim._resolve_bufnr(bufnr)
|
||||
opts = opts or {}
|
||||
|
||||
if not api.nvim_buf_is_loaded(bufnr) then
|
||||
return
|
||||
end
|
||||
|
||||
once_buf_loaded(bufnr, function()
|
||||
local ns = M.get_namespace(namespace)
|
||||
if not ns.user_data.virt_lines_ns then
|
||||
ns.user_data.virt_lines_ns =
|
||||
@@ -2101,6 +2097,7 @@ M.handlers.virtual_lines = {
|
||||
end
|
||||
|
||||
save_extmarks(ns.user_data.virt_lines_ns, bufnr)
|
||||
end)
|
||||
end,
|
||||
hide = function(namespace, bufnr)
|
||||
local ns = M.get_namespace(namespace)
|
||||
|
Reference in New Issue
Block a user