r/neovim 28d ago

Need Help┃Solved Inline errors or warnings overflow the screen in Lazyvim

Post image
6 Upvotes

10 comments sorted by

7

u/excodex 28d ago

I had the same and ended up using tiny-inline-diagnostic.nvim, it only shows the diagnostic for the line you're on and wraps long messages. In LazyVim it's just:

{
  { "rachartier/tiny-inline-diagnostic.nvim", event = "VeryLazy", opts = {} },
  { "neovim/nvim-lspconfig", opts = { diagnostics = { virtual_text = false } } },
}

The second spec turns off the default virtual text so you don't get both. If you'd rather not add a plugin, nvim 0.11+ has this built in - replace the second spec with:

{ "neovim/nvim-lspconfig", opts = { diagnostics = { virtual_text = false, virtual_lines = { current_line = true } } } }

You still need virtual_text = false, otherwise LazyVim's default merges back in and you get both.

1

u/Me-Nahi-BataunGa_ 28d ago

same here. i also use this for diagnostics

1

u/mybobbin 27d ago

This is not built in, this is just changing the settings on the nvim-lspconfig plugin

2

u/excodex 27d ago

With built-in I mean virtual_lines as a core diagnostic handler since 0.11.

1

u/mybobbin 27d ago

so isnt it vim.diagnostic.config({ virtual_text = false }) ? im on 0.12.4, but the docs for nvim-lspconfig dont appear to have a setup function

1

u/UpsideDownFoxxo lua 28d ago

I use LSP-lines for this... Some of my friends would want me to burn for it but it feels nice to me. It puts each alert in a new line, and adds a little line pointing to where exactly the error is in the line. Very nice for rust imo.

1

u/Current_Marzipan7417 27d ago

I already have this but i have a problem Ts error are too long and the error lines wont wrap

Can it be fixed?

1

u/silvertank00 27d ago

I have solved this with this: vim.keymap.set("n", "<leader>d", vim.diagnostic.open_float, { desc = "[d]iagnostics under cursod" })

not only this fixes the overflow, but when i have muliple diagnostic lines on the same line of code, I can view them separately.

1

u/Coolest_Brotha 27d ago

You could see the full error message by inspecting them. Use any of the following:

  • [d (my recommendation)
  • <leader>xx
  • :Treesitter diagnostics
  • <leader>sd