-
Notifications
You must be signed in to change notification settings - Fork 18
Open
Description
I'm displaying diagnostic messages in the top right hand corner, and I noticed that sometimes, diagnostics wouldn't show in files that have very few lines of code in them. It turns out that if the diagnostic message spans multiple lines, the display of that message will be limited by the number of lines of the current file.
Here's a 6-line file, where the message can be fully displayed:
And now, with only 3 lines.
Using NVIM v0.10.4
my diagflow lua configuration
local function get_severity_icon(severity)
local icons = {
error = "",
info = "",
hint = "",
warn = "",
}
if severity == vim.diagnostic.severity.ERROR then
return icons.error
elseif severity == vim.diagnostic.severity.INFO then
return icons.info
elseif severity == vim.diagnostic.severity.HINT then
return icons.hint
elseif severity == vim.diagnostic.severity.WARN then
return icons.warn
else
return ""
end
end
local function format_diag(diagnostic)
local icon_string = ""
if diagnostic.severity ~= nil then
icon_string = get_severity_icon(diagnostic.severity)
return string.format("%s %s\n%s", icon_string, diagnostic.source, diagnostic.message)
end
return string.format("%s\n%s", diagnostic.source, diagnostic.message)
end
require("diagflow").setup({
enable = true,
max_width = 60, -- the maximum width of the diagnostic messages
max_height = 12, -- the maximum height per diagnostics
severity_colors = { -- the highlight groups to use for each diagnostic severity level
error = "diagnosticfloatingerror",
warning = "diagnosticfloatingwarn",
info = "diagnosticfloatinginfo",
hint = "diagnosticfloatinghint",
},
format = format_diag, -- the format function use to format the diagnostic messages
gap_size = 1,
scope = "cursor", -- 'cursor', 'line' this changes the scope, so instead of showing errors under the cursor, it shows errors on the entire line.
padding_top = 0,
padding_right = 0,
text_align = "right", -- 'left', 'right'
placement = "top", -- 'top', 'inline'
inline_padding_left = 0, -- the padding left when the placement is inline
update_event = { "diagnosticchanged", "bufreadpost", "bufenter", "bufleave" }, -- the event that updates the diagnostics cache
toggle_event = {"insertenter", "insertleave"}, -- if insertenter, can toggle the diagnostics on inserts
show_sign = false, -- set to true if you want to render the diagnostic sign before the diagnostic message
render_event = { "diagnosticchanged", "cursormoved", "bufenter", "bufleave" , "insertenter", "insertleave"},
border_chars = {
top_left = "·",
top_right = "·",
bottom_left = "·",
bottom_right = "·",
vertical = " ",
},
show_borders = true,
})Metadata
Metadata
Assignees
Labels
No labels

