Add empty directory icons
This commit is contained in:
committed by
Kiyan
parent
7531c7023d
commit
25b414051f
@@ -16,6 +16,8 @@ function M.get_icon_state()
|
|||||||
folder_icons = {
|
folder_icons = {
|
||||||
default = "",
|
default = "",
|
||||||
open = "",
|
open = "",
|
||||||
|
empty = "",
|
||||||
|
empty_open = "",
|
||||||
symlink = "",
|
symlink = "",
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,6 +15,9 @@ local path_to_matching_str = require'lib.utils'.path_to_matching_str
|
|||||||
local function dir_new(cwd, name)
|
local function dir_new(cwd, name)
|
||||||
local absolute_path = cwd..'/'..name
|
local absolute_path = cwd..'/'..name
|
||||||
local stat = luv.fs_stat(absolute_path)
|
local stat = luv.fs_stat(absolute_path)
|
||||||
|
local handle = luv.fs_opendir(absolute_path, nil, 1)
|
||||||
|
local children = luv.fs_readdir(handle)
|
||||||
|
luv.fs_closedir(handle)
|
||||||
return {
|
return {
|
||||||
name = name,
|
name = name,
|
||||||
absolute_path = absolute_path,
|
absolute_path = absolute_path,
|
||||||
@@ -23,6 +26,7 @@ local function dir_new(cwd, name)
|
|||||||
match_name = path_to_matching_str(name),
|
match_name = path_to_matching_str(name),
|
||||||
match_path = path_to_matching_str(absolute_path),
|
match_path = path_to_matching_str(absolute_path),
|
||||||
open = false,
|
open = false,
|
||||||
|
empty = children == nil,
|
||||||
entries = {}
|
entries = {}
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -16,14 +16,22 @@ local set_folder_hl = function(line, depth, git_icon_len, _, hl_group)
|
|||||||
end
|
end
|
||||||
|
|
||||||
if icon_state.show_folder_icon then
|
if icon_state.show_folder_icon then
|
||||||
get_folder_icon = function(open, is_symlink)
|
get_folder_icon = function(open, is_symlink, is_empty)
|
||||||
local n = ""
|
local n = ""
|
||||||
if is_symlink then
|
if is_symlink then
|
||||||
n = icon_state.icons.folder_icons.symlink
|
n = icon_state.icons.folder_icons.symlink
|
||||||
elseif open then
|
elseif open then
|
||||||
n = icon_state.icons.folder_icons.open
|
if is_empty then
|
||||||
|
n = icon_state.icons.folder_icons.empty_open
|
||||||
|
else
|
||||||
|
n = icon_state.icons.folder_icons.open
|
||||||
|
end
|
||||||
else
|
else
|
||||||
n = icon_state.icons.folder_icons.default
|
if is_empty then
|
||||||
|
n = icon_state.icons.folder_icons.empty
|
||||||
|
else
|
||||||
|
n = icon_state.icons.folder_icons.default
|
||||||
|
end
|
||||||
end
|
end
|
||||||
return n.." "
|
return n.." "
|
||||||
end
|
end
|
||||||
@@ -230,7 +238,7 @@ local function update_draw_data(tree, depth, markers)
|
|||||||
local git_hl = get_git_hl(node)
|
local git_hl = get_git_hl(node)
|
||||||
|
|
||||||
if node.entries then
|
if node.entries then
|
||||||
local icon = get_folder_icon(node.open, node.link_to ~= nil)
|
local icon = get_folder_icon(node.open, node.link_to ~= nil, node.empty)
|
||||||
local git_icon = get_git_icons(node, index, offset, #icon+1) or ""
|
local git_icon = get_git_icons(node, index, offset, #icon+1) or ""
|
||||||
-- INFO: this is mandatory in order to keep gui attributes (bold/italics)
|
-- INFO: this is mandatory in order to keep gui attributes (bold/italics)
|
||||||
set_folder_hl(index, offset, #icon, #node.name+#git_icon, 'NvimTreeFolderName')
|
set_folder_hl(index, offset, #icon, #node.name+#git_icon, 'NvimTreeFolderName')
|
||||||
|
|||||||
Reference in New Issue
Block a user