nvim-neo-tree / neo-tree.nvim

Neovim plugin to manage the file system and other tree like structures.
MIT License
3.63k stars 211 forks source link

BUG: not following `pwd` after restoring session with Resession #1495

Open mehalter opened 3 months ago

mehalter commented 3 months ago

Did you check docs and existing issues?

Neovim Version (nvim -v)

0.10.0 Release

Operating System / Version

Arch Linux

Describe the Bug

When I restore a session with resession.nvim which in turn changes the current working directory (:pwd), neo-tree doesn't reflect the new current working directory when I open it if it was previously open

Screenshots, Traceback

This shows Neo-tree opened not in the current working directory which is displayed in the bottom when I run :pwd

2024-06-12_09:15:03_screenshot

Steps to Reproduce

  1. create a directory with the repro.lua file
  2. mkdir test, make a directory in there as a "scratch directory
  3. echo "SESSION LOADED" > test/test, make an example file
  4. nvim -u repro.lua, start up neovim
  5. :cd test, change directory into the test directory
  6. :e test, open our example file
  7. :lua require("resession").save("Test"), save a session
  8. :q, quit neovim
  9. nvim -u repro.lua, start up neovim again
  10. :Neotree, open neo-tree and see that we are in our repro folder
  11. q, close neo-tree
  12. :lua require("resession").load("Test"), load our session
  13. :pwd, check the current working directory and see that it is in our test/ folder
  14. :Neotree, open neo-tree and see that it has us in our repro folder and not in the test/ folder
  15. :pwd, check the current working directory even in our Neo-tree buffer and see that it has us in the test/ directory

Expected Behavior

Neo-tree should be following the current working directory no matter what. I'm not sure what would be causing this issue. My initial thought is the issue is on the neo-tree side just because neo-tree should be respecting the current working directory no matter what. Please let me know if I can provide any other information to help debug this!

Your Configuration

-- DO NOT change the paths and don't remove the colorscheme
local root = vim.fn.fnamemodify("./.repro", ":p")

-- set stdpaths to use .repro
for _, name in ipairs({ "config", "data", "state", "cache" }) do
    vim.env[("XDG_%s_HOME"):format(name:upper())] = root .. "/" .. name
end

-- bootstrap lazy
local lazypath = root .. "/plugins/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
    vim.fn.system({ "git", "clone", "--filter=blob:none", "https://github.com/folke/lazy.nvim.git", lazypath })
end
vim.opt.runtimepath:prepend(lazypath)

-- install plugins
local plugins = {
    "folke/tokyonight.nvim",
    {
        "nvim-neo-tree/neo-tree.nvim",
        branch = "v3.x",
        dependencies = {
            "nvim-lua/plenary.nvim",
            "nvim-tree/nvim-web-devicons", -- not strictly required, but recommended
            "MunifTanjim/nui.nvim",
            -- "3rd/image.nvim", -- Optional image support in preview window: See `# Preview Mode` for more information
        },
        opts = {},
    },
    {
        "stevearc/resession.nvim",
        opts = {},
    },
    -- add any other plugins here
}
require("lazy").setup(plugins, {
    root = root .. "/plugins",
})

vim.cmd.colorscheme("tokyonight")
-- add anything else here
agmalpartida commented 3 weeks ago

Neo-tree works if you refresh (by using the R key). Neo-tree needs to automatically refresh.