-
Notifications
You must be signed in to change notification settings - Fork 255
CWD/root does not update after changing buffer for the first time #225
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
Comments
Neo-tree does not actually change it's root based on what file you are viewing. Step 5 in your example is the result of another plugin or setting changing your cwd. It should react to the |
Ah, that's true. Should have mentioned it. I use https://github.com/ahmedkhalf/project.nvim and it works with nvim-tree and does work with neo-tree as well, just not first time I change buffers for some reason. Apologies for incomplete information, completely slipped my mind. |
I tried to install that project and test it out but it just doesn't work at all for me. The one time I got it to change the working directory, it went to the wrong one. My suggestion is to confirm what the working directory actually is after entering a buffer:
will output the global working directory. This applies if there is no tab cwd or window cwd.
will output the tab's working directory. This is what is used when displayed in a sidebar. (position = "left" or position = "right")
will output the window's working directory. This is used when the neo-tree position = "current". |
Just tried to run Did you not manage to get it to change cwd for you at all? Odd, that plugin just works out of the box for me. Would you want me to try to come up with minimal config to replicate that issue? |
Yes, that would be helpful. Another thing you could try, if you don't mind cloning the repo and pointing your plugin manager to your local copy, is to change this line: neo-tree.nvim/lua/neo-tree/setup/init.lua Line 57 in b500daa
to: events.define_autocmd_event(events.VIM_DIR_CHANGED, { "++nested DirChanged" }, 200) |
No problem at all, will try to put something together soon. After making that change I got that error:
|
Sorry, I had the syntax wrong. |
Unfortunately changing line 57 to events.define_autocmd_event(events.VIM_DIR_CHANGED, { "DirChanged ++nested" }, 200) made it never update root of the tree, as oppose to not only updating it on first change. |
I tried to come up with minimal reproducible configuration but failed. I have two points:
Will keep trying to come up with solid steps to reproduce it. Just putting it up there now in case it points you to something. |
The issue here is the firing, or possibly the swallowing of the DirChanged autocmd event. My idea about added I'm not sure how null-ls can factor into this, but it's an interesting clue. Probably still related to how autocmd events are affected by what it does. |
I just pushed a change to the main branch that will enabled nested events for the DirChanged autocmd. This may fix your issue, can you give it a try? |
Thanks for looking into it, but unfortunately it did not help, root still doesn't change on initial change of buffers. |
Ignore that close event, it happened automatically when I released because I mentioned the issue number in the commit. I'm re-opening now. |
I know what this is. In that situation, I think Telescope will open the buffer in the Neo-tree window. When that happens, neo-tree will recognize that its window was stolen, show that buffer in a different window, and set neo-tree as the active buffer again. There are some
One or more of those is probably critical to fixing the problem, I just don't know how just yet! |
|
@gegoune A lot has changed since this was initially reported. Is this still happening? |
Did not check that very use case in a while and indeed it seems to be fixed now. Gonna close. Thanks! |
I still have the problem. Could you give me some suggestions about how to config? |
I am on
main
now but it was the same onv2.x
branch.With
require('neo-tree').setup()
(no custom configuration) neo-tree's CWD (root) is not updating after switching to another repository for the first time.Follow these steps:
:e B/file
or Telescope - effect is the same), tree remains rooted at A's root`, showing content of repository A instead of BCan you reproduce it?
I am using
filesystem
for above test but it behaves the same forbuffers
but does not update at all forgit_status
.The text was updated successfully, but these errors were encountered: