sync with cwd not working
Description
The option to sync with the cwd is not working since I updated
Neovim version
NVIM v0.9.0
Operating system and version
Linux 6.1.0 Debian amd64
nvim-tree version
6319ad94050c4489951ad34b6535c134a3efa455
Minimal config
require('nvim-tree').setup ({
disable_netrw = true,
hijack_netrw = true,
prefer_startup_root = false,
sync_root_with_cwd = true,
})
Steps to reproduce
- nvim
- cd
- NvimTreeOpen
Expected behavior
The root of Nvim tree should be the cwd that you cd-ed into.
Actual behavior
It uses the directory from which you started neovim
Just noticed that too, i can also reproduce seems like it was working up until very recently.
Yeah, I updated all my plugins today and that was a problem
I'm not able to reproduce; the tree always opens in my home directory.
:cd something opens with something root.
Same behaviour with
vim.g.loaded_netrw = 1
vim.g.loaded_netrwPlugin = 1
@CodeCraftTV I'd be most grateful if you created a Clean Room Replication as per the bug report instructions.
@CodeCraftTV @asmodeus812 please test with 874b7be as #2082 touched that functionality recently.
@alex-courtis the way reproduce this is simple - i open two tabs with two different working dirs (or two windows with lcd) then if i open the trees in both tabs and navigate between them, even though the tcd is updated, when i navigate from one tab to the next, the tree root and focused file just do not update, it is stuck on whichever root directory i first opened the tree. Config is below.
EDIT: I tried git reset --hard to the following commit - https://github.com/nvim-tree/nvim-tree.lua/commit/1d79a64a88af47ddbb55f4805ab537d11d5b908e this one works fine, i can jump between tabs and the file and root is updated correctly, tried the one you suggested but it was broken too. So it's somewhere between head and the one i tried with.
auto_reload_on_write = false,
sync_root_with_cwd = true,
hijack_cursor = true,
disable_netrw = true,
hijack_netrw = true,
hijack_unnamed_buffer_when_opening = true,
hijack_directories = {
enable = true,
auto_open = true
},
renderer = {
full_name = true,
indent_width = 1,
root_folder_modifier = ":t",
highlight_opened_files = "name",
},
git = {
enable = false,
ignore = true,
},
actions = {
change_dir = {
enable = false,
global = false,
},
open_file = {
quit_on_open = true,
resize_window = true,
},
},
update_focused_file = {
enable = true,
update_root = true,
ignore_list = {
"", "fzf", "help", "qf",
"lspinfo", "undotree"
}
},
view = {
hide_root_folder = false,
mappings = {
custom_only = false,
},
},
ignore_list = {
"", "fzf", "help", "qf",
"lspinfo", "undotree"
}
"" may result in all file finds being ignored. Remove it.
actions = {
change_dir = {
enable = false,
Is preventing directory changes. Set it and global to true.
I'm still not clear what the issue is; when did it first appear?
Please revert to 874b7be and attempt to replicate.
EDIT: I tried git reset --hard to the following commit - 1d79a64 this one works fine
That worked; I can reproduce.
actions.change_dir.enable behaviour has changed.
""may result in all file finds being ignored. Remove it.
I believe that is for filetypes, the reason it's empty is that i don't want to have any buffers with empty filetype to ever be considered for chdir. Empty filetypes usually indicate some special type of buffer that probably does not even exist on the fs.
actions = { change_dir = { enable = false,
That one i saw from the docs, reason it's set it i don't want nvim tree to change my working dir, only to read from it and respond accordingly.
*nvim-tree.actions.change_dir*
vim |current-directory| behaviour.
*nvim-tree.actions.change_dir.enable*
Change the working directory when changing directories in the tree.
But it's great you can reproduce it, i am still not sure which commit it was. I just randomly picked an old one, which i know worked since i recently tested exactly that functionality.
I believe that is for filetypes, the reason it's empty is that i don't want to have any buffers with empty filetype to ever be considered for chdir. Empty filetypes usually indicate some special type of buffer that probably does not even exist on the fs.
That was causing failures during my testing, as a lot of files have empty &ft. Please be mindful that find file and directory change won't happen for them.
But it's great you can reproduce it, i am still not sure which commit it was. I just randomly picked an old one, which i know worked since i recently tested exactly that functionality.
It seems that 31d8e24 #2060 caused the regression.
@asmodeus812 @CodeCraftTV I would be most grateful if you tested a fix:
cd /path/to/nvim-tree.lua
git pull
git checkout 2088-actions-change-dir-enable-false-does-not-update-tree-root
That didn't work for me, so i did some testing, and realised I at least somewhat accidentally wasted your time.
The bug I found was that when one has nvim-tree open and than uses :cd to enter a new directory in neovim, the tree doesn't follow like it did before. I tested it in a clean room and that seems to be the problem, as for the fix, that didn't work for me, because stupid I just didn't specify the problem much. All in all, I am very sorry to have waisted your time.
@CodeCraftTV Does it mean this issue cane closed?
I mean there is still that problem, that the tree doesnt update the root directory, when it was once opened. Now I ask, should i close this issue or not, and if yes, what should I do? (This is my first issue report)
Its broken for me as well...
sync_root_with_cwd = true,
But when changing the working folder it does not refresh nvim tree like it used too which is a shame.
@asmodeus812 @CodeCraftTV I would be most grateful if you tested a fix:
cd /path/to/nvim-tree.lua git pull git checkout 2088-actions-change-dir-enable-false-does-not-update-tree-root
I was faced with the same problem. I used workspaces neovim plugin to jump between different folders and the plugin was changing the current workspace correctly but on opening nvim-tree cwd wan't changed. I checked your branch and tested it, it works for me!
hi, fix #2095 works for me
Its broken for me as well...
sync_root_with_cwd = true,But when changing the working folder it does not refresh nvim tree like it used too which is a shame.
That sounds like a separate issue.
@rlees85 Please raise a new bug report, with a clean room reproducer and instructions on how to reproduce.
@alex-courtis I would but its now fixed! If its a separate issue, it was fixed by the same fix
I would but its now fixed! If its a separate issue, it was fixed by the same fix
Good news. Please do raise an issue if it occurs again.