allow opening symlink to folders
This commit is contained in:
@@ -89,7 +89,8 @@ let g:lua_tree_icons = {
|
|||||||
\ },
|
\ },
|
||||||
\ 'folder': {
|
\ 'folder': {
|
||||||
\ 'default': "",
|
\ 'default': "",
|
||||||
\ 'open': ""
|
\ 'open': "",
|
||||||
|
\ 'symlink': "",
|
||||||
\ }
|
\ }
|
||||||
\ }
|
\ }
|
||||||
|
|
||||||
|
|||||||
@@ -106,7 +106,8 @@ You can set icons for:
|
|||||||
\ },
|
\ },
|
||||||
\ 'folder': {
|
\ 'folder': {
|
||||||
\ 'default': "",
|
\ 'default': "",
|
||||||
\ 'open': ""
|
\ 'open': "",
|
||||||
|
\ 'symlink': "",
|
||||||
\ }
|
\ }
|
||||||
\ }
|
\ }
|
||||||
|
|
||||||
|
|||||||
@@ -15,7 +15,8 @@ function M.get_icon_state()
|
|||||||
},
|
},
|
||||||
folder_icons = {
|
folder_icons = {
|
||||||
default = "",
|
default = "",
|
||||||
open = ""
|
open = "",
|
||||||
|
symlink = "",
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -93,7 +93,7 @@ function M.unroll_dir(node)
|
|||||||
if #node.entries > 0 then
|
if #node.entries > 0 then
|
||||||
renderer.draw(M.Tree, true)
|
renderer.draw(M.Tree, true)
|
||||||
else
|
else
|
||||||
populate(node.entries, node.absolute_path)
|
populate(node.entries, node.link_to or node.absolute_path)
|
||||||
renderer.draw(M.Tree, true)
|
renderer.draw(M.Tree, true)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -48,10 +48,17 @@ end
|
|||||||
local function link_new(cwd, name)
|
local function link_new(cwd, name)
|
||||||
local absolute_path = cwd..'/'..name
|
local absolute_path = cwd..'/'..name
|
||||||
local link_to = luv.fs_realpath(absolute_path)
|
local link_to = luv.fs_realpath(absolute_path)
|
||||||
|
local open, entries
|
||||||
|
if luv.fs_stat(link_to).type == 'directory' then
|
||||||
|
open = false
|
||||||
|
entries = {}
|
||||||
|
end
|
||||||
return {
|
return {
|
||||||
name = name,
|
name = name,
|
||||||
absolute_path = absolute_path,
|
absolute_path = absolute_path,
|
||||||
link_to = link_to,
|
link_to = link_to,
|
||||||
|
open = open,
|
||||||
|
entries = entries,
|
||||||
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),
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,12 +16,16 @@ 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)
|
get_folder_icon = function(open, is_symlink)
|
||||||
if open then
|
local n = ""
|
||||||
return icon_state.icons.folder_icons.open .. " "
|
if is_symlink then
|
||||||
|
n = icon_state.icons.folder_icons.symlink
|
||||||
|
elseif open then
|
||||||
|
n = icon_state.icons.folder_icons.open
|
||||||
else
|
else
|
||||||
return icon_state.icons.folder_icons.default .. " "
|
n = icon_state.icons.folder_icons.default
|
||||||
end
|
end
|
||||||
|
return n.." "
|
||||||
end
|
end
|
||||||
set_folder_hl = function(line, depth, icon_len, name_len, hl_group)
|
set_folder_hl = function(line, depth, icon_len, name_len, hl_group)
|
||||||
table.insert(hl, {hl_group, line, depth+icon_len, depth+icon_len+name_len})
|
table.insert(hl, {hl_group, line, depth+icon_len, depth+icon_len+name_len})
|
||||||
@@ -225,7 +229,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)
|
local icon = get_folder_icon(node.open, node.link_to ~= nil)
|
||||||
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, 'LuaTreeFolderName')
|
set_folder_hl(index, offset, #icon, #node.name+#git_icon, 'LuaTreeFolderName')
|
||||||
|
|||||||
@@ -95,10 +95,8 @@ function M.on_keypress(mode)
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
if node.link_to then
|
if node.link_to and not node.entries then
|
||||||
local stat = luv.fs_stat(node.link_to)
|
local stat = luv.fs_stat(node.link_to)
|
||||||
-- TODO: potentially CD here
|
|
||||||
if stat.type == 'directory' then return end
|
|
||||||
lib.open_file(mode, node.link_to)
|
lib.open_file(mode, node.link_to)
|
||||||
elseif node.entries ~= nil then
|
elseif node.entries ~= nil then
|
||||||
lib.unroll_dir(node)
|
lib.unroll_dir(node)
|
||||||
|
|||||||
Reference in New Issue
Block a user