~thatdarnpat

https://thatdarnpat.com

Trackers

~thatdarnpat/nvim-culprit

Last active 11 months ago

#3 Fix popup placement bug 11 months ago

Ticket created by ~thatdarnpat on ~thatdarnpat/nvim-culprit

Currently happening when Fugitive first opens

#2 Add more config options 11 months ago

Ticket created by ~thatdarnpat on ~thatdarnpat/nvim-culprit

  • hash placement
  • log format
  • hl groups

#1 Fix config injection 11 months ago

Ticket created by ~thatdarnpat on ~thatdarnpat/nvim-culprit

#27 Show diagnostics in floating window 2 years ago

Comment by ~thatdarnpat on ~whynothugo/lsp_lines.nvim

I very much want something that will trigger on a CursorHold autocmd, but I'd like for it to display inside of a floating window instead of virtual lines because I find all of the "thrash" to be kind of jarring with diagnostics popping in and out as I scroll through my file.

I don't think vim.lsp.buf.hover is exactly what we want because doesn't always contain diagnostic information. My config has it usually populating with type information for whatever symbol is under the cursor. I think that vim.lsp.util.open_floating_preview() might be more appropriate, although I'm currently encountering 2 issues with getting it to work:

  1. Unless I'm reading something wrong, I don't see a good way to invoke LSP Lines for a given line. vim.lsp.util.open_floating_preview accepts a table of text to render, so ideally I'd be able to do something like vim.lsp.util.open_floating_preview(lsp_lines.get_diag_for_line(vim.api.nvim_get_current_line(), ... )
  2. The second argument of open_floating_preview is a syntax to string to set for the preview window, and I'm not sure if there's going to be a way to nicely highlight everything we'd want to include.

I was able to hack together a quick illustration of basically what I'm going for here.

vim.lsp.util.open_floating_preview(
  {vim.api.nvim_get_current_line(), '      └──── Unused local `lsp`.'},
  'lua',
  { width = 50, height = 2, focusable = false, wrap = false}
)

I think it might require some refactoring in the render.lua in order to get a function that can just return a table of diagnostic lines. I get that this functionality is not something you're particularly looking for, but would you be open to a PR that does this? If so, I might take a crack at it.

EDIT: Also, it's entirely possible that I've misunderstood something here. I've not used any of Neovim's floating window APIs before and haven't had a chance to really dig into lsp_lines.render.show and grok what's going on in there. Feel free to correct me if I'm missing something 😅