Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tree sitter fetch all grammars #107514

Merged
merged 9 commits into from Dec 30, 2020

Conversation

Profpatsch
Copy link
Member

The update script would only fetch the few grammars listed in the
tree-sitter repository previously. But the tree-sitter github orga has
a rather large amount of officially supported grammars.

Thus we change the script to query the github APIs for repositories
instead (up to 100 this is supported without paging).

Since the repository list also contains some that are not grammars,
there is a bash script which lists all repos we are aware of and the
ones we want to ignore. It will make sure we don’t forget any
repositories in the future, by comparing to the actual list with jq.

Motivation for this change
Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option sandbox in nix.conf on non-NixOS linux)
  • Built on platform(s)
    • NixOS
    • macOS
    • other Linux distributions
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Determined the impact on package closure size (by running nix path-info -S before and after)
  • Ensured that relevant documentation is up to date
  • Fits CONTRIBUTING.md.

@teto
Copy link
Member

teto commented Dec 24, 2020

I am not sure yet but it would be nice to keep the lua grammar ( https://github.com/nvim-treesitter/tree-sitter-lua ): neovim may require it for its 0.5 release.

@Profpatsch
Copy link
Member Author

I am unsure how the lua grammar was added, since the update script would definitely not keep it.

We are going to have to add a list of extra grammars to the updater.

@Profpatsch
Copy link
Member Author

neovim may require it for its 0.5 release.

As in, it would want a dependency?
Before we depend on it from within nixpkgs, I’d make sure the build we expose has a at least somewhat stable API that is easy to integrate. Right now the grammars only get a $out/parser executable, I don’t know if that is enough.

@teto
Copy link
Member

teto commented Dec 24, 2020

It may become a dependency, it has not been decided yet. Even without I would like to keep it. Maybe it can be defined somewhere else to make it clear it's not automatically updated.

@Profpatsch
Copy link
Member Author

Maybe it can be defined somewhere else to make it clear it's not automatically updated.

it should definitely be automatically updated

@Profpatsch
Copy link
Member Author

It’s easy to add, let me take a look.

@SuperSandro2000
Copy link
Member

Result of nixpkgs-review pr 107514 run on x86_64-darwin 1

1 package built:
  • tree-sitter

@SuperSandro2000
Copy link
Member

Result of nixpkgs-review pr 107514 run on x86_64-linux 1

1 package built:
  • tree-sitter

The update script would only fetch the few grammars listed in the
tree-sitter repository previously. But the tree-sitter github orga has
a rather large amount of officially supported grammars.

Thus we change the script to query the github APIs for repositories
instead (up to 100 this is supported without paging).

Since the repository list also contains some that are not grammars,
there is a bash script which lists all repos we are aware of and the
ones we want to ignore. It will make sure we don’t forget any
repositories in the future, by comparing to the actual list with jq.
The new update scripts gives us a bunch of new grammars!
We want the ability to add different orga repos as well, and that is a
lot easier on the nix level.
Some of the grammars are not in the official orga, like
tree-sitter-lua, so we make sure the updater knows how to fetch them.
@Profpatsch
Copy link
Member Author

@teto I refactored a little, now we can add more repositories that are not from the tree-sitter orga.

@teto
Copy link
Member

teto commented Dec 29, 2020

The configuration is scattered through several whiltelists/orgs, my approach would have been to put a single list with the different attributes (organisation, ignore etc) but as long as it works, it's fine. Feel free to merge when ready.

@Profpatsch
Copy link
Member Author

my approach would have been to put a single list with the different attributes (organisation, ignore etc) but as long as it works, it's fine. Feel free to merge when ready.

We want the tree-sitter org grammars to be complete always, this is why they are handled specially, because the update script checks whether we missed a repo.

@Profpatsch Profpatsch merged commit d5deb8c into NixOS:master Dec 30, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants