Show lsp diagnostic message on cursor line #911
Isrothy
started this conversation in
Show and tell
Replies: 2 comments 2 replies
-
When the diagnostic message contains '%', this snip of code shall be out of order. function diagnostics_message:update_status(is_focused)
local r, _ = unpack(vim.api.nvim_win_get_cursor(0))
local diagnostics = vim.diagnostic.get(0, { lnum = r - 1 })
if #diagnostics > 0 then
local top = diagnostics[1]
for _, d in ipairs(diagnostics) do
if d.severity < top.severity then
top = d
end
end
local icons = { " ", " ", " ", " " }
local hl = {
self.highlights.error,
self.highlights.warn,
self.highlights.info,
self.highlights.hint,
}
return highlight.component_format_highlight(hl[top.severity])
.. icons[top.severity]
.. " "
.. utils.stl_escape(top.message)
else
return ""
end
end
|
Beta Was this translation helpful? Give feedback.
0 replies
-
This is great! I added a catch for long messages as they were messing up my lualine components on the right hand side. local length_max = 90
local message = top.message
if #message > length_max then
message = string.sub(top.message, 1, length_max) .. " [...]"
end
return highlight.component_format_highlight(hl[top.severity])
.. icons[top.severity]
.. " "
.. utils.stl_escape(message) @Isrothy Have you considered submitting a PR to make this a built-in feautre? It's a fantastic component. |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I just made a lualine component which shows lsp diagnostic message on cursor line.
It looks like this

Beta Was this translation helpful? Give feedback.
All reactions