nvim-tree / nvim-tree/nvim-tree.lua

Persist the "filter options" over the session lifecycle

Open
#3,186 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

feature request PR please QOL
Dominant language
Lua
Stars
8.6k
Forks
639
Avg merge
1d 14h
Merged PRs (30d)
2

Description

hey nvim-tree builders,

I would like to raise a small feature request to you, which may increase the nvim-tree UX a bit, just for your reference. Thanks a lot for building this useful tool.

Is this a question?
No

Can this functionality be implemented utilising API?
I'm not very sure about this, but with a preliminary search in the API, I didn't find a very straight-forward way to implement it.

Is your feature request related to a problem? Please describe.

I set the nvim-tree to update root dir following the buffer switch, I often switch back and forth between two git projects which have different root ofc. The default setting recognizes .gitignore, so, in a project, if I need to inspect some git ignored files, I have to turn off the ignore filter by I key, navigate to the ignored directory and open the target file. But quickly, I ran into two problems:

  • When I switch to another file in a different root dir, then switch back later, I expected the tree view is exactly the same as I left it, i.e. a view showing all ignore dirs/files are still there and focus follows my opened file, it means my previous filter toggle is still functioning. However, they are all gone, i have to toggle ignore filter again to show those ignored files.
  • After I toggle ignore filter again, the tree-view didn't refresh to follow the opened file automatically, I have to navigate to the deep dir which contains that file...
      update_focused_file = {
        enable = true,
        update_root = {
          enable = true,
          ignore_list = {},
        },
        exclude = false,
      },

Describe the solution you'd like

  • The filter options can persist across root dir switchs, and be a session level setting.
  • Once set, it can apply on all the root dirs you switch to.
  • The tree focus can follow the files on the ignore list, only if you turn off the ignore filter for current session.
  • The setting doesn't change the default settings, in a new vim session, all the filter option changes are gone.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing the I key filter toggle and the update_focused_file.update_root lifecycle described in the issue. Check how filter state and focus are handled when switching roots, then verify that the state persists only within a session and that focus follows ignored files when the filter is disabled.

Written by the indexing model from the issue text.

Assessment

Tech stack
lua
Domain
tooling
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.