Skip to content

Multiple sets of patterns #124

@casey

Description

@casey

Thanks for the great plugin!

I mostly program in Rust, and adding Cargo.toml to g: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, sometimes vim-rooter will stop at a Cargo.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 setting g:rooter_patterns to multiple sets of patterns, which would be checked in order.

In my this case, I would use the following configuration:

let g:rooter_patterns = [['.git/'], ['Cargo.toml']]

vim-rooter would first search for a .git directory, and only if that failed search for a Cargo.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 in plugin/rooter.vim.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions