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

add option to customize direction of completion menu

Open jam1015 opened this issue 3 years ago • 3 comments

Is your feature request related to a problem? Please describe.

when the (new, custom) autocomplete menu pops up above the text, the closest match is on top of the menu, furthest from the text I'm typing, making me have to move my gaze further than I'd like to

Describe the solution you'd like

add an option so that when the autocomplete menu pops up above, the closest match is at the bottom (closest to the text being typed) <C-n> would then pick the next item moving the selection physically upward on the screen. opposite for <C-p>, or whatever custom keybinding are used.

Describe alternatives you've considered

looked briefly through the docs to see if this is already an option; didn't see anything but maybe I missed it.

jam1015 avatar Aug 08 '22 20:08 jam1015

One more vote for this request. Basically reverse the completion list order. This way the nearest match is close to where the cursor is and where the user is focused on, rather than at the top of the window. Thanks.

damnskippy avatar Aug 08 '22 21:08 damnskippy

Use 'pumheight' option to limit the height of popup menu.

chemzqm avatar Aug 09 '22 17:08 chemzqm

My suggestion is sent your feature request to vim first, we can follow the behavior of the built-in pum.

chemzqm avatar Aug 09 '22 18:08 chemzqm

I had the same problem but I see that you can disable that function with: "suggest.noselect": true
here we talk about it: https://github.com/neoclide/coc.nvim/discussions/4088

Cris-lml007 avatar Aug 29 '22 20:08 Cris-lml007

@chemzqm just my humble 2c - It would be a nice feature to dynamically reverse the completion list based on whether popup is placed above or below the cursor, so that the best match is near the cursor rather than the top of the popup. FWIW, outside of vim, fuzzy finders commonly offer the option to reverse the search list in this manner. Just offering a suggestion. Thank you.

damnskippy avatar Aug 30 '22 14:08 damnskippy

Fixed by 6d708118

chemzqm avatar Aug 31 '22 16:08 chemzqm

@chemzqm could the docs besides also follow direction? For example, currently, when pum is above, and reversed, the suggestion is shown close to the cursor, which is nice, but the docs for this item is still displayed top right of pum, so, this doesn't help much at avoiding eye movements. I suggest when it's reversed, the docs float bottom to align with pum's float bottom. This would be a proper up mirror image of down pum/doc behavior.

oblitum avatar Aug 31 '22 17:08 oblitum

I should then, suggest to make that the last addition to this and avoid going further, like making documentation text content upside-down 😄

oblitum avatar Aug 31 '22 17:08 oblitum

Fixed by 6d70811

Thank you!!! Reverse list works great. Perhaps one minor nit is what @oblitum is pointing out regarding doc which still goes to the top. But I can totally see how it gets tricky to align the bottom of the doc "window" to align with the match position on pum, given the doc height can be variable based on the number of lines in the doc.

With the vim native pum, this problem wasn't there perhaps because it forced the pum direction to be always below the cursor if I'm not mistaken. The drawback is that the closer the cursor to the bottom of the viewport window fewer completion matches are visible. Not sure if it's worth it to add an option to force this behavior i.e. to add an option for that behavior.

Another thought - currently the popup seems to go above or below at ~50% of &lines value. Maybe if this value is configurable, then the user can say up until 80% of &lines pum will be below, and if it's further below, then pum will be above.

Just some thoughts. Incredibly grateful for all the effort you've put in (and continue to) into this plugin, thanks again.

damnskippy avatar Sep 01 '22 13:09 damnskippy