Skip to content

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

Open
@zaiqiang-dong

Description

@zaiqiang-dong

Did you check docs and existing issues?

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

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

Screencast.2024-03-21.17.50.06.mp4

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,
	},

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions