Right Align Virtual text

local rightAlignFormatFunction = function(diagnostic) -- luacheck: ignore
	local line = diagnostic.lnum
	local line_length = #(vim.api.nvim_buf_get_lines(0, line, line + 1, false)[1] or "")
	local lwidth = vim.api.nvim_get_option("columns")
        -- calculate the space needed to right align 
	local splen = string.rep(" ", lwidth - line_length - string.len(diagnostic.message) - 4)
	return string.format("%s🔥%s", splen, diagnostic.message)
end

vim.diagnostic.config({
	virtual_text = { source = false, prefix = "", format = rightAlignFormatFunction, spacing = 0 },
})
--

This Doesn’t seem to work.

I think that might be because you’re measuring the byte-length of the string. What you want is probably strdisplaywidth()

No. It doesn’t seem to work.
Thanks for you reply.