From 951e10a64e0b03069f0f50ddc79d6a8ed8d23dec Mon Sep 17 00:00:00 2001 From: ADoyle Date: Sun, 4 Sep 2022 10:23:56 +0800 Subject: [PATCH] fix(#1568): show relative path of symlink destination (#1569) --- lua/nvim-tree/renderer/builder.lua | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lua/nvim-tree/renderer/builder.lua b/lua/nvim-tree/renderer/builder.lua index f63be552..acb1d8ea 100644 --- a/lua/nvim-tree/renderer/builder.lua +++ b/lua/nvim-tree/renderer/builder.lua @@ -1,4 +1,5 @@ local utils = require "nvim-tree.utils" +local core = require "nvim-tree.core" local git = require "nvim-tree.renderer.components.git" local pad = require "nvim-tree.renderer.components.padding" @@ -114,7 +115,8 @@ function Builder:_build_folder(node, padding, git_hl, git_icons_tbl) local foldername = name .. self.trailing_slash if node.link_to and self.symlink_destination then local arrow = icons.i.symlink_arrow - foldername = foldername .. arrow .. node.link_to + local link_to = utils.path_relative(node.link_to, core.get_cwd()) + foldername = foldername .. arrow .. link_to end 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) local arrow = icons.i.symlink_arrow local symlink_formatted = node.name if self.symlink_destination then - symlink_formatted = symlink_formatted .. arrow .. node.link_to + local link_to = utils.path_relative(node.link_to, core.get_cwd()) + symlink_formatted = symlink_formatted .. arrow .. link_to end local link_highlight = git_highlight or "NvimTreeSymlink"