-
-
Notifications
You must be signed in to change notification settings - Fork 619
feat(#2654): filters.custom may be a function #2655
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
Merged
Merged
Changes from all commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
b754082
feat(#2654): add `binaries` field to `filters`
dxrcy e942899
feat(#2648): allow functions in `filters.custom`
dxrcy be1e6e4
Merge branch 'nvim-tree:master' into master
dxrcy d65092d
ci: fix: stylua check
dxrcy 0e46599
ci: fix: add new keybind and config to docs
dxrcy 1304c03
fix: replace os-specific binary filter with `vim.fn.executable`
dxrcy 89653f3
fix: remove function and mapping for `binaries` filter
dxrcy 7978157
fix: add `node` parameter to custom filter function
dxrcy 7339881
fix: update doc for custom filter function signature
dxrcy 0e880dc
fix: add custom filter to `ACCEPTED_TYPES`
dxrcy 2e4a1d1
fix: accept single function for custom filter
dxrcy 5e416f3
fix: change custom filter on `ACCEPTED_TYPES`
dxrcy b447d69
fix: revert to using `path` for custom filter function
dxrcy 38ded48
fix: use `function` type for custom filter
dxrcy 8363ac5
fix: type for custom filter in help
dxrcy c4b4aae
fix: custom filter single function no longer mutates `M.config.filter…
dxrcy 1e054f3
Merge branch 'nvim-tree:master' into master
dxrcy 340c581
fix: remove dead `if` statement in custom filter
dxrcy 8385e89
Merge branch 'nvim-tree:master' into master
dxrcy e771143
fix: separate custom filter function from `M.ignore_list`
dxrcy c3336b5
doc nit
alex-courtis File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,7 @@ local marks = require "nvim-tree.marks" | |
local M = { | ||
ignore_list = {}, | ||
exclude_list = {}, | ||
custom_function = nil, | ||
} | ||
|
||
---@param path string | ||
|
@@ -84,6 +85,11 @@ local function custom(path) | |
|
||
local basename = utils.path_basename(path) | ||
|
||
-- filter user's custom function | ||
if M.custom_function and M.custom_function(path) then | ||
return true | ||
end | ||
|
||
-- filter custom regexes | ||
local relpath = utils.path_relative(path, vim.loop.cwd()) | ||
for pat, _ in pairs(M.ignore_list) do | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. With some hacking
I was able to pass the custom function through, however it's never executed as I reckon you'll need to directly call the custom function outside of this loop. |
||
|
@@ -153,9 +159,13 @@ function M.setup(opts) | |
M.exclude_list = opts.filters.exclude | ||
|
||
local custom_filter = opts.filters.custom | ||
if custom_filter and #custom_filter > 0 then | ||
for _, filter_name in pairs(custom_filter) do | ||
M.ignore_list[filter_name] = true | ||
if type(custom_filter) == "function" then | ||
M.custom_function = custom_filter | ||
else | ||
if custom_filter and #custom_filter > 0 then | ||
for _, filter_name in pairs(custom_filter) do | ||
M.ignore_list[filter_name] = true | ||
end | ||
end | ||
end | ||
end | ||
|
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you, looking good!