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

Default detection methods { "lsp", "pattern" } cause multiple CWDs when opening files in same project. #156

Open
collinvandyck opened this issue May 25, 2024 · 0 comments

Comments

@collinvandyck
Copy link

In a Rust project with an attached LSP I noticed that nvim-tree was flickering when using project.nvim and opening files in different crates within the same workspace. The project would would stay correctly on the workspace root, but I wasn't sure why it was flickering, and also collapsing the directory of the previously opened file in a different sub-crate.

I turned silent_chdir = false to debug what was happening and what I saw is that it was performing multiple chdirs, once for one of the patterns that matched and also for the LSP workspace root.

Changing the detection method to just { "lsp" } removed the flickering and in-project collapse of the tree in the previous buffer in the other workspace crate.

It was my understanding from the documentation that the ordering of the detection methods meant that it would prefer a match from the first detection method encountered. I had assumed that since I had an lsp attached, it would only change directory to that supplied by the LSP and would ignore the patterns configured, but what I saw is that it was using both the LSP and the patterns.

This is my config that produced the flickering:

require("project_nvim").setup {
	detection_methods = { "lsp", "pattern" },                                                                        
	patterns = {
		".git",
		"Cargo.toml",
		"_darcs",
		".hg",
		".bzr",
		".svn",
		"Makefile",
		"package.json",
	},
	silent_chdir = false,
}

and this config stops the flickering and multiple CWD changes:

require("project_nvim").setup {
	detection_methods = { "lsp" },                                                                        
	patterns = {
		".git",
		"Cargo.toml",
		"_darcs",
		".hg",
		".bzr",
		".svn",
		"Makefile",
		"package.json",
	},
	silent_chdir = false,
}

Is there a way to use both lsp and pattern but to disregard the pattern if the lsp supplies a project root?

collinvandyck added a commit to collinvandyck/dotfiles that referenced this issue May 25, 2024
Using lsp and pattern ends up cuasing multiple CWDs to happen.

See: ahmedkhalf/project.nvim#156
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant