nvim-tree / nvim-tree/nvim-tree.lua

Treat symbolic links as valid tree paths for root purposes

Open
#2,015 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

feature request QOL
Dominant language
Lua
Stars
8.6k
Forks
639
Avg merge
1d 14h
Merged PRs (30d)
2

Description

Is this a question?
No.

Can this functionality be implemented utilizing API?
Don't think so.

Is your feature request related to a problem? Please describe.
I'm editing some project files that are symbolically linked in from somewhere else but his precludes nvim-tree showing a common root that isn't system root (/). For example:

the true path to these files is in /mnt/hgfs/vmshare/ . I am editing various files in /home/russianguyovic/project/ and have the files linked into /home/russianguyovic/project/headers/ (e.g. ln -s /mnt/hgfs/vmshare/ /home/russianguyovic/project/headers/). My tree root for all other files in the project is /home/russianguyovic/project/, however for the symbolically linked files that is not possible; the closest common root nvim-tree will acknowledge is the system root, / (root). If, while focused on some file /mnt/hgfs/vmshare/stuff.h one uses :cd /home/russianguyovic/project/, the tree very briefly blinks to the new root and then goes back to /mnt/hgfs/vmshare/. The solution would be for nvim-tree to look at link location rather than the target and treat that as the leaf from which to build a path back up towards system root.

Describe the solution you'd like
nvim-tree should look at the link location, not the target, to determine where that leaf is relative to system root. (I feel like I'm doing a terrible job of explaining this. I would like the two groups of files mentioned above to both be able to use /home/russianguyovic/project/ as their nvim-tree root, to reference my hypothetical example.)

Describe alternatives you've considered
The alternative is to just live with it.

Additional context
Imagine a directory structure like so with a linked-in folder, highlighted by a red box below:
regular_file
nvim-tree correctly shows the target of the symbolic link, which is cool, but it uses only the target for directory traversal pathing to determine possible roots:
symbolic_link
If I would like to see both .viminfo and config.toml in the tree at the same time, I can only do so by using system root as the root of the nvim-tree tree:
giant-tree
This is less than ideal.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the linked-directory example from the issue and tracing how nvim-tree determines a common root from a focused file. Compare the symlink location with its target during traversal. Done means files under /mnt/hgfs/vmshare/ and /home/russianguyovic/project/ can share /home/russianguyovic/project/ as the tree root without falling back to /.

Written by the indexing model from the issue text.

Assessment

Tech stack
lua
Domain
devtools
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.