Skip to content

Add view to show open buffers only #744

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

Closed
cseickel opened this issue Oct 24, 2021 · 13 comments
Closed

Add view to show open buffers only #744

cseickel opened this issue Oct 24, 2021 · 13 comments
Labels
feature request PR please nvim-tree team does not have the bandwidth to implement; a PR will be gratefully appreciated

Comments

@cseickel
Copy link

I have this idea I'd like to implement, which is to have a file explorer which can be toggled between showing all files and only the files which are currently open. The purpose of this is to provide a good representation of the workspace for the current task you are focused on, both as a visual reminder and a way to switch buffers.

This an alternative to showing buffers as tabs (which I find confusing for some reason) or having a flat list of buffers that can be referenced on command with BufExplorer or :ls. I have also tried leaving all my buffers open in small splits, but I don't always have the space for this. I think the best way to list your open buffers is as a vertical tree within their folder structure.

The workflow would be to:

  1. show the full tree,
  2. open a few files,
  3. toggle back to "Open Buffers Only" mode
  4. as buffers are opened via Go to Definition, Find References, Telescope, etc, they are added to the "Open Buffers Only" view
  5. work...
  6. occasionally jump to nvim-tree sidebar to switch buffers
  7. toggle back to "All Files" mode to browse and open another file via folder navigation
  8. back to "Open Buffers Only" mode
  9. work...

I would be willing to code this and put in a PR. My questions are:

  1. Are you interested in having this as a feature?
  2. I gathered from other issues that there is a lot of refactoring going on right now, should I work off of a particular branch or wait for something else to be completed?
  3. Any advice on the best way to go about this? I was thinking about injecting an if clause to filter the tree just before it renders if a flag is set from the toggle function.
@khalidchawtany
Copy link

what you describe looks like https://github.com/el-iot/buffer-tree

@cseickel
Copy link
Author

That is certainly trying to solve the same problem, but it's way too basic for me and is not written as a sidebar or even a buffer that can be arranged. I'd like to implement that idea into a complete tree plugin like this so i can get auto update, styling, icons, etc.

Still, I'm going to try it out in the mean time...

@cseickel
Copy link
Author

This turned out to be pretty easy to add. I have a working solution in my fork: https://github.com/cseickel/nvim-tree.lua

I also fixed a bug with refreshing. As it was, a lot of refresh requests were just silently dropped causing glitchy behavior with all of the toggle functions.

I just need to add documentation and then I'll put in a pull request.

@alex-courtis alex-courtis added the PR please nvim-tree team does not have the bandwidth to implement; a PR will be gratefully appreciated label Apr 3, 2022
@alex-courtis
Copy link
Member

alex-courtis commented Apr 3, 2022

@cseickel any progress on your PR?

You might want to check the filter work in progress #1056 as it may do what you want.

@cseickel
Copy link
Author

cseickel commented Apr 3, 2022

Sorry @alex-courtis, I abandoned that PR and ended up creating my own tree plugin instead.

@alex-courtis
Copy link
Member

Closing as it is covered by #1056

@x0y-gt

This comment was marked as off-topic.

@gegoune

This comment was marked as off-topic.

@rofrol

This comment was marked as off-topic.

@resoliwan

This comment has been minimized.

@x0y-gt

This comment was marked as off-topic.

@gegoune

This comment was marked as off-topic.

@resoliwan
Copy link

resoliwan commented Mar 27, 2024

I used the git filter command, and while searching for the buffer filter, I came across this post. So, I understand that there is a way to achieve what I'm looking for. However, I'm not sure how to do it. Therefore, I'm trying to search for the implementation of git filter because it has similar features. While searching, I found out that there is a custom mode. Upon reading the help document, I discovered a pre-built no_buffer filter

*nvim-tree.filters.no_buffer*
Do not show files that have no |buflisted()| buffer.
Toggle via |nvim-tree-api.tree.toggle_no_buffer_filter()|, default `B`
For performance reasons this may not immediately update on buffer
delete/wipe. A reload or filesystem event will result in an update.
  Type: `boolean`, Default: `false`

@nvim-tree nvim-tree locked as off-topic and limited conversation to collaborators Mar 28, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
feature request PR please nvim-tree team does not have the bandwidth to implement; a PR will be gratefully appreciated
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants