TheBlob42 / drex.nvim

Another directory/file explorer for Neovim written in Lua
GNU General Public License v3.0
96 stars 8 forks source link

Remaining buffer after :DrexDrawerToggle #5

Closed jasper-schnabel closed 2 years ago

jasper-schnabel commented 2 years ago

Hey,

Thanks for the very cool plugin, I really like the simplicity.

I have found something that causes me trouble. When you call Drex with :DrexDrawerToggle and then close it again with :DrexDrawerToggle a Drex buffer remains, which is very annoying when cycling through the buffers.

Before:

screenshot_2021-12-24_10:41:37

After:

screenshot_2021-12-24_10:41:49

TheBlob42 commented 2 years ago

First of all thanks for the kind words :slightly_smiling_face:

The reason you see the buffer in your buffer list is because of two things:

  1. drex does not "clean up" old buffers so they can be reused when you open the same directory again
  2. all drex buffers are have the option buflisted set on by default, so that these buffers show up in the buffer list
    (check :h 'buflisted')

Call DrexDrawerToggle, then immediately check your buffer list and you will see that the drex buffer is present already even before closing it again

I do not plan to change the behavior of keeping drex buffers around for reusage (1.). Imagine the following scenario: you open the drawer, then expand some sub directories and then close the drawer window again. Now when you re-open it you would probably expect the drawer window to be exactly as you left it (with all directories expanded). Also this reduces the number of directory scans that have to be done when opening and closing drex buffers

However I made the drex buffers "listed" intentionally (2.) so I could easily jump to a specific already opened buffer via the buffer list. If this does work against the flows of other users I could make this option configurable, so that drex buffers would be "unlisted" by default and not appear in the buffer list at all (for those who prefer to not see them there). Would that solve your problem here? :thinking:

jasper-schnabel commented 2 years ago

If this does work against the flows of other users I could make this option configurable, so that drex buffers would be "unlisted" by default and not appear in the buffer list at all (for those who prefer to not see them there). Would that solve your problem here?

Thanks for the quick response and the detailed explanation of the buffer, that definitely made sense to me. Yes that would absolutely solve my problem and would be great.

Thanks

TheBlob42 commented 2 years ago

I had another thought about this and there is a simple solution without the need for another configuration option.
Just add the following snippet to your configuration:

vim.cmd('autocmd FileType drex setlocal nobuflisted')

I will probably add some information about this to the repository wiki
Please let me know if you have any more questions :slightly_smiling_face: