blink.cmp icon indicating copy to clipboard operation
blink.cmp copied to clipboard

buffer source stops working in cmdline

Open raulchen opened this issue 1 month ago • 10 comments

Make sure you have done the following

  • [x] Updated to the latest version of blink.cmp
  • [x] Searched for existing issues and documentation (try <C-k> on https://cmp.saghen.dev)

Bug Description

I have the following config.

  cmdline = {
    sources = function()
      local type = vim.fn.getcmdtype()
      -- Search forward and backward
      if type == '/' or type == '?' then return { 'buffer' } end
      -- Command line
      if type == ':' then return { 'cmdline', 'buffer' } end
      -- Input (vim.fn.input())
      if type == '@' then return { 'buffer' } end
      return {}
    end,
    ...
  }

the buffer source used to work perfectly in the cmdline mode, regardless of what command it is. after https://github.com/saghen/blink.cmp/pull/1734, now buffer source only works for :s/:g and there is no way to make it work for other command.

cc @soifou

Relevant configuration


neovim version

NVIM v0.11.5

blink.cmp version

1.7.0

raulchen avatar Nov 11 '25 00:11 raulchen

Thanks, you pointed out a problem.

For your issue, using the latest version, I suggest you remove cmdline.sources and add sources.providers.buffer.enabled = true.

soifou avatar Nov 11 '25 13:11 soifou

Hmm reverted, actually I might investigate this more deeply.

soifou avatar Nov 11 '25 14:11 soifou

thanks for the reply. The issue is here. Now I have patched this function to workaround this issue.

raulchen avatar Nov 11 '25 19:11 raulchen

With the new logic, we only enable the buffer source where it makes sense (searching, substitution, input). What use case do you have to enable the buffer source globally in the cmdline?

saghen avatar Nov 11 '25 19:11 saghen

@saghen That's a good question I should have asked it earlier but the underlying issue is that enabled can't seem to be overriden by user config. If they want to enable the buffer source while in : so be it, set enabled = true should work (think this is because of call_or_get logic).

soifou avatar Nov 11 '25 20:11 soifou

@saghen e.g., when I do vimgrep or G commit -m "..." (G is a git wrapper), I'd like to complete words from the buffers.

@soifou do you mean providers.buffer.enabled = true? this still doesn't work unfortunately.

raulchen avatar Nov 12 '25 17:11 raulchen

if we don't want to enable it globally, we can also make the list of commands configurable.

raulchen avatar Nov 12 '25 17:11 raulchen

Pushed an update, grep commands come definitively into that list. I'm not sure though if we want to handle plugins commands like G commit -m.

do you mean providers.buffer.enabled = true? this still doesn't work unfortunately.

Yeah that was I meant in my previous comment, this should work but currently it's not :) I add that to my list.

soifou avatar Nov 12 '25 17:11 soifou

@soifou can we make it configurable? I have a few other self-defined commands that need the buffer source.

raulchen avatar Nov 12 '25 21:11 raulchen

@raulchen on main you can now remove your cmdline.sources and add sources.providers.buffer.enabled = true to workaround this. The buffer source will be always enabled. Or you can tweak it in a function if you need more control.

can we make it configurable?

Make sense, I'll put this on my todo!

soifou avatar Nov 25 '25 10:11 soifou