mengelbrecht / lightline-bufferline

A lightweight plugin to display the list of buffers in the lightline vim plugin
MIT License
334 stars 25 forks source link

How to unhide all buffers in bufferline #110

Closed wuelnerdotexe closed 2 years ago

wuelnerdotexe commented 2 years ago

I installed this wonderful plugin and configured it to be perfect for my workflow. I wanted to use it to know what buffers I have at any moment regardless of their type, name or state; but unfortunately for my case, bufferline hides buffers like 'startify' and 'nerdtree' by default. Is there a way to disable buffer filtering? Thanks in advance 🙏🏼

mengelbrecht commented 2 years ago

@wuelnerdotexe thanks 🙂

Currently the default buffer filtering can only be extended and not replaced. I am thinking of adding an option to disable the default filtering while still being able to specify a custom filter function. Until this is ready you could replace the lines https://github.com/mengelbrecht/lightline-bufferline/blob/3a8a4efba81f6c65b94510e93160e0e4061bf03d/autoload/lightline/bufferline.vim#L171-L172 with

  return 1

That should disable the filtering for all buffers.

wuelnerdotexe commented 2 years ago

Thank you for your prompt response. I have applied return 1 to the s:filter_buffer(i) function and it seems to disable filtering, but unfortunately it shows non-existent empty buffers.

[Bufferline in the upper right corner of Neovim]

I've played around with the code a bit, but haven't been able to fix the error. So for the time being I will wait for its official implementation, I have found that my current buffer workflow together with lightline's native tabs function makes sense.

wuelnerdotexe commented 2 years ago

@mengelbrecht, thank you very much again for this plugin. You can close this issue if you wish :)

mengelbrecht commented 2 years ago

@wuelnerdotexe I installed startify and nerdtree to investigate why the buffers are hidden. The buffers don't have the buflisted option set and are thus hidden by the default filter.

If you replace the s:filter_buffer function with the following snippet it should lead to the result you want:

function! s:filter_buffer(i)
  let filetype = getbufvar(a:i, '&filetype')
  return bufexists(a:i)
       \ && (buflisted(a:i) || filetype ==# "nerdtree" || filetype ==# "startify")
       \ && filetype !=# 'qf'
       \ && s:tabpage_filter(a:i) 
       \ && call(s:bufferFilterFunc, [a:i])
endfunction
wuelnerdotexe commented 2 years ago

Now it works as expected, many thanks @mengelbrecht. I proceed to close the issue. 🥳