allow opening symlink to folders
This commit is contained in:
parent
033b465f34
commit
0862bcc08e
@ -89,7 +89,8 @@ let g:lua_tree_icons = {
|
||||
\ },
|
||||
\ 'folder': {
|
||||
\ 'default': "",
|
||||
\ 'open': ""
|
||||
\ 'open': "",
|
||||
\ 'symlink': "",
|
||||
\ }
|
||||
\ }
|
||||
|
||||
|
||||
@ -106,7 +106,8 @@ You can set icons for:
|
||||
\ },
|
||||
\ 'folder': {
|
||||
\ 'default': "",
|
||||
\ 'open': ""
|
||||
\ 'open': "",
|
||||
\ 'symlink': "",
|
||||
\ }
|
||||
\ }
|
||||
|
||||
|
||||
@ -15,7 +15,8 @@ function M.get_icon_state()
|
||||
},
|
||||
folder_icons = {
|
||||
default = "",
|
||||
open = ""
|
||||
open = "",
|
||||
symlink = "",
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -93,7 +93,7 @@ function M.unroll_dir(node)
|
||||
if #node.entries > 0 then
|
||||
renderer.draw(M.Tree, true)
|
||||
else
|
||||
populate(node.entries, node.absolute_path)
|
||||
populate(node.entries, node.link_to or node.absolute_path)
|
||||
renderer.draw(M.Tree, true)
|
||||
end
|
||||
end
|
||||
|
||||
@ -48,10 +48,17 @@ end
|
||||
local function link_new(cwd, name)
|
||||
local absolute_path = cwd..'/'..name
|
||||
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 {
|
||||
name = name,
|
||||
absolute_path = absolute_path,
|
||||
link_to = link_to,
|
||||
open = open,
|
||||
entries = entries,
|
||||
match_name = path_to_matching_str(name),
|
||||
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
|
||||
|
||||
if icon_state.show_folder_icon then
|
||||
get_folder_icon = function(open)
|
||||
if open then
|
||||
return icon_state.icons.folder_icons.open .. " "
|
||||
get_folder_icon = function(open, is_symlink)
|
||||
local n = ""
|
||||
if is_symlink then
|
||||
n = icon_state.icons.folder_icons.symlink
|
||||
elseif open then
|
||||
n = icon_state.icons.folder_icons.open
|
||||
else
|
||||
return icon_state.icons.folder_icons.default .. " "
|
||||
n = icon_state.icons.folder_icons.default
|
||||
end
|
||||
return n.." "
|
||||
end
|
||||
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})
|
||||
@ -225,7 +229,7 @@ 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)
|
||||
local icon = get_folder_icon(node.open, node.link_to ~= nil)
|
||||
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, 'LuaTreeFolderName')
|
||||
|
||||
@ -95,10 +95,8 @@ function M.on_keypress(mode)
|
||||
return
|
||||
end
|
||||
|
||||
if node.link_to then
|
||||
if node.link_to and not node.entries then
|
||||
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)
|
||||
elseif node.entries ~= nil then
|
||||
lib.unroll_dir(node)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user