Skip to content

Commit

Permalink
Prototype link showing and adding symlink option
Browse files Browse the repository at this point in the history
  • Loading branch information
aadi58002 committed Jan 9, 2024
1 parent 4bd5657 commit d599e1d
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ require("telescope").setup {
hidden = { file_browser = false, folder_browser = false },
respect_gitignore = vim.fn.executable "fd" == 1
no_ignore = false,
show_symlinks = false,
follow_symlinks = false,
browse_files = require("telescope._extensions.file_browser.finders").browse_files,
browse_folders = require("telescope._extensions.file_browser.finders").browse_folders,
Expand Down
7 changes: 6 additions & 1 deletion lua/telescope/_extensions/file_browser/finders.lua
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,10 @@ local function fd_file_args(opts)
if opts.no_ignore then
table.insert(args, "--no-ignore")
end
if opts.follow_symlinks then
if opts.show_symlinks then
table.insert(args, "--type")
table.insert(args, "symlink")
elseif opts.follow_symlinks then
table.insert(args, "--follow")
end
return args
Expand Down Expand Up @@ -174,6 +177,7 @@ end
---@field hidden table|boolean: determines whether to show hidden files or not (default: `{ file_browser = false, folder_browser = false }`)
---@field respect_gitignore boolean: induces slow-down w/ plenary finder (default: false, true if `fd` available)
---@field no_ignore boolean: disable use of ignore files like .gitignore/.ignore/.fdignore (default: false, requires `fd`)
---@field show_symlinks boolean: show symbolic links, i.e. files and folders (default: false)
---@field follow_symlinks boolean: traverse symbolic links, i.e. files and folders (default: false, only works with `fd`)
---@field hide_parent_dir boolean: hide `../` in the file browser (default: false)
---@field dir_icon string: change the icon for a directory (default: )
Expand Down Expand Up @@ -204,6 +208,7 @@ fb_finders.finder = function(opts)
auto_depth = vim.F.if_nil(opts.auto_depth, false), -- depth for file browser
respect_gitignore = vim.F.if_nil(opts.respect_gitignore, has_fd),
no_ignore = vim.F.if_nil(opts.no_ignore, false),
show_symlinks = vim.F.if_nil(opts.show_symlinks, false),
follow_symlinks = vim.F.if_nil(opts.follow_symlinks, false),
files = vim.F.if_nil(opts.files, true), -- file or folders mode
grouped = vim.F.if_nil(opts.grouped, false),
Expand Down
9 changes: 9 additions & 0 deletions lua/telescope/_extensions/file_browser/make_entry.lua
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,10 @@ local make_entry = function(opts)
end
end

if entry.lstat.type == "link" then
path_display = string.format("%s -> %s", path_display, utils.transform_path(opts, entry.realpath))
end

local file_width = vim.F.if_nil(opts.file_width, math.max(15, total_file_width))
-- TODO maybe this can be dealt with more cleanly
if #path_display > file_width then
Expand Down Expand Up @@ -242,6 +246,11 @@ local make_entry = function(opts)
return t.lstat
end

if k == "realpath" then
t.realpath = vim.F.if_nil(vim.loop.fs_realpath(t.value))
return t.realpath
end

return rawget(t, rawget({ value = 1 }, k))
end

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

0 comments on commit d599e1d

Please sign in to comment.