nvim-neo-tree / neo-tree.nvim

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

BUG:follow_current_file does not work at a directory that containing a large number of subdirectories and files #1409

Open zaiqiang-dong opened 7 months ago

zaiqiang-dong commented 7 months ago

Did you check docs and existing issues?

Neovim Version (nvim -v)

0.9.5

Operating System / Version

20.04.1-Ubuntu

Describe the Bug

follow_current_file does not work at a directory that containing a large number of subdirectories and files,such as a Linux source code tree

Screenshots, Traceback

https://github.com/nvim-neo-tree/neo-tree.nvim/assets/10396859/db76b222-7160-4278-ad8b-ac327ce93a15

Steps to Reproduce

1.set "follow_current_file = { enabled = true }," 2.open vim in a linux source code tree and open neo tree 3.run "/" find "file.c" and select by "c-n" and "" open it

Expected Behavior

neo tree can focus the "file.c" that opened by

Your Configuration

{
        "nvim-neo-tree/neo-tree.nvim",
        branch = "v3.x",
        cmd = "Neotree",
        keys = {
            {
                "<leader>n",
                function()
                    require("neo-tree.command").execute({ toggle = true, dir = vim.loop.cwd() })
                end,
                desc = "Explorer NeoTree (cwd)",
            },
            {
                "<leader>r",
                "<cmd>Neotree reveal<CR>",
                desc = "Explorer NeoTree (cwd)",
            },
        },
        init = function()
            if vim.fn.argc(-1) == 1 then
                local stat = vim.loop.fs_stat(vim.fn.argv(0))
                if stat and stat.type == "directory" then
                    require("neo-tree")
                end
            end
        end,
        opts = {
            close_if_last_window = true,
            resize_timer_interval = 1000,
            sources = { "filesystem", "buffers", "git_status", "document_symbols" },
            source_selector = {
                winbar = true,
                sources = {
                    { source = "filesystem" },
                    { source = "buffers" },
                    { source = "remote" },
                },
            },
            open_files_do_not_replace_types = { "terminal", "Trouble", "trouble", "qf", "Outline" },
            filesystem = {
                bind_to_cwd = true,
                follow_current_file = { enabled = true },
                use_libuv_file_watcher = true,
            },
            window = {
                position = "left",
                width = 30,
                mappings = {
                    ["<s-Tab>"] = "prev_source",
                    ["<Tab>"] = "next_source",
                },
            },
            default_component_configs = {
                indent = {
                    with_expanders = true, -- if nil and file nesting is enabled, will enable expanders
                    expander_collapsed = "",
                    expander_expanded = "",
                    expander_highlight = "NeoTreeExpander",
                },
            },
        },
        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
            {
                "s1n7ax/nvim-window-picker",
                version = "2.*",
                config = function()
                    require("window-picker").setup({
                        filter_rules = {
                            include_current_win = false,
                            autoselect_one = true,
                            -- filter using buffer options
                            bo = {
                                -- if the file type is one of following, the window will be ignored
                                filetype = { "neo-tree", "neo-tree-popup", "notify" },
                                -- if the buffer type is one of following, the window will be ignored
                                buftype = { "terminal", "quickfix" },
                            },
                        },
                    })
                end,
            },
        },
        config = function(_, opts)
            require("neo-tree").setup(opts)
        end,
    },
pysan3 commented 7 months ago

This is reproducible and unfortunately I think this is very difficult to fix.

@zaiqiang-dong Will it start following current file when you go to a different file and then come back? (I assume the answer is yes) and this is the only easy way to restart follow-current-file.

I'm currently doing a rewrite that should make search and async code work smoothly so please wait till it's done for a real solution: https://github.com/nvim-neo-tree/neo-tree.nvim/discussions/1340#discussioncomment-8812757

zaiqiang-dong commented 7 months ago

Thank you for your reply. Looking forward to version v4. x

0x56696B commented 6 months ago

+1 I hit the same issue, even when the file name is unique. A lot of files and deep nesting leads to the follow_current_file not doing anything. Works on small codebase, but on a larger one it fails silently