camspiers / snap

A fast finder system for neovim.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

"Ignore current buffer" setting for buffer producer

garymh opened this issue Β· comments

Thought of another feature request πŸ˜„:

The buffers listing command is great, but I have some muscle memory with FZF/Telescope where the buffers list ignores the current buffer you're in. I've been using this as a psuedo <c-^>. since the next buffer is the most recently used buffer (although that might not be the case in snap).

I've been playing with ways to do this with vim.api.nvim_get_current_buf(), but I think snap's UI is counting as a buffer which throws off any possible conditionals.

You can access the current buffer using the winnr property that is on the request. Omitting the vim.fn because I'm on my phone:

bufname(winbufnr(request.winnr))

With:

5c32028

and:

76b136f

You can now do arbitrary filtering:

snap.run {
  producer = snap.get'consumer.fzy'(
    snap.get'consumer.filter'(
      function (request, result)
        -- return boolean, if true then result is added, otherwise it is filtered
      end,
      snap.get'producer.vim.buffer'
    ),
  ),
  select = snap.get'select.file'.select,
  multiselect = snap.get'select.file'.multiselect,
  views = {snap.get'preview.file'}
}

Awesome! Thank you!!