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

Missing completions after longer period of time #40

Open
lcmen opened this issue Mar 31, 2022 · 7 comments
Open

Missing completions after longer period of time #40

lcmen opened this issue Mar 31, 2022 · 7 comments

Comments

@lcmen
Copy link

lcmen commented Mar 31, 2022

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
Copy link
Author

lcmen commented Apr 23, 2022

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
Copy link
Author

lcmen commented Apr 28, 2022

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).

@otavioschwanck
Copy link

Same problem here, using barbar to delete unused buffers

@lcmen
Copy link
Author

lcmen commented May 28, 2022

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

@otavioschwanck
Copy link

@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 } }

@lcmen
Copy link
Author

lcmen commented Jun 7, 2022

@otavioschwanck why do you need custom function?

@otavioschwanck
Copy link

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants