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

Add user choice to follow symlinks or keep them #1404

Open
terminatorul opened this issue Feb 4, 2024 · 4 comments
Open

Add user choice to follow symlinks or keep them #1404

terminatorul opened this issue Feb 4, 2024 · 4 comments

Comments

@terminatorul
Copy link

Add new option so users can choose to resolve symlinks or not.

Automatically resolving symlinks is not always the right choice, and is different from what Vim does, and can cause some issues for users when their directory changes unexpectedly.

Attached a (rather naive) patch that simply skips the call to Vim resolve() function if the option g:NERDTreeResolveSymLinks is disabled (v:false). The default option is v:true, to keep the original behavior of NERDTree, though I do not recommend it.

symlinks.zip

@rzvxa
Copy link
Member

rzvxa commented Feb 5, 2024

Hi, Thanks for bringing this up. The reason behind resolving the symlinks in NERDTree was to show the symlink destination in the tree with the [name] -> [dest] format and provide the ability to follow the node in the tree on expanding it. There was PR #1367 for toggling the destination preview on or off. We can extend it so it can disable the whole symlink resolving.
To make it easier on ourselves we can replace the toggle with a global variable to prevent it from changing constantly by the user in mid-session.

Until now there was no good reason for using #1367, But if we use it to keep symlinks unresolved it can be useful.
Feel free to fork and modify that PR or create your own if you want to do it fresh.

@terminatorul
Copy link
Author

I think showing the symlinks (and junctions on Windows) is fine, as it will not cause problems to users, But replacing the symlink with the target, when changing directory (or loading a directory) or opening a file, is a different option.

I noticed somehow my simple patch obove does not affect how symlinks are displayed, but still prevents changing the original directory. So luckily it did exactly what I wanted.

@rzvxa
Copy link
Member

rzvxa commented Feb 6, 2024

Maybe I'm wrong since I didn't use the patch I just read it, As far as I've seen NERDTree needs to resolve the path to knowing if a file is a symlink or not so I don't know how bypassing it wouldn't break the symlink destination.
I need to run it to make sure, But I highly encourage you to create a PR for it.

@rzvxa
Copy link
Member

rzvxa commented Feb 7, 2024

A PR addressing this issue may also resolve or help with #1339 and #1352.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants