hover.nvim icon indicating copy to clipboard operation
hover.nvim copied to clipboard

Is hover open?

Open junkblocker opened this issue 7 months ago • 1 comments

This is similar to #1 . <c-n> and <C-p> are being mapped unconditionally in the suggested config. I would like to map them to switch hover providers only if hover is open, otherwise fallback to <C-n> / <C-p> (or nav through other popup menu which may be open etc.. How do I tell if a hover popup is currently open or not?

junkblocker avatar May 16 '25 13:05 junkblocker

Hey! I was looking into something similar and found a solution:

local bufnr = vim.api.nvim_get_current_buf()
local hover_win = vim.b[bufnr].hover_preview
if hover_win and vim.api.nvim_win_is_valid(hover_win) then
  -- window is open
else
  -- window is closed
end

Pretty much the same code is used in the enter function (source).

I hope this helps 🙂

patrickpichler avatar Sep 27 '25 10:09 patrickpichler