Skip to content

Commit 59571f6

Browse files
committed
feat(hidden_dotfile_highlight): make a file that has a dotfile parent be also a dotfile
1 parent fd0d2de commit 59571f6

File tree

3 files changed

+18
-4
lines changed

3 files changed

+18
-4
lines changed

lua/nvim-tree/explorer/node.lua

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,20 @@ function M.is_git_ignored(node)
128128
return node and node.git_status ~= nil and node.git_status.file == "!!"
129129
end
130130

131+
---@param node Node
132+
---@return boolean
133+
function M.is_dotfile(node)
134+
if node == nil then
135+
return false
136+
end
137+
-- Inspect(node)
138+
if node.is_dot or (node.name and (node.name:sub(1, 1) == ".")) or M.is_dotfile(node.parent) then
139+
node.is_dot = true
140+
return true
141+
end
142+
return false
143+
end
144+
131145
---@param node Node
132146
function M.node_destroy(node)
133147
if not node then

lua/nvim-tree/node.lua

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
---@field fs_stat uv.fs_stat.result|nil
1010
---@field git_status GitStatus|nil
1111
---@field hidden boolean
12+
---@field is_dot boolean
1213
---@field name string
1314
---@field parent DirNode
1415
---@field type string

lua/nvim-tree/renderer/decorator/hidden.lua

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
local buffers = require "nvim-tree.buffers"
2-
1+
local is_dotfile = require("nvim-tree.explorer.node").is_dotfile
32
local HL_POSITION = require("nvim-tree.enum").HL_POSITION
43
local ICON_PLACEMENT = require("nvim-tree.enum").ICON_PLACEMENT
54

@@ -38,7 +37,7 @@ end
3837
---@param node Node
3938
---@return HighlightedString[]|nil icons
4039
function DecoratorHidden:calculate_icons(node)
41-
if self.enabled and (node.name:sub(1, 1) == ".") then
40+
if self.enabled and is_dotfile(node) then
4241
return { self.icon }
4342
end
4443
end
@@ -47,7 +46,7 @@ end
4746
---@param node Node
4847
---@return string|nil group
4948
function DecoratorHidden:calculate_highlight(node)
50-
if not self.enabled or self.hl_pos == HL_POSITION.none or not (node.name:sub(1, 1) == ".") then
49+
if not self.enabled or self.hl_pos == HL_POSITION.none or not (is_dotfile(node)) then
5150
return nil
5251
end
5352

0 commit comments

Comments
 (0)