Skip to content

Commit c41c752

Browse files
committed
feat(hidden_display): Allow fine grained rendering of hidden files in
a folder
1 parent cb56c0d commit c41c752

File tree

5 files changed

+33
-0
lines changed

5 files changed

+33
-0
lines changed

doc/nvim-tree-lua.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1004,6 +1004,12 @@ Icon order and sign column precedence:
10041004
Hidden icon placement.
10051005
Type: `string`, Default: `"after"`
10061006

1007+
*nvim-tree.renderer.icons.hidden_placement*
1008+
Place where the hidden (dotfile) icon will be rendered.
1009+
Can be `"after"` or `"before"` filename (after the file/folders icons)
1010+
or `"signcolumn"` (requires |nvim-tree.view.signcolumn| enabled).
1011+
Type: `string`, Default: `"after"`
1012+
10071013
*nvim-tree.renderer.icons.bookmarks_placement*
10081014
Bookmark icon placement.
10091015
Type: `string`, Default: `signcolumn`

lua/nvim-tree/appearance/init.lua

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ M.HIGHLIGHT_GROUPS = {
1414
-- Standard
1515
{ group = "NvimTreeNormal", link = "Normal" },
1616
{ group = "NvimTreeNormalFloat", link = "NormalFloat" },
17+
{ group = "NvimTreeNormalFloatBorder", link = "FloatBorder" },
1718
{ group = "NvimTreeNormalNC", link = "NvimTreeNormal" },
1819

1920
{ group = "NvimTreeLineNr", link = "LineNr" },

lua/nvim-tree/explorer/explore.lua

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,11 @@ local M = {}
1515
---@param cwd string
1616
---@param node Node
1717
---@param git_status table
18+
---@return integer filtered_count
1819
local function populate_children(handle, cwd, node, git_status)
1920
local node_ignored = explorer_node.is_git_ignored(node)
2021
local nodes_by_path = utils.bool_record(node.nodes, "absolute_path")
22+
2123
local filter_status = filters.prepare(git_status)
2224
while true do
2325
local name, t = vim.loop.fs_scandir_next(handle)
@@ -68,6 +70,13 @@ function M.explore(node, status)
6870

6971
populate_children(handle, cwd, node, status)
7072

73+
local child_hidden_count = 0
74+
for _, child_node in ipairs(node.nodes) do
75+
if child_node then
76+
child_hidden_count = child_hidden_count + 1
77+
end
78+
end
79+
7180
local is_root = not node.parent
7281
local child_folder_only = explorer_node.has_one_child_folder(node) and node.nodes[1]
7382
if M.config.group_empty and not is_root and child_folder_only then
@@ -84,6 +93,21 @@ function M.explore(node, status)
8493
sorters.sort(node.nodes)
8594
live_filter.apply_filter(node)
8695

96+
if true or child_hidden_count ~= 0 then
97+
table.insert(node.nodes, {
98+
absolute_path = "",
99+
git_status = {},
100+
101+
has_children = false,
102+
name = "(" .. tostring(child_hidden_count) .. " hidden items)",
103+
nodes = {},
104+
open = false,
105+
106+
parent = node,
107+
type = "file",
108+
})
109+
end
110+
87111
log.profile_end(profile)
88112
return node.nodes
89113
end

lua/nvim-tree/renderer/builder.lua

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -381,6 +381,7 @@ function Builder:build_lines(node)
381381
end
382382
local num_children = self:get_nodes_number(node.nodes)
383383
local idx = 1
384+
-- table.insert(node.nodes, { name = "cock", path = "cock" })
384385
for _, n in ipairs(node.nodes) do
385386
if not n.hidden then
386387
self:build_signs(n)

lua/nvim-tree/view.lua

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ M.View = {
5050
"Normal:NvimTreeNormal",
5151
"NormalNC:NvimTreeNormalNC",
5252
"NormalFloat:NvimTreeNormalFloat",
53+
"FloatBorder:NvimTreeNormalFloatBorder",
5354
}, ","),
5455
},
5556
}

0 commit comments

Comments
 (0)