From 9650c0ed9d5b8b38c866b1d3d1ef8757e601ca3b Mon Sep 17 00:00:00 2001 From: "Cooper b. Anderson" Date: Thu, 18 Feb 2021 21:01:33 -0500 Subject: [PATCH] Add empty directory highlight group --- lua/lib/lib.lua | 2 +- lua/lib/populate.lua | 2 +- lua/lib/renderer.lua | 7 +++++-- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/lua/lib/lib.lua b/lua/lib/lib.lua index a07613ab..1dbd5e09 100644 --- a/lua/lib/lib.lua +++ b/lua/lib/lib.lua @@ -92,7 +92,7 @@ end function M.unroll_dir(node) node.open = not node.open - if node.children_initial then node.children_initial = false end + if node.has_children then node.has_children = false end if #node.entries > 0 then renderer.draw(M.Tree, true) else diff --git a/lua/lib/populate.lua b/lua/lib/populate.lua index d62b8c55..440d4f14 100644 --- a/lua/lib/populate.lua +++ b/lua/lib/populate.lua @@ -25,7 +25,7 @@ local function dir_new(cwd, name) match_name = path_to_matching_str(name), match_path = path_to_matching_str(absolute_path), open = false, - children_initial = has_children, + has_children = has_children, entries = {} } end diff --git a/lua/lib/renderer.lua b/lua/lib/renderer.lua index d790d746..29c95e3d 100644 --- a/lua/lib/renderer.lua +++ b/lua/lib/renderer.lua @@ -238,10 +238,13 @@ local function update_draw_data(tree, depth, markers) local git_hl = get_git_hl(node) if node.entries then - local icon = get_folder_icon(node.open, node.link_to ~= nil, #node.entries ~= 0 or node.children_initial) + local has_children = #node.entries ~= 0 or node.has_children + local icon = get_folder_icon(node.open, node.link_to ~= nil, has_children) local git_icon = get_git_icons(node, index, offset, #icon+1) or "" -- INFO: this is mandatory in order to keep gui attributes (bold/italics) - set_folder_hl(index, offset, #icon, #node.name+#git_icon, 'NvimTreeFolderName') + local folder_hl = "NvimTreeFolderName" + if not has_children then folder_hl = "NvimTreeEmptyFolderName" end + set_folder_hl(index, offset, #icon, #node.name+#git_icon, folder_hl) if git_hl then set_folder_hl(index, offset, #icon, #node.name+#git_icon, git_hl) end