Skip to content
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

Symlinked folders are not shown #300

Open
aadi58002 opened this issue Aug 13, 2023 · 11 comments
Open

Symlinked folders are not shown #300

aadi58002 opened this issue Aug 13, 2023 · 11 comments
Labels
bug Something isn't working

Comments

@aadi58002
Copy link

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()]]
@aadi58002 aadi58002 added the bug Something isn't working label Aug 13, 2023
@jamestrew
Copy link
Collaborator

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
Copy link
Author

aadi58002 commented Aug 16, 2023

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
Copy link
Collaborator

jamestrew commented Aug 16, 2023

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:

  • new options show_symlink (boolean for whether to show symlinks) & follow_symlink (boolean for whether <cr> on a symlink will follow it)
  • new actions something like cd and cd_physical (for cd and cd -P respectively)

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

local function fd_file_args(opts)
local args
if opts.files then
args = {
"--absolute-path",
"--path-separator=" .. os_sep,
"--type",
"file",
}
if opts.add_dirs then
table.insert(args, "--type")
table.insert(args, "directory")
end
if type(opts.depth) == "number" then
table.insert(args, "--maxdepth")
table.insert(args, opts.depth)
end
else
args = { "--type", "directory", "--absolute-path" }
end
if hidden_opts(opts) then
table.insert(args, "--hidden")
end
if not opts.respect_gitignore then
table.insert(args, "--no-ignore-vcs")
end
return args
end

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

@rashil2000
Copy link
Contributor

@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:

if hidden_opts(opts) then
table.insert(args, "--hidden")
end
if not opts.respect_gitignore then
table.insert(args, "--no-ignore-vcs")
end

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

@jamestrew
Copy link
Collaborator

@rashil2000 sounds good. go for it thanks.

@mebble
Copy link

mebble commented Sep 19, 2023

I was looking forward to this, thanks.

@macseem
Copy link

macseem commented Jul 15, 2024

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

@javierfileiv
Copy link

I'm looking forward to this... hope will get approved soon.
Thanks

@aadi58002
Copy link
Author

aadi58002 commented Nov 26, 2024

I was originally working on the PR but after that time I moved to using emacs and didn't time to work on the PR. There are only a few bug fixs left while the base functionality only viewing the symlink file and not showing the symlinked path was working for me for a few week while the PR was in review stage.

@javierfileiv
Copy link

I think I won't know have to continue your work... not a lua/nvim programmer, and mainly, even though Im learning, I dunno how to setup my nvim to get a environment to test and get logs. Do you know any guide to set it up?

@aadi58002
Copy link
Author

You can just create a fork of this plugin and during plugin installation point to your repo instead of this one. Then you can start developing in ~/.local/share/nvim folder where you will find your installed plugins

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

6 participants