Skip to content

Commit 9acf8ac

Browse files
committed
feat: add always_show option to filtered_items config, closes #446
1 parent 312b5fd commit 9acf8ac

File tree

6 files changed

+40
-17
lines changed

6 files changed

+40
-17
lines changed

README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,10 @@ use {
248248
hide_by_pattern = { -- uses glob style patterns
249249
--"*.meta"
250250
},
251-
never_show = { -- remains hidden even if visible is toggled to true
251+
always_show = { -- remains visible even if other settings would normally hide it
252+
--".gitignored",
253+
},
254+
never_show = { -- remains hidden even if visible is toggled to true, this overrides always_show
252255
--".DS_Store",
253256
--"thumbs.db"
254257
},

doc/neo-tree.txt

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -645,27 +645,43 @@ highlight group which will be applied when they are visible, see
645645
hide_by_pattern = {
646646
--"*.meta",
647647
},
648-
never_show = { -- remains hidden even if visible is toggled to true
648+
always_show = { -- remains visible even if other settings would normally hide it
649+
--".gitignored",
650+
},
651+
never_show = { -- remains hidden even if visible is toggled to true, this overrides always_show
649652
--".DS_Store",
650653
--"thumbs.db",
651654
},
652655
},
653656
}
654657
})
655658
<
659+
656660
The `visible` option just defines the default value. This value is toggled by
657661
the "toggle_hidden" command, which is mapped to H by default.
658662

659-
The `never_show` option is the same as `hide_by_name`, except that those items
660-
will remain hidden even if you toggle `visible` to true. This section takes
661-
precedence over the others.
663+
The `hide_dotfiles` option just hides anything that starts with `. `(period).
662664

663-
The `hide_by_pattern` option uses glob syntax, which is converted to lua
664-
patterns. No gaurantees on how it handles advanced patterns.
665+
The `hide_gitignored` option will query git for the files and folders being
666+
shown, and hide those that are marked as ignored.
665667

666668
The `hide_hidden` option only will work on Windows using the Windows logic
667669
that determines if a file or directory is hidden.
668670

671+
The `hide_by_name` option is a list of file/folder names that should be
672+
hidden. This is an exact match.
673+
674+
The `hide_by_pattern` option uses glob syntax, which is converted to lua
675+
patterns. No gaurantees on how it handles advanced patterns.
676+
677+
The `always_show` option is a list of file/folder names that will always be
678+
visible, even if other settings would normally hide it. This section takes
679+
precedence over all other options except for `never_show`.
680+
681+
The `never_show` option is the same as `hide_by_name`, except that those items
682+
will remain hidden even if you toggle `visible` to true. This section takes
683+
precedence over the others.
684+
669685

670686
NETRW HIJACK BEHAVIOR *neo-tree-netrw-hijack*
671687

lua/neo-tree/defaults.lua

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,10 @@ local config = {
345345
hide_by_pattern = { -- uses glob style patterns
346346
--"*.meta"
347347
},
348-
never_show = { -- remains hidden even if visible is toggled to true
348+
always_show = { -- remains visible even if other settings would normally hide it
349+
--".gitignored",
350+
},
351+
never_show = { -- remains hidden even if visible is toggled to true, this overrides always_show
349352
--".DS_Store",
350353
--"thumbs.db"
351354
},

lua/neo-tree/sources/common/file-items.lua

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,10 @@ function create_item(context, path, _type)
113113
item.filtered_by = item.filtered_by or {}
114114
item.filtered_by.never_show = true
115115
end
116+
if f.always_show[name] then
117+
item.filtered_by = item.filtered_by or {}
118+
item.filtered_by.always_show = true
119+
end
116120
if f.hide_by_name[name] then
117121
item.filtered_by = item.filtered_by or {}
118122
item.filtered_by.name = true

lua/neo-tree/sources/filesystem/init.lua

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -257,11 +257,6 @@ M.setup = function(config, global_config)
257257
config.filtered_items = config.filtered_items or {}
258258
config.enable_git_status = global_config.enable_git_status
259259

260-
local hide_by_name = config.filtered_items.hide_by_name
261-
if hide_by_name then
262-
config.filtered_items.hide_by_name = utils.list_to_dict(hide_by_name)
263-
end
264-
265260
local hide_by_pattern = config.filtered_items.hide_by_pattern
266261
if hide_by_pattern then
267262
local glob = require("neo-tree.sources.filesystem.lib.globtopattern")
@@ -271,9 +266,11 @@ M.setup = function(config, global_config)
271266
end
272267
end
273268

274-
local never_show = config.filtered_items.never_show
275-
if never_show then
276-
config.filtered_items.never_show = utils.list_to_dict(never_show)
269+
for _, key in ipairs({ "hide_by_name", "always_show", "never_show" }) do
270+
local list = config.filtered_items[key]
271+
if type(list) == "table" then
272+
config.filtered_items[key] = utils.list_to_dict(list)
273+
end
277274
end
278275

279276
--Configure events for before_render

lua/neo-tree/ui/renderer.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ local remove_filtered = function(source_items, filtered_items)
140140
local fby = child.filtered_by
141141
if type(fby) == "table" and not child.is_reveal_target and not fby.show_anyway then
142142
if not fby.never_show then
143-
if filtered_items.visible or child.is_nested then
143+
if filtered_items.visible or child.is_nested or fby.always_show then
144144
table.insert(visible, child)
145145
else
146146
table.insert(hidden, child)

0 commit comments

Comments
 (0)