hrsh7th / nvim-compe

Auto completion Lua plugin for nvim

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[feature] hope compe#confirm() can select the first selection, like vscode, when we set `menuone, noselect`.

MaiLunJiye opened this issue · comments

I love this plugin, thanks for your work

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

I config the keymap as following

_G.tab_complete = function()
    if vim.fn.pumvisible() == 1 then
        return vim.fn['compe#confirm']()
    elseif vim.fn.call("vsnip#available", {1}) == 1 then
        return t "<Plug>(vsnip-expand-or-jump)"
    else
        return t "<Tab>"
    end
end

remap("i", "<Tab>", "v:lua.tab_complete()", {expr = true})
remap("s", "<Tab>", "v:lua.tab_complete()", {expr = true})

I hope it can use <TAB> to confirm and select the first one as well as vscode.
However, after setting set completeopt=menuone,noselect,required by nvim-compe,
I can't use <TAB> to confirm and select the first one.
I have to tap <C-n> or <Down> to select the first one in popup-menu and then tap <TAB> to confirm.
It might be ehanced.

Describe the solution you'd like

Maybe compe#confirm() can check whether select an item in popup-menu.
if not, select the first one and confirm. if yes, confirm.

Describe alternatives you've considered

Additional context

vscode behavior

type something, popup-menu open, but noselect.
截屏2021-07-24 下午10 07 06

tap <TAB>, confirm and select the first one.

截屏2021-07-24 下午10 11 13

You can use compe#confirm({ 'keys': '<CR>', 'select': v:true }). See https://github.com/hrsh7th/nvim-compe#how-to-automatically-select-the-first-match