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

feature: select nth item in the completion list, and number items #382

Closed
theol0403 opened this issue Nov 25, 2024 · 2 comments
Closed

feature: select nth item in the completion list, and number items #382

theol0403 opened this issue Nov 25, 2024 · 2 comments
Labels
feature New feature or request

Comments

@theol0403
Copy link

theol0403 commented Nov 25, 2024

Feature Description

Thank you for this incredible plugin! I am honestly blown away by the modularity, structure, and expressive configuration you've built into this.

I am requesting the feature of showing item numbers inside the completion window - should not be too hard with your components system, and additionally a command to "select nth item".

Example (with cmp):
image

Benefits of displaying item numbers:

  • ability to quickly count number of times to hit Down/C-n/Tab
  • ability to provide context for a "select nth item" command/keybind
  • support people with screen readers

This has been implemented in this PR to nvim-cmp: hrsh7th/nvim-cmp#1491

Related:

@theol0403 theol0403 added the feature New feature or request label Nov 25, 2024
@max397574
Copy link
Contributor

what I think this would require

  1. allow confirming items based on visible position
  2. pass position in the window to the ctx used for components

@Saghen Saghen closed this as completed in 4b1a793 Nov 30, 2024
@Saghen
Copy link
Owner

Saghen commented Nov 30, 2024

Here's how I configured it locally, I'll add it to the readme

keymap = {
  preset = 'default',
  ['<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
        }
      }
    }
  }
}

Thank you for this incredible plugin! I am honestly blown away by the modularity, structure, and expressive configuration you've built into this.

❤️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants