zefei / vim-wintabs

Modern buffer manager for Vim
MIT License
325 stars 25 forks source link

Add FzF support for wintab buffers #21

Closed alexanderjeurissen closed 6 years ago

alexanderjeurissen commented 6 years ago

I did some digging through the vim-wintabs source code and found the variable w:wintabs_buflist which is a array of buffer numbers that map to the buffers of a specific split.

I thought it would be great to have a FzF command to quickly fuzzy search for all wintab buffers that are assigned to the current split. So I quickly hacked together the following fzf snippet:

    function! s:WintabsBuffers()
      if exists("w:wintabs_buflist")
        call fzf#run({
        \ 'source': map(copy(w:wintabs_buflist), 'bufname(v:val)'),
        \ 'sink':   'e',
        \ 'window':  'enew' })
      else
        echo "wintabs not loaded"
      endif
    endfunction

    command! -nargs=* WintabsChose call s:WintabsBuffers()

Somehow (not sure if this is a bug) I noticed that the w:wintabs_buflist variable on vim enter is not an empty list (e.g. not set), which seems strange and requires me to have the exists("w:wintabs_buflist") failsafe (correct me if wrong)

I was wondering as seeing as wintabs already has integration with plugins like xolox session if integrating the above is of interest to you.

zefei commented 6 years ago

This looks great! I'd welcome any plugin integration, feel free to send a PR. I'd also love to be able to search in different scopes (window, vimtab, all). Thank you!

zefei commented 6 years ago

I actually tried adding an API to do this, but decided to scratch it off. The rational is that I think using fzf History together with g:wintabs_switchbuf would give you enough tools to achieve something similar. I'm closing this, but please feel free to re-open if History+g:wintabs_switchbuf isn't good enough for your workflow.

dylan-chong commented 5 years ago

A good solution is in #44