neovim: how to select last entry on menu opening in nvim-cmp?

263 views Asked by At

How can I get cmp.complete() in nvim-cmp to start from the last entry. This is default behavior in vim. I want nvim-cmp to open on pressing <C-p> and start from the end of completion list, if its open then select previous entry. <C-n> works similarly, it was easy to get that working. I want it to match the behavior that vim's default completion has. I use select_prev_item() twice for now to go to last entry. Thats hacky and slow. I tried this too, but here I want cmp.complete() to select last entry on open:

["<C-p>"] = function()
    if cmp.visible() then
        cmp.select_prev_item({ behavior = cmp.SelectBehavior.Insert })
    else
        cmp.complete({
            config = {
                reason = cmp.ContextReason.Auto,
                view = { entries = { selection_order = "bottom_up" }
                }
            }
        })
    end
end,
0

There are 0 answers