vim-projectionist icon indicating copy to clipboard operation
vim-projectionist copied to clipboard

glob does not match root directory

Open sergeant-wizard opened this issue 7 years ago • 6 comments

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.

sergeant-wizard avatar Jun 02 '18 22:06 sergeant-wizard

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.

tpope avatar Jun 02 '18 23:06 tpope

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?

sergeant-wizard avatar Jun 02 '18 23:06 sergeant-wizard

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 {}.

tpope avatar Jun 03 '18 01:06 tpope

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.

sergeant-wizard avatar Jun 03 '18 02:06 sergeant-wizard

Not filename per se but the matched portion of the filename.

{
    "*foo": {
        "make": "echo {}"
    }
}

tpope avatar Jun 03 '18 02:06 tpope

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)~

sergeant-wizard avatar Jun 03 '18 02:06 sergeant-wizard