-
Notifications
You must be signed in to change notification settings - Fork 72
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
Multiple sets of patterns #124
Comments
What does the directory structure of a workspace(s) look like? |
It's pretty flexible, but a few layouts might be:
Or:
|
I've never used Rust. Do those layouts show the project root directory with the crates being workspaces? Or Is each example a workspace? If the latter, please could you show where workspaces sit in relation to the project root. Presumably you can't just use |
Each example is a workspace, with the top Usually workspaces have |
Hmm, so is a workspace the root of a project? Or does the root of a project contain workspaces? |
A workspaces is usually at the root of a project, and it contains one or more crates. A real-world example is here. The repo is a workspace, and the root |
Thanks for explaining further. Would you expect to see a If not, these patterns work for me: let g:rooter_patterns = ['!../Cargo.toml', '!../../Cargo.toml', 'Cargo.toml'] Your suggestion of an extra loop changes the algorithm from breadth-first to depth-first. If I'm going to do that I'd prefer an explicit option and to keep the patterns as a simple list. |
You would expect to see a
That's a good idea, I'll do that.
I understand the reluctance to do so, although the advantage of a list of lists is that it has extra flexibility in that it combines breadth first and depth first searches. And if it's possible to check if an item is a list or a list of lists, it could still retain the existing behavior by default when it's just a list of strings. |
I met similar situation. Android use let g:rooter_patterns = [['.repo'], ['.git']] |
Disable specific project root patterns (Makefile, package.json) that are liable to appear below toplevel and confuse vim-rooter, until we gain the ability to choose between BFS and DFS semantics.
Thanks for the great plugin!
I mostly program in Rust, and adding
Cargo.toml
tog:rooter_patterns
usually works to find the correct project root when working in rust projects.However, Rust supports workspaces with directories with
Cargo.toml
files. In this case, sometimesvim-rooter
will stop at aCargo.toml
file in a subdirectory.In such cases, I'd rather
vim-rooter
use the location of the.git
directory to find the project root.I was thinking about how
vim-rooter
might support this, and one possibility is to to allow settingg:rooter_patterns
to multiple sets of patterns, which would be checked in order.In my this case, I would use the following configuration:
vim-rooter
would first search for a.git
directory, and only if that failed search for aCargo.toml
file.I think this would be a pretty simple change. A new configuration option,
g:rooter_pattern_groups
. If it was unset, it would default to[g:rooter_patterns]
, for backwards compatibility. And the implementation would be an additional for loop around the main for loop inplugin/rooter.vim
.The text was updated successfully, but these errors were encountered: