Saghen / blink.cmp

Performant, batteries-included completion plugin for Neovim
MIT License
1.21k stars 71 forks source link

builtin buffer provider could be shadowed by lsp, thus ignoring words from comments in suggestions #303

Closed xiaket closed 2 days ago

xiaket commented 3 days ago

Make sure you have done the following

Bug Description

First off, I really appreciate the effort into this plugin. The performance is sooo impressive! Kudos!

I would like to report that the buffer provider has not included the words from the comments, is that intentional?

Way to reproduce this issue:

  1. Run echo "# uuid is a library used by this module" >> a.py && nvim a.py.
  2. enter uu, my expected behavior(also the behavior in cmp IIRC) is uuid will show up, but it is not.

Relevant configuration

{
    "saghen/blink.cmp",
    -- lazy loading handled internally
    lazy = false,
    -- use a release tag to download pre-built binaries
    version = "v0.*",

    opts = {
      -- 'enter' for mappings similar to 'super-tab' but with 'enter' to accept
      keymap = { preset = "enter" },

      -- experimental auto-brackets support
      accept = { auto_brackets = { enabled = true } },

      -- experimental signature help support
      trigger = { signature_help = { enabled = true } },
    },
  },

neovim version

v0.10.2

blink.cmp version: branch, tag, or commit

master

xiaket commented 3 days ago

After some digging, it looks like removing the line here would force the use of buffer even when lsp is available and resolve the issue.

xiaket commented 3 days ago

I've changed my config to be:

      sources = {
        -- list of enabled providers
        completion = {
          enabled_providers = { "lsp", "path", "snippets", "buffer" },
        },

        -- table of providers to configure
        providers = {
          buffer = {
            name = "Buffer",
            module = "blink.cmp.sources.buffer",
            score_offset = -3,
          },
        },
      },

And the completion looks good to me now. Thanks! Please feel free to close this issue. :)

Saghen commented 2 days ago

Sounds good! I've created #311 which might make this a bit more intuitive.

Fyi, you can enable-disable the fallback_for behavior by passing a function in its place. You could check the current LSP and only disable the fallback_for for the misbehaving LSPs.

fallback_for = function()
  local clients = vim.lsp.get_clients({ bufnr = 0 })
  for _, client in pairs(clients) do
    if client.name == 'lua_ls' then return {} end
  end
  return { 'lsp' }
end

First off, I really appreciate the effort into this plugin. The performance is sooo impressive! Kudos!

My pleasure!