1

When you do popup_create({whatever}, #{ line: m, col: n}), m and n are meant to be screen column numbers, as per :help popup_create-arguments.

But what if I want to position the popup at a specific document line and column?

Well, line: and col: can be given 'cursor±offset', which is basically a way to change the origin from which line and col are counted, and since the offset from the cursor can be computed as [desiredline - line('.'), desiredcol - col('.')], one can craft the two 'cursor±offset' strings carefully to put the popup where they want.

By carefully I mean that one needs to take care of + and -, which is probably not that hard.

But what makes the thing so hard are two points:

  1. How do I detect (in order to abort the creation) if the position where I want to put the popup in the given buffer is
    • out of the terminal window?
    • within the terminal window but out of the current Vim window?
  2. Most importantly, how in the world do I deal with the case of wrap being turned on?

I'd be tempted to open a request (I'm checking if one exists already) for having one of these:

  • popup_create to accept the text line and text column numbers for easy positioning it with respect to text
  • a general to_screenpos function accepting a text line and text column numbers and converting them to a position on the screen, which would allow preprocessing [line('.') ± offset, col('.') ± offset] before passing it to popup_create; it could even result in [] to communicate that position is not visible, so one could not call popup_create in that case.

but I'd like to see if a handy solution exits already.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.