Skip to content

Commit 38fabe8

Browse files
authored
Optionally suppress the symlink destination (#1396)
1 parent f43b8af commit 38fabe8

File tree

4 files changed

+16
-1
lines changed

4 files changed

+16
-1
lines changed

doc/nvim-tree-lua.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,7 @@ Subsequent calls to setup will replace the previous configuration.
238238
},
239239
},
240240
special_files = { "Cargo.toml", "Makefile", "README.md", "readme.md" },
241+
symlink_destination = true,
241242
},
242243
hijack_directories = {
243244
enable = true,
@@ -725,6 +726,10 @@ UI rendering setup
725726
A list of filenames that gets highlighted with `NvimTreeSpecialFile`.
726727
Type: `table`, Default: `{ "Cargo.toml", "Makefile", "README.md", "readme.md", }`
727728

729+
*nvim-tree.renderer.symlink_destination*
730+
Whether to show the destination of the symlink.
731+
Type: `boolean`, Default: `true`
732+
728733
*nvim-tree.filters*
729734
Filtering options.
730735

lua/nvim-tree.lua

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -491,6 +491,7 @@ local DEFAULT_OPTS = { -- BEGIN_DEFAULT_OPTS
491491
},
492492
},
493493
special_files = { "Cargo.toml", "Makefile", "README.md", "readme.md" },
494+
symlink_destination = true,
494495
},
495496
hijack_directories = {
496497
enable = true,

lua/nvim-tree/renderer/builder.lua

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,11 @@ function Builder:configure_git_icons_placement(where)
7070
return self
7171
end
7272

73+
function Builder:configure_symlink_destination(show)
74+
self.symlink_destination = show
75+
return self
76+
end
77+
7378
function Builder:_insert_highlight(group, start, end_)
7479
table.insert(self.highlights, { group, self.index, start, end_ or -1 })
7580
end
@@ -153,7 +158,10 @@ function Builder:_build_symlink(node, padding, git_highlight, git_icons_tbl)
153158

154159
local icon = icons.i.symlink
155160
local arrow = icons.i.symlink_arrow
156-
local symlink_formatted = node.name .. arrow .. node.link_to
161+
local symlink_formatted = node.name
162+
if self.symlink_destination then
163+
symlink_formatted = symlink_formatted .. arrow .. node.link_to
164+
end
157165

158166
local link_highlight = git_highlight or "NvimTreeSymlink"
159167

lua/nvim-tree/renderer/init.lua

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ function M.draw()
7676
:configure_opened_file_highlighting(M.config.highlight_opened_files)
7777
:configure_git_icons_padding(M.config.icons.padding)
7878
:configure_git_icons_placement(M.config.icons.git_placement)
79+
:configure_symlink_destination(M.config.symlink_destination)
7980
:configure_filter(live_filter.filter, live_filter.prefix)
8081
:build_header(view.is_root_folder_visible(core.get_cwd()))
8182
:build(core.get_explorer())

0 commit comments

Comments
 (0)