Fallback to default icon for symlinks and fix padding

Fixes https://github.com/kyazdani42/nvim-tree.lua/issues/80
This commit is contained in:
Santos Gallegos
2020-08-03 18:09:50 -05:00
committed by Kiyan Yazdani
parent 62846b1e31
commit 222732d9d4
4 changed files with 33 additions and 6 deletions

View File

@@ -4,6 +4,7 @@ function M.get_icon_state()
local show_icons = vim.g.lua_tree_show_icons or { git = 1, folders = 1, files = 1 }
local icons = {
default = "",
symlink = "",
git_icons = {
unstaged = "",
staged = "",
@@ -22,6 +23,10 @@ function M.get_icon_state()
if user_icons then
if user_icons.default then
icons.default = user_icons.default
icons.symlink = user_icons.default
end
if user_icons.symlink then
icons.symlink = user_icons.symlink
end
for key, val in pairs(user_icons.git or {}) do
if icons.git_icons[key] then

View File

@@ -49,6 +49,20 @@ if icon_state.show_file_icon then
end
local get_symlink_icon = function() return icon_state.icons.symlink end
if icon_state.show_file_icon then
get_symlink_icon = function()
return #icon_state.icons.symlink > 0 and icon_state.icons.symlink.." " or ""
end
end
local get_special_icon = function() return icon_state.icons.default end
if icon_state.show_file_icon then
get_special_icon = function()
return icon_state.icons.default.." "
end
end
local get_git_icons = function() return "" end
local get_git_hl = function() return end
@@ -210,17 +224,17 @@ local function update_draw_data(tree, depth, markers)
table.insert(lines, padding..icon..git_icon..node.name)
end
elseif node.link_to then
local icon = get_symlink_icon()
local link_hl = git_hl or 'LuaTreeSymlink'
table.insert(hl, { link_hl, index, offset, -1 })
table.insert(lines, padding..node.name..""..node.link_to)
table.insert(lines, padding..icon..node.name..""..node.link_to)
index = index + 1
else
local icon
local git_icons
if special[node.name] then
icon = icon_state.icons.default
if icon ~= "" then icon = icon.." " end
icon = get_special_icon()
git_icons = get_git_icons(node, index, offset, 0)
table.insert(hl, {'LuaTreeSpecialFile', index, offset+#git_icons, -1})
else