Skip to content

Diagnostic message cut off vertically if not enough lines in buffer #60

@Cuberootex

Description

@Cuberootex

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:

Image

And now, with only 3 lines.

Image

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

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions