Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
3 tasks done
zaiqiang-dong opened this issue Mar 21, 2024 · 3 comments
Assignees
Labels
bug Something isn't working
Milestone

Comments

@zaiqiang-dong
Copy link

zaiqiang-dong commented Mar 21, 2024

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,
	},
@zaiqiang-dong zaiqiang-dong added the bug Something isn't working label Mar 21, 2024
@pysan3
Copy link
Collaborator

pysan3 commented Mar 21, 2024

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: #1340 (comment)

@pysan3 pysan3 self-assigned this Mar 21, 2024
@pysan3 pysan3 added this to the v4.0 milestone Mar 21, 2024
@zaiqiang-dong
Copy link
Author

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

@viko-stamoff
Copy link

+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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants