nvim-telescope / telescope-file-browser.nvim

File Browser extension for telescope.nvim
MIT License
1.69k stars 92 forks source link

Symlinked folders are not shown #300

Open aadi58002 opened 1 year ago

aadi58002 commented 1 year ago

Description

I use stow to manage my config file. All the folders which stow has symlinked are not visible inside the directory view.

image

image

Neovim version

NVIM v0.9.1
Build type: None
LuaJIT 2.1.0-beta3
Compilation: /usr/lib/ccache/bin/cc  -Wall -Wextra -pedantic -Wno-unused-parameter -Wstrict-prototypes -std=gnu99 -Wshadow -Wconversion -Wvla -Wdouble-promotion -Wmissing-noreturn -Wmissing-format-attribute -Wmissing-prototypes -fno-common -Wimplicit-fallthrough -fdiagnostics-color=always -fstack-protector-strong -DUNIT_TESTING -DINCLUDE_GENERATED_DECLARATIONS -D_GNU_SOURCE -I/usr/include/luajit-2.1 -I/usr/include -I/usr/include -I/builddir/neovim-0.9.1/build/src/nvim/auto -I/builddir/neovim-0.9.1/build/include -I/builddir/neovim-0.9.1/build/cmake.config -I/builddir/neovim-0.9.1/src -I/usr/include -I/usr/include -I/usr/include -I/usr/include -I/usr/include -I/usr/include -I/usr/include

  system vimrc file: "$VIM/sysinit.vim"
  fall-back for $VIM: "/usr/share/nvim"

Operating system and version

Void Linux

Steps to reproduce

  1. Create a soft symlink to any folder.
  2. Open the folder where the symlink was created.
  3. The symlink is not visible in the file and folder view.

Expected behavior

It expected to show symlinks like (Like in the screen shot) with a arrow and path of the link.It can also show them as just regular folders or files.

Actual behavior

Symlinks are ignored and not visible in the default view

Minimal config

vim.cmd [[set runtimepath=$VIMRUNTIME]]
vim.cmd [[set packpath=/tmp/nvim/site]]
local package_root = '/tmp/nvim/site/pack'
local install_path = package_root .. '/packer/start/packer.nvim'
local function load_plugins()
  require('packer').startup {
    {
      'wbthomason/packer.nvim',
      {
        'nvim-telescope/telescope.nvim',
        requires = {
          'nvim-lua/plenary.nvim',
          'nvim-telescope/telescope-file-browser.nvim',
        },
      },
      -- ADD PLUGINS THAT ARE _NECESSARY_ FOR REPRODUCING THE ISSUE
    },
    config = {
      package_root = package_root,
      compile_path = install_path .. '/plugin/packer_compiled.lua',
      display = { non_interactive = true },
    },
  }
end
_G.load_config = function()
  require('telescope').setup()
  require('telescope').load_extension('file_browser')
  -- ADD INIT.LUA SETTINGS THAT ARE _NECESSARY_ FOR REPRODUCING THE ISSUE
end
if vim.fn.isdirectory(install_path) == 0 then
  print("Installing Telescope and dependencies.")
  vim.fn.system { 'git', 'clone', '--depth=1', 'https://github.com/wbthomason/packer.nvim', install_path }
end
load_plugins()
require('packer').sync()
vim.cmd [[autocmd User PackerComplete ++once echo "Ready!" | lua load_config()]]
jamestrew commented 1 year ago

I think this is a pretty solid feature to have.

Just showing symlinked files/folder would be trivially easy. Showing where the symlink points to would be a little bit more work.

One concern I have is that we don't currently have a good "ecosystem" around navigating symlinks. Currently we use the realpath(3) of a given path (so symlinks will also be expanded and followed). Navigating back from a symlink actually just takes you one directory up rather than back. So there will probably be a need for new options and actions to support the navigation to/from symlinks. This will take the most work I think. It won't be anything crazy but without this "ecosystem" showing symlinks might not be a great experience.

I'll be pretty busy over the next few months. I'm not sure if I'll have the capacity for new features. PRs are welcome.

aadi58002 commented 1 year ago

I think the behavior you described is most practical way the folder links can work.It will work very nicely for my workflow. Sadly i am not too familiar with either neovim or the lua language. I will try to implement it but not sure how long it might take. Thanks for the quick response and the guideline to implement the feature.Also great extension thanks for creating and maintaining it.

jamestrew commented 1 year ago

I'm not sure if following symlink by default is ideal though. cd doesn't follow symlink by default and neither does netrw.

I think ideally to have symlinks as part of this plugin, we probably want:

If you're interested in trying to implement these, I can try to help you through it. In the meantime, if you wanna try out showing symlinks yourself, you can fork this repo and add something like

table.insert(args, "--type")
table.insert(args, "symlink")

somewhere in here https://github.com/nvim-telescope/telescope-file-browser.nvim/blob/ad7b637c72549713b9aaed7c4f9c79c62bcbdff0/lua/telescope/_extensions/file_browser/finders.lua#L38-L66

edit: adding the --type symlink flag to folder browser might cause some issues when coupled with git status

rashil2000 commented 1 year ago

@jamestrew I think a good and quick short-term workaround would be to enable showing symlinked files/folder, when the user has fd installed. The way we could do this is by introducing a config option follow_symlinks (which only works in the presence of fd), and use a block of code such as:

  if opts.follow_symlinks then
    table.insert(args, "--follow")
  end

somewhere after here:

https://github.com/nvim-telescope/telescope-file-browser.nvim/blob/ad7b637c72549713b9aaed7c4f9c79c62bcbdff0/lua/telescope/_extensions/file_browser/finders.lua#L59-L64

Would it be alright if I make a PR for this?

jamestrew commented 1 year ago

@rashil2000 sounds good. go for it thanks.

mebble commented 1 year ago

I was looking forward to this, thanks.

macseem commented 2 months ago

Issue is still there The PR seems to hang during code review :(