Tree sitter grammars recently started adding a
[`tree-sitter.json`](https://tree-sitter.github.io/tree-sitter/cli/init.html?highlight=tree-sitter.json#structure-of-tree-sitterjson)
file to the root of their repos. It has some useful information for
folks writing code, so I believe it makes sense to expose.
Here I've made 3 changes:
1. `tree-sitter-grammars.*` now include the `tree-sitter.json`:
```console
$ ls $(nix-build -A tree-sitter-grammars.tree-sitter-nix)
parser queries tree-sitter.json
```
2. `python3.pkgs.tree-sitter-grammars.*` Python packages have a new
`config` method you can call to get a nicely typed datastructure:
```console
$ nix-shell -p 'let pkgs = import ./. {}; in pkgs.python3.withPackages (ps: [ps.tree-sitter-grammars.tree-sitter-nix])' --run "python -c 'import tree_sitter_nix; print(tree_sitter_nix.config())'"
field_schema='https://tree-sitter.github.io/tree-sitter/assets/schemas/config.schema.json' grammars=[Grammar(name='nix', camelcase='Nix', title='Nix', scope='source.nix', path='/nix/store/29vbs3fbzzjgq6jgrwlklwwbwwsvgx2b-tree-sitter-nix-grammar-0.25.6', external_files=None, file_types=['nix'], highlights='queries/highlights.scm', injections='queries/injections.scm', locals='queries/locals.scm', tags='queries/tags.scm', injection_regex='^nix$', first_line_regex=None, content_regex=None, class_name='TreeSitterNix')] metadata=Metadata(version='0.3.0', license='MIT', description='Nix grammar for tree-sitter', links=Links(repository=AnyUrl('https://github.com/nix-community/tree-sitter-nix'), funding=None, homepage=None), authors=[Author(name='Charles Strahan', email='charles@cstrahan.com', url=AnyUrl('https://www.cstrahan.com/'))], namespace='io.github.tree-sitter') bindings=Bindings(c=True, go=True, java=False, kotlin=False, node=True, python=True, rust=True, swift=True, zig=False)
```
This required introducing a new `python-modules/tree-sitter-config`
for the generated `TreeSitterConfig` datatype. I'm sort of hoping
this (or something like it) would be acceptable for including in upstream
`tree-sitter/py-tree-sitter`.
3. I've submitted patches to all grammers whose `tree-sitter.json` didn't
obey upstream's schema definition. Until those patches land, we can
opt the language out of the `test_config` test by setting
`passthru.checkTreeSitterJson = false`.