-
I've started to use nvim-metals and so far I'm both impressed and pleased! Thanks a lot! There's one thing I'm struggling to get to work though. When there's an inline diagnostic, either because my screen is not large enough or because I tend to split it in multiple windows (or tmux panes), the diagnostic is not always readable (it doesn't wrap). I wonder if it is possible to show this in the status when the cursor is in the line that contains the error/warning, or some other option I'm failing to find. Any pointers would be greatly appreciated. Thanks! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
Hey @reidrac! Thanks for the kind words! I'm glad you're enjoying it so far! So I personally just turn the virtual text off for Scala. I find that it doesn't work great since our error messages are so long. There is a couple different things you can do I guess to get around this. I've done this before and it works alright. The local function split_on(s, delimiter)
local result = {}
local from = 1
local delim_from, delim_to = string.find(s, delimiter, from)
while delim_from do
table.insert(result, string.sub(s, from, delim_from - 1))
from = delim_to + 1
delim_from, delim_to = string.find(s, delimiter, from)
end
table.insert(result, string.sub(s, from))
return result
end
local diagnostic_foramt = function(diagnostic)
return string.format("%s: %s", diagnostic.source, split_on(diagnostic.message, "\n")[1])
end
vim.diagnostic.config({ virtual_text = { format = diagnostic_foramt }, severity_sort = true }) It's a bit verbose, but I just pulled it out of my config. It can probably be simplified. Then if you want to see the full error message you can just trigger a mapping like this while you're on that line
Which will show you the full diagnostic in a float. I personally don't use the virtual text and just mainly utilize these:
Since I can quickly jump to the next diagnostic and it automatically opens in a float preview. Hope that helps! |
Beta Was this translation helpful? Give feedback.
Hey @reidrac! Thanks for the kind words! I'm glad you're enjoying it so far!
So I personally just turn the virtual text off for Scala. I find that it doesn't work great since our error messages are so long. There is a couple different things you can do I guess to get around this.
I've done this before and it works alright. The
vim.diagnostic
takes a table where you can pass in a function to do whatever you want to the diagnostic. So for example if you wanted to just display the first line via virtual text you could do this: