nerdtree
nerdtree copied to clipboard
NERDTree does not update its tree when changing working directory
Use fzf to change working directory
I share my code (lua) that I use to change working directory:
function Projects()
coroutine.wrap(function()
-- table projects, example { '/home/erick/Proyectos/glux', '/home/erick/.dotfiles' }
local projects = require('project_nvim').get_recent_projects()
local result = fzf.fzf(projects, "--ansi", { border = false })
if result then
-- change working directory
require('project_nvim.project').set_pwd(result[1], "stixcode")
else
print("Ups error")
end
end)()
end
My home directory was /home/erick/Proyectos/glux but when changing to /home/erick/.dotfiles, NERDTree does not update

I temporarily fix it using the NERDTreeCWD function, but this unnecessarily opens NERDTree
function Projects()
coroutine.wrap(function()
-- table projects, example { '/home/erick/Projects/nerdtree', '/home/erick/Projects/fzf.vim' }
local projects = require('project_nvim').get_recent_projects()
local result = fzf.fzf(projects, "--ansi", { border = false })
if result then
-- change working directory
require('project_nvim.project').set_pwd(result[1], "stixcode")
--> Update NERDTree <--
vim.fn["NERDTreeCWD"]()
else
print("Ups error")
end
end)()
end
this is because it is called the function NERDTree Focus is called in NERDTreeCWD preservim/nerdtree:/plugin/NERD_tree.vim#L213
Is there a way to update NERDTree after changing working directory?