cmp-buffer icon indicating copy to clipboard operation
cmp-buffer copied to clipboard

Missing completions after longer period of time

Open lcmen opened this issue 3 years ago • 7 comments

Thank you for the plugin, it's awesome! I've configured it to autocomplete from all the buffers as described in the readme but I've noticed that after having Neovim opened for the whole day, the plugin misses some of the words (sometimes even from the same buffer so I have to fallback to ctrl-x ctrl-n). I'd love to provide more info but I'm not sure how to debug it. Any idea?

Thanks!

lcmen avatar Mar 31 '22 17:03 lcmen

I think I've found the problem. I was using BufOnly plugin to cleanup unused buffers. Unfortunately, it uses bdelete instead of bwipeout which doesn't remove buffer from vim.api.nvim_list_bufs() results. This led to having huge list of buffers (like 50-100) after a few hours of use.

lcmen avatar Apr 23 '22 17:04 lcmen

I'm going to try to use BufOnly.nvim instead and see how it goes. This plugin uses vim.api.nvim_buf_delete to delete a buffer (which according to documentation, behaves like bwipeout).

lcmen avatar Apr 28 '22 18:04 lcmen

Same problem here, using barbar to delete unused buffers

otavioschwanck avatar May 28 '22 18:05 otavioschwanck

@otavioschwanck with BufOnly.nvim, it has been working fine for me for a couple of weeks already.

lcmen avatar May 28 '22 18:05 lcmen

@lcmen to really fix i did this:

-- at lua/valid_lister_buffers.lua

local function return_listed_valid_buffers()
  local buffers = vim.api.nvim_list_bufs()
  local buffersToUse = {}
  local bufferIndex = 1

  for i=1,table.getn(buffers),1 do
    local buf = buffers[i]
    local byte_size = vim.api.nvim_buf_get_offset(buf, vim.api.nvim_buf_line_count(buf))

    if not (byte_size > 1024 * 128) and (vim.fn.buflisted(buf) == 1 or vim.fn.getbufvar(buf, '&buftype', 'ERROR') == 'terminal') then -- 1 Megabyte max
      buffersToUse[bufferIndex] = buf
      bufferIndex = bufferIndex + 1
    end
  end

  return buffersToUse
end

return return_listed_valid_buffers

-- at your config
    { name = "buffer", option = { get_bufnrs = function()
      return require('valid_listed_buffers')()
    end } }

otavioschwanck avatar Jun 03 '22 00:06 otavioschwanck

@otavioschwanck why do you need custom function?

lcmen avatar Jun 07 '22 14:06 lcmen

@otavioschwanck why do you need custom function?

with this function i get only the buffers that are really open and the file size uns lower then 128kbs.

otavioschwanck avatar Jun 07 '22 19:06 otavioschwanck