Skip to content

Commit 951e10a

Browse files
authored
fix(#1568): show relative path of symlink destination (#1569)
1 parent d753a1d commit 951e10a

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

lua/nvim-tree/renderer/builder.lua

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
local utils = require "nvim-tree.utils"
2+
local core = require "nvim-tree.core"
23

34
local git = require "nvim-tree.renderer.components.git"
45
local pad = require "nvim-tree.renderer.components.padding"
@@ -114,7 +115,8 @@ function Builder:_build_folder(node, padding, git_hl, git_icons_tbl)
114115
local foldername = name .. self.trailing_slash
115116
if node.link_to and self.symlink_destination then
116117
local arrow = icons.i.symlink_arrow
117-
foldername = foldername .. arrow .. node.link_to
118+
local link_to = utils.path_relative(node.link_to, core.get_cwd())
119+
foldername = foldername .. arrow .. link_to
118120
end
119121

120122
local git_icons = self:_unwrap_git_data(git_icons_tbl, offset + #icon + (self.is_git_after and #foldername + 1 or 0))
@@ -160,7 +162,8 @@ function Builder:_build_symlink(node, padding, git_highlight, git_icons_tbl)
160162
local arrow = icons.i.symlink_arrow
161163
local symlink_formatted = node.name
162164
if self.symlink_destination then
163-
symlink_formatted = symlink_formatted .. arrow .. node.link_to
165+
local link_to = utils.path_relative(node.link_to, core.get_cwd())
166+
symlink_formatted = symlink_formatted .. arrow .. link_to
164167
end
165168

166169
local link_highlight = git_highlight or "NvimTreeSymlink"

0 commit comments

Comments
 (0)