Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmp.accept with index doesn't work when no item is selected #633

Closed
2 tasks done
sefidel opened this issue Dec 18, 2024 · 0 comments
Closed
2 tasks done

cmp.accept with index doesn't work when no item is selected #633

sefidel opened this issue Dec 18, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@sefidel
Copy link

sefidel commented Dec 18, 2024

Make sure you have done the following

  • I have updated to the latest version of blink.cmp
  • I have read the README

Bug Description

Early return in cmp.accept prevents accepting nth item when none is selected.
This prevents users from selecting nth item using keybind if they have completion.list.selection set to either auto_insert or manual.

Relevant code

Relevant configuration

keymap = {
  preset = 'enter',
  ['<A-1>'] = { function(cmp) cmp.accept({ index = 1 }) end },
  ['<A-2>'] = { function(cmp) cmp.accept({ index = 2 }) end },
  ['<A-3>'] = { function(cmp) cmp.accept({ index = 3 }) end },
  ['<A-4>'] = { function(cmp) cmp.accept({ index = 4 }) end },
  ['<A-5>'] = { function(cmp) cmp.accept({ index = 5 }) end },
  ['<A-6>'] = { function(cmp) cmp.accept({ index = 6 }) end },
  ['<A-7>'] = { function(cmp) cmp.accept({ index = 7 }) end },
  ['<A-8>'] = { function(cmp) cmp.accept({ index = 8 }) end },
  ['<A-9>'] = { function(cmp) cmp.accept({ index = 9 }) end },
},
completion = {
  menu = {
    draw = {
      columns = { { 'item_idx' }, { 'kind_icon' }, { 'label', 'label_description', gap = 1 } },
      components = {
        item_idx = {
          text = function(ctx) return tostring(ctx.idx) end,
          highlight = 'BlinkCmpItemIdx' -- optional, only if you want to change its color
        }
      }
    }
  }
}

completion = {
  list = {
    selection = 'auto_insert',
  }
}

neovim version

NVIM v0.11.0-dev

blink.cmp version: branch, tag, or commit

main b4c6fe6

@sefidel sefidel added the bug Something isn't working label Dec 18, 2024
@Saghen Saghen closed this as completed in ea12c51 Dec 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant