Add ability to use Dataview expressions in custom rules #353
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Goal
I wanted the ability to define file icons based on dynamic rules, for example:
Related Issues
Proposed Solution
I thought we could leverage Dataview expressions to create concise, powerful rules. And since Dataview functions can do various string operations, including regex matching, these new rules would be a superset of the current string/regex-powered rules.
Match a plain string
Match a regular expression
Match if the file has tasks and they are all complete
Match if a file property is present and has a non-null value
Match if a file is tagged
And much more!
This should work with any Dataview expression so the custom rules can take into account any metadata provided by Dataview like outlinks, inlinks, aliases, bookmark status…
PR Status
This is a draft because I haven't fully wrapped my mind around how icons are refreshed. There seem to be a lot of events and conditions that factor in so I'm hoping to get some help from more knowledgeable contributors if this idea gets traction. With that said, this appears mostly functional, at least for the file explorer. I left some questions in the code diff.
TODO
Testing