neovim-qt icon indicating copy to clipboard operation
neovim-qt copied to clipboard

[Feature Request] Support balloon

Open eyalk5 opened this issue 5 years ago • 3 comments

Well, it is a bit of a funny request, because neovim doesn't support balloon. Just vim. But I believe that it can be done.

My first impression is that it is simple. All that needs to be done is to export options ballooneval and balloondelay, and implement a simple code that calls QToolTip::showText based on the function ballooneval. Similar to this example: https://doc.qt.io/qt-5/qtwidgets-widgets-tooltips-example.html

So, we can actually go over neovim in this case.

This can be really beneficial for vimspector. https://github.com/puremourning/vimspector/issues/29

I'd like to hear you opinion on the simplicity even if you are not going to implement this (or even approve a PR).

eyalk5 avatar Jan 28 '20 11:01 eyalk5

On the GUI side this seems simple. Expose a method to set the balloon. For simplification lets ignore balloondelay for now.

It seems a balloon show() method places the balloon at the mouse cursor (I dont think there is a balloon for the text cursor). Now this means balloonexpr is called on a mouse movement (after some delay).

Sadly there no mouse tracking in vim/nvim. The UI would have to notify nvim about mouse movements with screen coordinates i.e. call balloonexpr.

And finally the balloonexpr would need to translate the mouse event coordinates into a window/buffer. I dont think balloonexpr is very useful without information about the local buffer Vim usually provides the following to balloonexxpr. This is probably the hardest bit.

	v:beval_bufnr	number of the buffer in which balloon is going to show
	v:beval_winnr	number of the window
	v:beval_winid	ID of the window
	v:beval_lnum	line number
	v:beval_col	column number (byte index)
	v:beval_text	word under or after the mouse pointer

For nvim-q it is perfectly fine to accept balloon notifications. Even easier if the notification includes the coordinates. That last part requires mapping coordinates so I'm unsure if it can be done in vimscript alone.

equalsraf avatar Jan 28 '20 23:01 equalsraf

The Vim balloon API is really, really bad. Nvim core will eventually support hover events, would prefer to leave balloon API in its grave....

Meanwhile a GUI (nvim-qt) can capture hover events and show a floating window. Nvim 0.5 will have some higher-level floating-window functions to make it easier to give them typical behavior (delay, borders, timeout, etc.)

justinmk avatar Jan 29 '20 07:01 justinmk

Seems for a UI-side hover/balloon, core nvim would just need an API function which takes (grid, row, col) and gives back (winid, rownr, colnr). This function already exists internally and could be easily exposed.

bfredl avatar Jan 29 '20 08:01 bfredl