Skip to content
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

feat: add options always_show_by_pattern #1444

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,9 @@ use {
always_show = { -- remains visible even if other settings would normally hide it
--".gitignored",
},
always_show_by_pattern = { -- uses glob style patterns
--".env*",
},
never_show = { -- remains hidden even if visible is toggled to true, this overrides always_show
--".DS_Store",
--"thumbs.db"
Expand Down
7 changes: 7 additions & 0 deletions doc/neo-tree.txt
Original file line number Diff line number Diff line change
Expand Up @@ -931,6 +931,9 @@ highlight group which will be applied when they are visible, see
always_show = { -- remains visible even if other settings would normally hide it
--".gitignored",
},
always_show_by_pattern = { -- uses glob style patterns
--".env*",
},
never_show = { -- remains hidden even if visible is toggled to true, this overrides always_show
--".DS_Store",
--"thumbs.db",
Expand Down Expand Up @@ -964,6 +967,10 @@ The `always_show` option is a list of file/folder names that will always be
visible, even if other settings would normally hide it. This section takes
precedence over all other options except for `never_show`.

the `always_show_by_pattern` option is a list of file/folder patterns that
always will be visible. This section takes precedence over all other options
except `never_show`.

The `never_show` option is the same as `hide_by_name`, except that those items
will remain hidden even if you toggle `visible` to true. This section takes
precedence over the others.
Expand Down
3 changes: 3 additions & 0 deletions lua/neo-tree/defaults.lua
Original file line number Diff line number Diff line change
Expand Up @@ -475,6 +475,9 @@ local config = {
always_show = { -- remains visible even if other settings would normally hide it
--".gitignored",
},
always_show_by_pattern = { -- uses glob style patterns
--".env*",
},
never_show = { -- remains hidden even if visible is toggled to true, this overrides always_show
--".DS_Store",
--"thumbs.db"
Expand Down
5 changes: 5 additions & 0 deletions lua/neo-tree/sources/common/file-items.lua
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,11 @@ function create_item(context, path, _type, bufnr)
if f.always_show[name] then
item.filtered_by = item.filtered_by or {}
item.filtered_by.always_show = true
else
if utils.is_filtered_by_pattern(f.always_show_by_pattern, path, name) then
item.filtered_by = item.filtered_by or {}
item.filtered_by.always_show = true
end
end
if f.hide_by_name[name] then
item.filtered_by = item.filtered_by or {}
Expand Down
2 changes: 1 addition & 1 deletion lua/neo-tree/sources/filesystem/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ M.setup = function(config, global_config)
config.filtered_items = config.filtered_items or {}
config.enable_git_status = global_config.enable_git_status

for _, key in ipairs({ "hide_by_pattern", "never_show_by_pattern" }) do
for _, key in ipairs({ "hide_by_pattern", "always_show_by_pattern", "never_show_by_pattern" }) do
local list = config.filtered_items[key]
if type(list) == "table" then
for i, pattern in ipairs(list) do
Expand Down