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

feat: option to combine completion.list.selection = "auto_insert" and "preselect" #668

Open
SamuelBorn opened this issue Dec 20, 2024 · 1 comment
Labels
feature New feature or request

Comments

@SamuelBorn
Copy link

Feature Description

Citation from default config:

-- 'preselect' will automatically select the first item in the completion list

-- 'auto_insert' will not select any item by default, and insert the completion items automatically when selecting them

I would like to the see another option that combines them both.
The documentation could be described as:

-- 'preselect_auto_insert' will automatically select the first item in the completion list, and insert the completion items automatically when selecting them

The default preselect action though should not trigger auto_insert as this would be annoying.

So to accept the first solution one still has to press the keyboard shortcut for accept or select_and_accept.

But after selecting with select_prev and select_next, auto_insert should trigger and accepting would no longer be necessary.

@SamuelBorn SamuelBorn added the feature New feature or request label Dec 20, 2024
@ycycyyc
Copy link

ycycyyc commented Dec 20, 2024

After migrating from nvim-cmp, I kept the same behavior by using the following code.

  local list = require "blink.cmp.completion.list"
  local select = list.select
  list.select = function(idx, o)
    select(idx, o)
    local item = list.items[idx]
    require("blink.cmp.completion.trigger").suppress_events_for_callback(function()
      if idx and idx > 1 and item and list.config.selection == "preselect" then
        list.apply_preview(item)
      end
    end)
  end

it would be better if there is an option to combine "auto_inesrt " and "preselect".

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

2 participants