Skip to content

Use relative path when possible #486

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

Conversation

eric-hansen
Copy link

@eric-hansen eric-hansen commented Jul 2, 2021

Introduces a new variable: vim_tree_load_git_file_relatively to not impact previous behavior. If non-nil then will attempt to use the absolute path, assuming within a Git project. I couldn't find a way to do it otherwise and didn't want to spend too much time hacking this about.

Resolves #482

If `vim_tree_load_git_file_relatively~= nil` and inside of a Git folder then work out how to load the file via relative path instead of absolute.  Otherwise if either condition is nil then fallback to old behavior of absolute path loading.
@eric-hansen eric-hansen changed the title Use relative path when possible #482 Use relative path when possible Jul 2, 2021
@smartding
Copy link
Contributor

please don't assume we're always within a git project, I use nvim to edit non-git-managed files too

@eric-hansen
Copy link
Author

please don't assume we're always within a git project, I use nvim to edit non-git-managed files too

Fixed. :)

@sindrets
Copy link
Contributor

sindrets commented Jul 3, 2021

This won't work when the git root is not the cwd of the tree. Also, this will be enabled even when:

let g:nvim_tree_load_git_file_relatively = 0

Which goes against how we treat all the other boolean options. #487 is a better approach.

@eric-hansen eric-hansen closed this Jul 3, 2021
@eric-hansen
Copy link
Author

Gotcha. Since you believe #487 is the better approach I've went and closed this out.

@Hubro
Copy link

Hubro commented Sep 28, 2021

For some reason this change was reverted:

099f905

And nvim-tree is once again opening all files using an absolute path, which is a huge pain for me.

Why was the change reverted? Is there something we can do to re-introduce it?


EDIT: Right, seems like it caused this bug: #495

Anything that can be done to fix it?

@smartding
Copy link
Contributor

@Hubro
I don't seem to experience the bug described in that video in #495, so I just kept my patch in my own fork, the patch only changes two lines of code.

@fragov
Copy link

fragov commented Aug 20, 2022

Same issue. Btw, Telescope opens files with relative paths.
Can this be fixed?

@alex-courtis
Copy link
Member

Same issue. Btw, Telescope opens files with relative paths. Can this be fixed?

There is little consistency between plugins and whether they open files relatively or absolutely.

It should be possible to open relatively; please raise a feature request.

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

Successfully merging this pull request may close these issues.

absolute path and relative path
6 participants