Repository is not illegal here.

foo:
name: some.scope.lang
begin: "(?i)([a-z][a-z0-9_]*)\\s*\\("
end: "\\)"
patterns:
- include: "#baz"
- include: "#bar"
repository:
...
Doesn't seem to like repository at any level below top.

foo: name: some.scope.lang begin: "(?i)([a-z][a-z0-9_]*)\\s*\\(" end: "\\)" patterns: - include: "#baz" - include: "#bar" repository: ...
Original is incorrect. For some reason, repository is not a supported key when the rule contains begin/end matches. The second comment stands. It is supported with no matches (just patterns, as above) and with a single match rule. e.g.
foo:
name: source.foo
match: "If.*"
captures:
0:
patterns:
- include: "#bar"
repository:
bar:
name: source.bar

I tried this on the current development version of vscode-tmlanguage (i.e. not the one on the marketplace) which contains the fix for #12, on a file foo.tmLanguage.yaml containing just this:
foo:
name: source.foo
match: "If.*"
captures:
0:
patterns:
- include: "#bar"
repository:
bar:
name: source.bar
The result is:
I think this is OK? Can you point me to another file where it's not working?
Thanks!
Sure, this file shouldn't have any syntax issues.
I believe this is now fixed