Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork634
Description
When using the git_clean and no_buffer filters together, I think it would be more useful to show files that are either dirty or open in a buffer. The current behavior is to only show files that are both dirty and open in a buffer.
Can this functionality be implemented utilising API?
Not currently, the filter logic is not exposed in the public API.
Describe the solution you'd like
Exposing the various filter functions to the public api in a way that they could be composed in the custom filter would be my preferred solution. Something like this would be nice:
require('nvim-tree').setup({filters= {no_buffer=false,git_clean=false,custom=function (path)localfilter_api=require('nvim-tree.api.filter')-- return true only when *both* git_clean and no_buffer would filter the path. These-- functions should not check the enabled/disabled state of the function so that the-- custom filter can have precedence while still using their result.returnfilter_api.git_clean(path)andfilter_api.no_buffer(path)end }})
Describe alternatives you've considered
I've implemented the behavior I want in my config with a couple janky runtime patches tonvim-tree's internal filter API:
localfilters=require('nvim-tree.explorer.filters')localenum=require('nvim-tree.enum')localshould_filter=filters.should_filterlocalshould_filter_as_reason=filters.should_filter_as_reasonfilters.should_filter=function (self,path,fs_stat,status)ifself.state.no_bufferandnotself:buf(path,status.bufinfo)thenreturnfalseendifself.state.git_cleanandnotself:git(path,status.project)thenreturnfalseendreturnshould_filter(self,path,fs_stat,status)endfilters.should_filter_as_reason=function (self,path,fs_stat,status)ifnotshould_filter(self,path,fs_stat,status)thenreturnenum.FILTER_REASON.noneendreturnshould_filter_as_reason(self,path,fs_stat,status)end
Additional context
