Skip to content

Optionally suppress the symlink destination #1396

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jul 5, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions doc/nvim-tree-lua.txt
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,7 @@ Subsequent calls to setup will replace the previous configuration.
},
},
special_files = { "Cargo.toml", "Makefile", "README.md", "readme.md" },
symlink_destination = true,
},
hijack_directories = {
enable = true,
Expand Down Expand Up @@ -725,6 +726,10 @@ UI rendering setup
A list of filenames that gets highlighted with `NvimTreeSpecialFile`.
Type: `table`, Default: `{ "Cargo.toml", "Makefile", "README.md", "readme.md", }`

*nvim-tree.renderer.symlink_destination*
Whether to show the destination of the symlink.
Type: `boolean`, Default: `true`

*nvim-tree.filters*
Filtering options.

Expand Down
1 change: 1 addition & 0 deletions lua/nvim-tree.lua
Original file line number Diff line number Diff line change
Expand Up @@ -491,6 +491,7 @@ local DEFAULT_OPTS = { -- BEGIN_DEFAULT_OPTS
},
},
special_files = { "Cargo.toml", "Makefile", "README.md", "readme.md" },
symlink_destination = true,
},
hijack_directories = {
enable = true,
Expand Down
10 changes: 9 additions & 1 deletion lua/nvim-tree/renderer/builder.lua
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,11 @@ function Builder:configure_git_icons_placement(where)
return self
end

function Builder:configure_symlink_destination(show)
self.symlink_destination = show
return self
end

function Builder:_insert_highlight(group, start, end_)
table.insert(self.highlights, { group, self.index, start, end_ or -1 })
end
Expand Down Expand Up @@ -153,7 +158,10 @@ function Builder:_build_symlink(node, padding, git_highlight, git_icons_tbl)

local icon = icons.i.symlink
local arrow = icons.i.symlink_arrow
local symlink_formatted = node.name .. arrow .. node.link_to
local symlink_formatted = node.name
if self.symlink_destination then
symlink_formatted = symlink_formatted .. arrow .. node.link_to
end

local link_highlight = git_highlight or "NvimTreeSymlink"

Expand Down
1 change: 1 addition & 0 deletions lua/nvim-tree/renderer/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ function M.draw()
:configure_opened_file_highlighting(M.config.highlight_opened_files)
:configure_git_icons_padding(M.config.icons.padding)
:configure_git_icons_placement(M.config.icons.git_placement)
:configure_symlink_destination(M.config.symlink_destination)
:configure_filter(live_filter.filter, live_filter.prefix)
:build_header(view.is_root_folder_visible(core.get_cwd()))
:build(core.get_explorer())
Expand Down