vim-projectionist
vim-projectionist copied to clipboard
glob does not match root directory
Suppose I have a directory structure
foo
bar/foo
and I want to set a rule for all the foo files.
If I create a .projections.json like so:
{
"*foo": {
"make": "echo found"
}
}
the rule works for bar/foo but not for foo in the root directory.
In zsh, ls **/*foo works as expected so it'll be nice if vim-projectionist behaved similarly.
I confirmed this in both vim 7.4.1689 and 8.0.1542.
I mean that's going to match quxxfoo too, working as you request would still be a half ass solution.
I recommend adding both "foo" and "*/foo". I'm not too keen on the duplication either but the current format does sadly necessitate it from time to time.
Does this come from the limitations of vim-script by the way? I can barely read vim script let alone write, but I think you could do this easily in other languages or frameworks?
It's not a Vim Script limitation. The core issue is that Projectionist deliberately disallows * to match nothing, because nothing isn't a valid filename, and we need a valid filename for {}.
I see, but can’t we use recursive glob? For example in ruby
Dir.glob(“**/foo”)
would provide the desired output and wouldn’t contain nothing as filenames, if I understand correctly.
Not filename per se but the matched portion of the filename.
{
"*foo": {
"make": "echo {}"
}
}
Right, that would break things.
What I should have said and want working is **/foo, but that doesn’t work either ~(I don’t have a laptop now to confirm this so I may be wrong)~