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

Accepting cmdline completion inserts excess -- when using selection = "auto_insert" #702

Closed
2 tasks done
chrisgrieser opened this issue Dec 21, 2024 · 7 comments
Closed
2 tasks done
Labels
accept Applying a completion item to the buffer bug Something isn't working cmdline Related to the command line

Comments

@chrisgrieser
Copy link
Contributor

chrisgrieser commented Dec 21, 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

  1. press /
  2. type something
  3. select first item with <C-n>
  4. accept with <C-y>
  5. the accepted item has a leading -- in there

somewhat related, the enter keymap preset together with the default select = "preselect" is also not ideal. It's technically not buggy, but pressing enter often selects an item, even though you intend to search for what you have currently typed.

Relevant configuration

opts = {
	completion = {
		list = {
			selection = "auto_insert",
		},
	},
},

neovim version

NVIM v0.10.2

blink.cmp version: branch, tag, or commit

0.8.0

@chrisgrieser chrisgrieser added the bug Something isn't working label Dec 21, 2024
@Saghen Saghen added accept Applying a completion item to the buffer cmdline Related to the command line labels Dec 21, 2024
@Saghen Saghen changed the title Bug: accepting cmdline completion inserts excess -- when using selection = "auto_insert" Accepting cmdline completion inserts excess -- when using selection = "auto_insert" Dec 21, 2024
@itse4elhaam
Copy link

itse4elhaam commented Dec 21, 2024

I dont know if this is related or not, but when I am writing a command in Neovim, it is automatically popping up the suggestions but it was not like this before the recent update.

How can I disable it? It should only appear on Tab like it used to.

Edit: I figured out that unknowingly I was using nvim-cmp for cmd completions, and now that I am using blink.cmp. I want some changes. For example, I want to not trigger by default and only trigger on Tab. Is that possible?

@Saghen
Copy link
Owner

Saghen commented Dec 21, 2024

@itse4elhaam Sounds like you'll want to wait for #697 so you can disable auto_show in cmdline mode

@Saghen
Copy link
Owner

Saghen commented Dec 21, 2024

@chrisgrieser I'm unable to reproduce this, could you provide an example file and maybe a video of it happening?

@itse4elhaam
Copy link

Hey @Saghen, Can something like this work as a temporary workaround?

-- NOTE: not working right now in the current state

vim.api.nvim_create_autocmd("CmdlineEnter", {
  callback = function()
    require("blink.cmp").opts.completion.menu.auto_show = false
  end,
})

vim.api.nvim_create_autocmd("CmdlineLeave", {
  callback = function()
    require("blink.cmp").opts.completion.menu.auto_show = true
  end,
})

@Saghen
Copy link
Owner

Saghen commented Dec 21, 2024

Yes! Very hacky so it might break in the future :)

@itse4elhaam
Copy link

That did not work so I implemented this:

vim.api.nvim_create_autocmd("CmdlineEnter", {
  callback = function()
    vim.api.nvim_set_keymap('c', '<CR>', '<CR>', { noremap = true, silent = true })
  end,
})

For some context: I have remapped my enter and tab both for completion but in the command line it just execs my current command instead of going to the selection.

Just for reference:

      keymap = {
        preset = "super-tab",
        ["<CR>"] = { "accept", "fallback" },
      }

@chrisgrieser
Copy link
Contributor Author

chrisgrieser commented Dec 21, 2024

@Saghen

sure, here is the video. (edit: video is using noice.nvim. However, just checked, with noice.nvim turned off, the behavior is the same.)

Pasted.image.2024-12-21.at.21.51.44.mp4

@Saghen Saghen closed this as completed in 0f92fb8 Dec 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
accept Applying a completion item to the buffer bug Something isn't working cmdline Related to the command line
Projects
None yet
Development

No branches or pull requests

3 participants