neo-tree.nvim icon indicating copy to clipboard operation
neo-tree.nvim copied to clipboard

BUG: Neotree not showing all buffers after restoring a session

Open Oneechan69 opened this issue 4 months ago • 0 comments

Did you check docs and existing issues?

  • [X] I have read all the docs.
  • [X] I have searched the existing issues.
  • [X] I have searched the existing discussions.

Neovim Version (nvim -v)

NVIM v0.10.1 Build type: Release LuaJIT 2.1.1725453128

Operating System / Version

macOS 15.1 Beta

Describe the Bug

When I open nvim and restore a session with either rmagatti/auto-session, or :mksession and :source, Neotree doesn't show all the open buffers while :ls does.

Screenshots, Traceback

No response

Steps to Reproduce

  1. nvim -u repro.lua
  2. Open 1-2 markdown files
  3. :mksession Session.vim
  4. reopen, nvim -u repro.lua
  5. Restore with :source Session.vim
  6. Do :ls for comparison

Expected Behavior

All buffers are shown after doing :Neotree buffers

Your Configuration

-- LazyNvim Setup
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
if not (vim.uv or vim.loop).fs_stat(lazypath) then
  vim.fn.system({
    "git",
    "clone",
    "--filter=blob:none",
    "https://github.com/folke/lazy.nvim.git",
    "--branch=stable", -- latest stable release
    lazypath,
  })
end
vim.opt.rtp:prepend(lazypath)
require("lazy").setup({
    {
        "nvim-neo-tree/neo-tree.nvim",
        branch = "v3.x",
        lazy = false,
        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
        },
        config = function()
          require("neo-tree").setup({
            follow_current_file = {
              enabled = true
            },
            buffers = {
              leave_dirs_open = true,
              follow_current_file = {
                  enabled = true,
                  leave_dirs_open = true,
              },
              bind_to_cwd = false,
          },
            sources = { "filesystem", "buffers", "git_status", "document_symbols" },
            open_files_do_not_replace_types = { "terminal", "Trouble", "trouble", "qf", "Outline" },
            filesystem = {
              follow_current_file = { enabled = true },
              use_libuv_file_watcher = true,
            },
            window = {
              mappings = {
                ["<space>"] = "none",
                ["Y"] = {
                  function(state)
                    local node = state.tree:get_node()
                    local path = node:get_id()
                    vim.fn.setreg("+", path, "c")
                  end,
                  desc = "Copy Path to Clipboard",
                },
                ["O"] = {
                  function(state)
                    require("lazy.util").open(state.tree:get_node().path, { system = true })
                  end,
                  desc = "Open with System Application",
                },
              },
            },
            default_component_configs = {
              indent = {
                with_expanders = true, -- if nil and file nesting is enabled, will enable expanders
                expander_collapsed = "",
                expander_expanded = "",
                expander_highlight = "NeoTreeExpander",
              },
              git_status = {
                symbols = {
                  unstaged = "󰄱",
                  staged = "󰱒",
                },
              },
            },
          })
        end,
      },
})


vim.api.nvim_create_autocmd("BufRead", {
    pattern = "*.md",
    callback = function()
      vim.cmd(":Neotree buffers")
      vim.cmd(":wincmd p")
    end,
})

Oneechan69 avatar Sep 30 '24 21:09 Oneechan69