Skip to content

Commit d599e1d

Browse files
committed
Prototype link showing and adding symlink option
1 parent 4bd5657 commit d599e1d

4 files changed

Lines changed: 17 additions & 1 deletion

File tree

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ require("telescope").setup {
107107
hidden = { file_browser = false, folder_browser = false },
108108
respect_gitignore = vim.fn.executable "fd" == 1
109109
no_ignore = false,
110+
show_symlinks = false,
110111
follow_symlinks = false,
111112
browse_files = require("telescope._extensions.file_browser.finders").browse_files,
112113
browse_folders = require("telescope._extensions.file_browser.finders").browse_folders,

lua/telescope/_extensions/file_browser/finders.lua

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,10 @@ local function fd_file_args(opts)
6565
if opts.no_ignore then
6666
table.insert(args, "--no-ignore")
6767
end
68-
if opts.follow_symlinks then
68+
if opts.show_symlinks then
69+
table.insert(args, "--type")
70+
table.insert(args, "symlink")
71+
elseif opts.follow_symlinks then
6972
table.insert(args, "--follow")
7073
end
7174
return args
@@ -174,6 +177,7 @@ end
174177
---@field hidden table|boolean: determines whether to show hidden files or not (default: `{ file_browser = false, folder_browser = false }`)
175178
---@field respect_gitignore boolean: induces slow-down w/ plenary finder (default: false, true if `fd` available)
176179
---@field no_ignore boolean: disable use of ignore files like .gitignore/.ignore/.fdignore (default: false, requires `fd`)
180+
---@field show_symlinks boolean: show symbolic links, i.e. files and folders (default: false)
177181
---@field follow_symlinks boolean: traverse symbolic links, i.e. files and folders (default: false, only works with `fd`)
178182
---@field hide_parent_dir boolean: hide `../` in the file browser (default: false)
179183
---@field dir_icon string: change the icon for a directory (default: )
@@ -204,6 +208,7 @@ fb_finders.finder = function(opts)
204208
auto_depth = vim.F.if_nil(opts.auto_depth, false), -- depth for file browser
205209
respect_gitignore = vim.F.if_nil(opts.respect_gitignore, has_fd),
206210
no_ignore = vim.F.if_nil(opts.no_ignore, false),
211+
show_symlinks = vim.F.if_nil(opts.show_symlinks, false),
207212
follow_symlinks = vim.F.if_nil(opts.follow_symlinks, false),
208213
files = vim.F.if_nil(opts.files, true), -- file or folders mode
209214
grouped = vim.F.if_nil(opts.grouped, false),

lua/telescope/_extensions/file_browser/make_entry.lua

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,10 @@ local make_entry = function(opts)
159159
end
160160
end
161161

162+
if entry.lstat.type == "link" then
163+
path_display = string.format("%s -> %s", path_display, utils.transform_path(opts, entry.realpath))
164+
end
165+
162166
local file_width = vim.F.if_nil(opts.file_width, math.max(15, total_file_width))
163167
-- TODO maybe this can be dealt with more cleanly
164168
if #path_display > file_width then
@@ -242,6 +246,11 @@ local make_entry = function(opts)
242246
return t.lstat
243247
end
244248

249+
if k == "realpath" then
250+
t.realpath = vim.F.if_nil(vim.loop.fs_realpath(t.value))
251+
return t.realpath
252+
end
253+
245254
return rawget(t, rawget({ value = 1 }, k))
246255
end
247256

lua/telescope/_extensions/file_browser/picker.lua

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ local fb_picker = {}
6767
---@field hidden table|boolean: determines whether to show hidden files or not (default: `{ file_browser = false, folder_browser = false }`)
6868
---@field respect_gitignore boolean: induces slow-down w/ plenary finder (default: false, true if `fd` available)
6969
---@field no_ignore boolean: disable use of ignore files like .gitignore/.ignore/.fdignore (default: false, requires `fd`)
70+
---@field show_symlinks boolean: show symbolic links, i.e. files and folders (default: false)
7071
---@field follow_symlinks boolean: traverse symbolic links, i.e. files and folders (default: false, only works with `fd`)
7172
---@field browse_files function: custom override for the file browser (default: |fb_finders.browse_files|)
7273
---@field browse_folders function: custom override for the folder browser (default: |fb_finders.browse_folders|)

0 commit comments

Comments
 (0)