Skip to content

feat(#3119): Expose filter functions to the api #3121

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

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

gracepetryk
Copy link

@gracepetryk gracepetryk commented May 6, 2025

Addresses #3119. Filter methods have all been normalized to accept a single path variable so that they may be easily called during a call to custom. Results are cached based on the path argument during each render loop to avoid computing filters more than once if the filter is enabled and also called in custom.

This enables filter configurations that were not possible before, for example combining filters so that items are only filtered if they match both:

require('nvim-tree').setup({
  filters = {
    custom = function (path)
      local filter_api = require('nvim-tree.api').filters

      return filter_api.git_clean(path) and filter_api.no_buffer(path)
    end
  }
})

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant