2021-12-21 02:18:32 +00:00
|
|
|
{ writeShellScript
|
2022-11-04 12:27:35 +00:00
|
|
|
, writeText
|
|
|
|
, writers
|
2021-12-21 02:18:32 +00:00
|
|
|
, nix-prefetch-git
|
|
|
|
, formats
|
|
|
|
, lib
|
2022-11-04 12:27:35 +00:00
|
|
|
, coreutils
|
2021-12-21 02:18:32 +00:00
|
|
|
, curl
|
|
|
|
, xe
|
|
|
|
}:
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2021-03-16 09:55:35 +00:00
|
|
|
# Grammar list:
|
|
|
|
# https://github.com/tree-sitter/tree-sitter/blob/master/docs/index.md
|
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
let
|
2021-01-05 17:05:55 +00:00
|
|
|
# Grammars we want to fetch from the tree-sitter github orga
|
|
|
|
knownTreeSitterOrgGrammarRepos = [
|
|
|
|
"tree-sitter-javascript"
|
|
|
|
"tree-sitter-c"
|
|
|
|
"tree-sitter-json"
|
|
|
|
"tree-sitter-cpp"
|
|
|
|
"tree-sitter-ruby"
|
|
|
|
"tree-sitter-go"
|
|
|
|
"tree-sitter-c-sharp"
|
|
|
|
"tree-sitter-python"
|
|
|
|
"tree-sitter-typescript"
|
|
|
|
"tree-sitter-rust"
|
|
|
|
"tree-sitter-bash"
|
|
|
|
"tree-sitter-php"
|
|
|
|
"tree-sitter-java"
|
|
|
|
"tree-sitter-scala"
|
|
|
|
"tree-sitter-ocaml"
|
|
|
|
"tree-sitter-julia"
|
|
|
|
"tree-sitter-html"
|
|
|
|
"tree-sitter-haskell"
|
|
|
|
"tree-sitter-regex"
|
|
|
|
"tree-sitter-css"
|
|
|
|
"tree-sitter-verilog"
|
|
|
|
"tree-sitter-jsdoc"
|
|
|
|
"tree-sitter-ql"
|
2022-09-09 14:08:57 +00:00
|
|
|
"tree-sitter-ql-dbscheme"
|
2021-01-05 17:05:55 +00:00
|
|
|
"tree-sitter-embedded-template"
|
2021-05-28 09:39:13 +00:00
|
|
|
"tree-sitter-tsq"
|
2022-04-27 09:35:20 +00:00
|
|
|
"tree-sitter-toml"
|
2021-01-05 17:05:55 +00:00
|
|
|
];
|
|
|
|
knownTreeSitterOrgGrammarReposJson = jsonFile "known-tree-sitter-org-grammar-repos" knownTreeSitterOrgGrammarRepos;
|
|
|
|
|
|
|
|
# repos of the tree-sitter github orga we want to ignore (not grammars)
|
|
|
|
ignoredTreeSitterOrgRepos = [
|
|
|
|
"tree-sitter"
|
|
|
|
"tree-sitter-cli"
|
|
|
|
# this is the haskell language bindings, tree-sitter-haskell is the grammar
|
|
|
|
"haskell-tree-sitter"
|
|
|
|
# this is the ruby language bindings, tree-sitter-ruby is the grammar
|
2022-10-21 18:38:19 +00:00
|
|
|
"ruby-tree-sitter.old"
|
2021-01-05 17:05:55 +00:00
|
|
|
# this is the (unmaintained) rust language bindings, tree-sitter-rust is the grammar
|
|
|
|
"rust-tree-sitter"
|
|
|
|
# this is the nodejs language bindings, tree-sitter-javascript is the grammar
|
|
|
|
"node-tree-sitter"
|
|
|
|
# this is the python language bindings, tree-sitter-python is the grammar
|
|
|
|
"py-tree-sitter"
|
|
|
|
# afl fuzzing for tree sitter
|
|
|
|
"afl-tree-sitter"
|
|
|
|
# archived
|
|
|
|
"highlight-schema"
|
|
|
|
# website
|
|
|
|
"tree-sitter.github.io"
|
2021-03-16 09:55:35 +00:00
|
|
|
# not maintained
|
|
|
|
"tree-sitter-razor"
|
2021-05-28 09:39:13 +00:00
|
|
|
# rust library for constructing arbitrary graph structures from source code
|
|
|
|
"tree-sitter-graph"
|
2022-06-16 17:23:12 +00:00
|
|
|
# abandoned
|
|
|
|
"tree-sitter-swift"
|
2022-11-21 17:40:18 +00:00
|
|
|
# abandoned
|
|
|
|
"tree-sitter-agda"
|
|
|
|
# abandoned
|
|
|
|
"tree-sitter-fluent"
|
2024-01-02 11:29:13 +00:00
|
|
|
# to unblock my update
|
|
|
|
"csharp-tree-sitter"
|
2024-04-21 15:54:59 +00:00
|
|
|
|
|
|
|
# Non-grammar repositories
|
|
|
|
".github"
|
|
|
|
"fuzz-action"
|
|
|
|
"parse-action"
|
|
|
|
"parser-setup-action"
|
|
|
|
"parser-test-action"
|
|
|
|
"parser-update-action"
|
|
|
|
"setup-action"
|
|
|
|
"workflows"
|
2021-01-05 17:05:55 +00:00
|
|
|
];
|
|
|
|
ignoredTreeSitterOrgReposJson = jsonFile "ignored-tree-sitter-org-repos" ignoredTreeSitterOrgRepos;
|
|
|
|
|
|
|
|
# Additional grammars that are not in the official github orga.
|
|
|
|
# If you need a grammar that already exists in the official orga,
|
|
|
|
# make sure to give it a different name.
|
|
|
|
otherGrammars = {
|
2024-01-02 11:29:13 +00:00
|
|
|
"tree-sitter-bitbake" = {
|
|
|
|
orga = "amaanq";
|
|
|
|
repo = "tree-sitter-bitbake";
|
|
|
|
};
|
2021-12-06 16:07:01 +00:00
|
|
|
"tree-sitter-beancount" = {
|
|
|
|
orga = "polarmutex";
|
|
|
|
repo = "tree-sitter-beancount";
|
|
|
|
};
|
2021-09-22 15:38:15 +00:00
|
|
|
"tree-sitter-clojure" = {
|
|
|
|
orga = "sogaiu";
|
|
|
|
repo = "tree-sitter-clojure";
|
|
|
|
};
|
2021-08-08 23:34:03 +00:00
|
|
|
"tree-sitter-comment" = {
|
|
|
|
orga = "stsewd";
|
|
|
|
repo = "tree-sitter-comment";
|
|
|
|
};
|
2021-09-22 15:38:15 +00:00
|
|
|
"tree-sitter-dart" = {
|
|
|
|
orga = "usernobody14";
|
|
|
|
repo = "tree-sitter-dart";
|
|
|
|
};
|
|
|
|
"tree-sitter-elisp" = {
|
|
|
|
orga = "wilfred";
|
|
|
|
repo = "tree-sitter-elisp";
|
|
|
|
};
|
2024-01-25 14:12:00 +00:00
|
|
|
"tree-sitter-just" = {
|
|
|
|
orga = "IndianBoy42";
|
|
|
|
repo = "tree-sitter-just";
|
|
|
|
};
|
2021-01-17 00:15:33 +00:00
|
|
|
"tree-sitter-nix" = {
|
|
|
|
orga = "cstrahan";
|
|
|
|
repo = "tree-sitter-nix";
|
|
|
|
};
|
2021-07-14 22:03:04 +00:00
|
|
|
"tree-sitter-latex" = {
|
|
|
|
orga = "latex-lsp";
|
|
|
|
repo = "tree-sitter-latex";
|
|
|
|
};
|
2021-01-05 17:05:55 +00:00
|
|
|
"tree-sitter-lua" = {
|
2022-01-27 00:19:43 +00:00
|
|
|
orga = "MunifTanjim";
|
2021-01-05 17:05:55 +00:00
|
|
|
repo = "tree-sitter-lua";
|
|
|
|
};
|
2021-03-16 09:55:35 +00:00
|
|
|
"tree-sitter-fennel" = {
|
|
|
|
orga = "travonted";
|
|
|
|
repo = "tree-sitter-fennel";
|
|
|
|
};
|
2021-10-17 02:12:59 +00:00
|
|
|
"tree-sitter-make" = {
|
|
|
|
orga = "alemuller";
|
|
|
|
repo = "tree-sitter-make";
|
|
|
|
};
|
2021-03-16 09:55:35 +00:00
|
|
|
"tree-sitter-markdown" = {
|
2022-01-26 04:04:25 +00:00
|
|
|
orga = "MDeiml";
|
2021-03-16 09:55:35 +00:00
|
|
|
repo = "tree-sitter-markdown";
|
|
|
|
};
|
2023-10-19 13:55:26 +00:00
|
|
|
"tree-sitter-proto" = {
|
|
|
|
orga = "mitchellh";
|
|
|
|
repo = "tree-sitter-proto";
|
|
|
|
};
|
2022-06-16 17:23:12 +00:00
|
|
|
"tree-sitter-rego" = {
|
|
|
|
orga = "FallenAngel97";
|
|
|
|
repo = "tree-sitter-rego";
|
|
|
|
};
|
2021-09-22 15:38:15 +00:00
|
|
|
"tree-sitter-rst" = {
|
|
|
|
orga = "stsewd";
|
|
|
|
repo = "tree-sitter-rst";
|
|
|
|
};
|
2021-03-16 09:55:35 +00:00
|
|
|
"tree-sitter-svelte" = {
|
|
|
|
orga = "Himujjal";
|
|
|
|
repo = "tree-sitter-svelte";
|
|
|
|
};
|
2022-06-16 17:23:12 +00:00
|
|
|
"tree-sitter-sql" = {
|
2022-11-21 17:40:18 +00:00
|
|
|
orga = "derekstride";
|
2022-06-16 17:23:12 +00:00
|
|
|
repo = "tree-sitter-sql";
|
2023-07-15 17:15:38 +00:00
|
|
|
branch = "gh-pages";
|
2022-06-16 17:23:12 +00:00
|
|
|
};
|
2024-04-21 15:54:59 +00:00
|
|
|
"tree-sitter-talon" = {
|
|
|
|
orga = "wenkokke";
|
|
|
|
repo = "tree-sitter-talon";
|
|
|
|
};
|
2023-10-09 19:29:22 +00:00
|
|
|
"tree-sitter-typst" = {
|
|
|
|
orga = "uben0";
|
|
|
|
repo = "tree-sitter-typst";
|
|
|
|
};
|
2021-09-22 15:38:15 +00:00
|
|
|
"tree-sitter-vim" = {
|
|
|
|
orga = "vigoux";
|
|
|
|
repo = "tree-sitter-viml";
|
|
|
|
};
|
2021-03-16 09:55:35 +00:00
|
|
|
"tree-sitter-yaml" = {
|
|
|
|
orga = "ikatyang";
|
|
|
|
repo = "tree-sitter-yaml";
|
|
|
|
};
|
2021-05-28 09:39:13 +00:00
|
|
|
"tree-sitter-zig" = {
|
2021-09-22 15:38:15 +00:00
|
|
|
orga = "maxxnino";
|
2021-05-28 09:39:13 +00:00
|
|
|
repo = "tree-sitter-zig";
|
|
|
|
};
|
2021-08-08 23:34:03 +00:00
|
|
|
"tree-sitter-fish" = {
|
|
|
|
orga = "ram02z";
|
|
|
|
repo = "tree-sitter-fish";
|
|
|
|
};
|
2021-09-18 10:52:07 +00:00
|
|
|
"tree-sitter-dot" = {
|
|
|
|
orga = "rydesun";
|
|
|
|
repo = "tree-sitter-dot";
|
|
|
|
};
|
2021-10-01 09:20:50 +00:00
|
|
|
"tree-sitter-norg" = {
|
|
|
|
orga = "nvim-neorg";
|
|
|
|
repo = "tree-sitter-norg";
|
|
|
|
};
|
2024-01-02 11:29:13 +00:00
|
|
|
"tree-sitter-norg-meta" = {
|
|
|
|
orga = "nvim-neorg";
|
|
|
|
repo = "tree-sitter-norg-meta";
|
|
|
|
};
|
2021-12-21 02:18:32 +00:00
|
|
|
"tree-sitter-commonlisp" = {
|
|
|
|
orga = "thehamsta";
|
|
|
|
repo = "tree-sitter-commonlisp";
|
|
|
|
};
|
|
|
|
"tree-sitter-cuda" = {
|
|
|
|
orga = "thehamsta";
|
|
|
|
repo = "tree-sitter-cuda";
|
|
|
|
};
|
|
|
|
"tree-sitter-glsl" = {
|
|
|
|
orga = "thehamsta";
|
|
|
|
repo = "tree-sitter-glsl";
|
|
|
|
};
|
|
|
|
"tree-sitter-dockerfile" = {
|
|
|
|
orga = "camdencheek";
|
|
|
|
repo = "tree-sitter-dockerfile";
|
|
|
|
};
|
|
|
|
"tree-sitter-ledger" = {
|
|
|
|
orga = "cbarrete";
|
|
|
|
repo = "tree-sitter-ledger";
|
|
|
|
};
|
|
|
|
"tree-sitter-gomod" = {
|
|
|
|
orga = "camdencheek";
|
|
|
|
repo = "tree-sitter-go-mod";
|
|
|
|
};
|
2022-06-16 17:23:12 +00:00
|
|
|
"tree-sitter-gowork" = {
|
|
|
|
orga = "omertuc";
|
|
|
|
repo = "tree-sitter-go-work";
|
|
|
|
};
|
2021-12-21 02:18:32 +00:00
|
|
|
"tree-sitter-graphql" = {
|
|
|
|
orga = "bkegley";
|
|
|
|
repo = "tree-sitter-graphql";
|
|
|
|
};
|
2022-04-27 09:35:20 +00:00
|
|
|
"tree-sitter-pgn" = {
|
|
|
|
orga = "rolandwalker";
|
|
|
|
repo = "tree-sitter-pgn";
|
|
|
|
};
|
2021-12-21 02:18:32 +00:00
|
|
|
"tree-sitter-perl" = {
|
|
|
|
orga = "ganezdragon";
|
|
|
|
repo = "tree-sitter-perl";
|
|
|
|
};
|
|
|
|
"tree-sitter-kotlin" = {
|
|
|
|
orga = "fwcd";
|
|
|
|
repo = "tree-sitter-kotlin";
|
|
|
|
};
|
|
|
|
"tree-sitter-scss" = {
|
|
|
|
orga = "serenadeai";
|
|
|
|
repo = "tree-sitter-scss";
|
|
|
|
};
|
|
|
|
"tree-sitter-erlang" = {
|
|
|
|
orga = "abstractmachineslab";
|
|
|
|
repo = "tree-sitter-erlang";
|
|
|
|
};
|
|
|
|
"tree-sitter-elixir" = {
|
|
|
|
orga = "elixir-lang";
|
|
|
|
repo = "tree-sitter-elixir";
|
|
|
|
};
|
|
|
|
"tree-sitter-surface" = {
|
|
|
|
orga = "connorlay";
|
|
|
|
repo = "tree-sitter-surface";
|
|
|
|
};
|
2022-11-04 12:27:35 +00:00
|
|
|
"tree-sitter-eex" = {
|
|
|
|
orga = "connorlay";
|
|
|
|
repo = "tree-sitter-eex";
|
|
|
|
};
|
2021-12-21 02:18:32 +00:00
|
|
|
"tree-sitter-heex" = {
|
|
|
|
orga = "connorlay";
|
|
|
|
repo = "tree-sitter-heex";
|
|
|
|
};
|
|
|
|
"tree-sitter-supercollider" = {
|
|
|
|
orga = "madskjeldgaard";
|
|
|
|
repo = "tree-sitter-supercollider";
|
|
|
|
};
|
|
|
|
"tree-sitter-tlaplus" = {
|
|
|
|
orga = "tlaplus-community";
|
|
|
|
repo = "tree-sitter-tlaplus";
|
|
|
|
};
|
|
|
|
"tree-sitter-glimmer" = {
|
|
|
|
orga = "alexlafroscia";
|
|
|
|
repo = "tree-sitter-glimmer";
|
|
|
|
};
|
|
|
|
"tree-sitter-pug" = {
|
|
|
|
orga = "zealot128";
|
|
|
|
repo = "tree-sitter-pug";
|
|
|
|
};
|
|
|
|
"tree-sitter-vue" = {
|
|
|
|
orga = "ikatyang";
|
|
|
|
repo = "tree-sitter-vue";
|
|
|
|
};
|
|
|
|
"tree-sitter-elm" = {
|
|
|
|
orga = "elm-tooling";
|
|
|
|
repo = "tree-sitter-elm";
|
|
|
|
};
|
|
|
|
"tree-sitter-yang" = {
|
|
|
|
orga = "hubro";
|
|
|
|
repo = "tree-sitter-yang";
|
|
|
|
};
|
|
|
|
"tree-sitter-query" = {
|
|
|
|
orga = "nvim-treesitter";
|
|
|
|
repo = "tree-sitter-query";
|
|
|
|
};
|
|
|
|
"tree-sitter-sparql" = {
|
|
|
|
orga = "bonabeavis";
|
|
|
|
repo = "tree-sitter-sparql";
|
|
|
|
};
|
|
|
|
"tree-sitter-gdscript" = {
|
|
|
|
orga = "prestonknopp";
|
|
|
|
repo = "tree-sitter-gdscript";
|
|
|
|
};
|
|
|
|
"tree-sitter-godot-resource" = {
|
|
|
|
orga = "prestonknopp";
|
|
|
|
repo = "tree-sitter-godot-resource";
|
|
|
|
};
|
|
|
|
"tree-sitter-turtle" = {
|
|
|
|
orga = "bonabeavis";
|
|
|
|
repo = "tree-sitter-turtle";
|
|
|
|
};
|
|
|
|
"tree-sitter-devicetree" = {
|
|
|
|
orga = "joelspadin";
|
|
|
|
repo = "tree-sitter-devicetree";
|
|
|
|
};
|
|
|
|
"tree-sitter-r" = {
|
|
|
|
orga = "r-lib";
|
|
|
|
repo = "tree-sitter-r";
|
|
|
|
};
|
|
|
|
"tree-sitter-bibtex" = {
|
|
|
|
orga = "latex-lsp";
|
|
|
|
repo = "tree-sitter-bibtex";
|
|
|
|
};
|
|
|
|
"tree-sitter-fortran" = {
|
|
|
|
orga = "stadelmanma";
|
|
|
|
repo = "tree-sitter-fortran";
|
|
|
|
};
|
|
|
|
"tree-sitter-cmake" = {
|
|
|
|
orga = "uyha";
|
|
|
|
repo = "tree-sitter-cmake";
|
|
|
|
};
|
2022-04-27 09:35:20 +00:00
|
|
|
"tree-sitter-janet-simple" = {
|
|
|
|
orga = "sogaiu";
|
|
|
|
repo = "tree-sitter-janet-simple";
|
|
|
|
};
|
2021-12-21 02:18:32 +00:00
|
|
|
"tree-sitter-json5" = {
|
|
|
|
orga = "joakker";
|
|
|
|
repo = "tree-sitter-json5";
|
|
|
|
};
|
|
|
|
"tree-sitter-pioasm" = {
|
|
|
|
orga = "leo60228";
|
|
|
|
repo = "tree-sitter-pioasm";
|
|
|
|
};
|
|
|
|
"tree-sitter-hjson" = {
|
|
|
|
orga = "winston0410";
|
|
|
|
repo = "tree-sitter-hjson";
|
|
|
|
};
|
|
|
|
"tree-sitter-llvm" = {
|
|
|
|
orga = "benwilliamgraham";
|
|
|
|
repo = "tree-sitter-llvm";
|
|
|
|
};
|
|
|
|
"tree-sitter-http" = {
|
|
|
|
orga = "ntbbloodbath";
|
|
|
|
repo = "tree-sitter-http";
|
|
|
|
};
|
|
|
|
"tree-sitter-prisma" = {
|
|
|
|
orga = "victorhqc";
|
|
|
|
repo = "tree-sitter-prisma";
|
|
|
|
};
|
2022-02-10 20:34:41 +00:00
|
|
|
"tree-sitter-org-nvim" = {
|
2022-01-22 01:22:15 +00:00
|
|
|
orga = "milisims";
|
|
|
|
repo = "tree-sitter-org";
|
|
|
|
};
|
2022-03-30 09:31:56 +00:00
|
|
|
"tree-sitter-hcl" = {
|
|
|
|
orga = "MichaHoffmann";
|
|
|
|
repo = "tree-sitter-hcl";
|
|
|
|
};
|
2022-04-27 09:35:20 +00:00
|
|
|
"tree-sitter-scheme" = {
|
|
|
|
orga = "6cdh";
|
|
|
|
repo = "tree-sitter-scheme";
|
|
|
|
};
|
2022-06-16 17:23:12 +00:00
|
|
|
"tree-sitter-tiger" = {
|
|
|
|
orga = "ambroisie";
|
|
|
|
repo = "tree-sitter-tiger";
|
|
|
|
};
|
2022-09-22 12:36:57 +00:00
|
|
|
"tree-sitter-nickel" = {
|
|
|
|
orga = "nickel-lang";
|
|
|
|
repo = "tree-sitter-nickel";
|
|
|
|
};
|
2022-09-30 11:47:45 +00:00
|
|
|
"tree-sitter-smithy" = {
|
|
|
|
orga = "indoorvivants";
|
|
|
|
repo = "tree-sitter-smithy";
|
|
|
|
};
|
2022-10-21 18:38:19 +00:00
|
|
|
"tree-sitter-jsonnet" = {
|
|
|
|
orga = "sourcegraph";
|
|
|
|
repo = "tree-sitter-jsonnet";
|
|
|
|
};
|
2023-04-12 12:48:02 +00:00
|
|
|
"tree-sitter-solidity" = {
|
|
|
|
orga = "JoranHonig";
|
|
|
|
repo = "tree-sitter-solidity";
|
|
|
|
};
|
2023-04-29 16:46:19 +00:00
|
|
|
"tree-sitter-nu" = {
|
2024-01-02 11:29:13 +00:00
|
|
|
orga = "nushell";
|
2023-04-29 16:46:19 +00:00
|
|
|
repo = "tree-sitter-nu";
|
|
|
|
};
|
2023-07-15 17:15:38 +00:00
|
|
|
"tree-sitter-cue" = {
|
|
|
|
orga = "eonpatapon";
|
|
|
|
repo = "tree-sitter-cue";
|
|
|
|
};
|
2024-01-02 11:29:13 +00:00
|
|
|
"tree-sitter-uiua" = {
|
|
|
|
orga = "shnarazk";
|
|
|
|
repo = "tree-sitter-uiua";
|
|
|
|
};
|
2023-07-15 17:15:38 +00:00
|
|
|
"tree-sitter-wing" = {
|
|
|
|
orga = "winglang";
|
|
|
|
repo = "wing";
|
|
|
|
};
|
2023-11-16 04:20:00 +00:00
|
|
|
"tree-sitter-wgsl" = {
|
|
|
|
orga = "szebniok";
|
|
|
|
repo = "tree-sitter-wgsl";
|
|
|
|
};
|
2024-02-07 01:22:34 +00:00
|
|
|
"tree-sitter-templ" = {
|
|
|
|
orga = "vrischmann";
|
|
|
|
repo = "tree-sitter-templ";
|
|
|
|
};
|
2024-04-21 15:54:59 +00:00
|
|
|
"tree-sitter-gleam" = {
|
|
|
|
orga = "gleam-lang";
|
|
|
|
repo = "tree-sitter-gleam";
|
|
|
|
};
|
|
|
|
"tree-sitter-koka" = {
|
|
|
|
orga = "mtoohey31";
|
|
|
|
repo = "tree-sitter-koka";
|
|
|
|
};
|
|
|
|
"tree-sitter-earthfile" = {
|
|
|
|
orga = "glehmann";
|
|
|
|
repo = "tree-sitter-earthfile";
|
|
|
|
};
|
2021-01-05 17:05:55 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
allGrammars =
|
|
|
|
let
|
|
|
|
treeSitterOrgaGrammars =
|
2021-12-21 02:18:32 +00:00
|
|
|
lib.listToAttrs (map
|
|
|
|
(repo:
|
|
|
|
{
|
|
|
|
name = repo;
|
|
|
|
value = {
|
|
|
|
orga = "tree-sitter";
|
|
|
|
inherit repo;
|
|
|
|
};
|
|
|
|
})
|
|
|
|
knownTreeSitterOrgGrammarRepos);
|
2021-01-05 17:05:55 +00:00
|
|
|
|
|
|
|
in
|
2022-12-28 21:21:41 +00:00
|
|
|
lib.attrsets.unionOfDisjoint otherGrammars treeSitterOrgaGrammars;
|
2021-01-05 17:05:55 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
2021-12-21 02:18:32 +00:00
|
|
|
jsonFile = name: val: (formats.json { }).generate name val;
|
2021-01-05 17:05:55 +00:00
|
|
|
|
2022-11-04 12:27:35 +00:00
|
|
|
# implementation of the updater
|
2023-10-19 13:55:26 +00:00
|
|
|
updateImpl = passArgs "updateImpl-with-args"
|
|
|
|
{
|
2022-11-04 12:27:35 +00:00
|
|
|
binaries = {
|
|
|
|
curl = "${curl}/bin/curl";
|
|
|
|
nix-prefetch-git = "${nix-prefetch-git}/bin/nix-prefetch-git";
|
|
|
|
printf = "${coreutils}/bin/printf";
|
|
|
|
};
|
|
|
|
inherit
|
|
|
|
knownTreeSitterOrgGrammarRepos
|
|
|
|
ignoredTreeSitterOrgRepos
|
|
|
|
;
|
|
|
|
}
|
2023-10-19 13:55:26 +00:00
|
|
|
(writers.writePython3 "updateImpl"
|
|
|
|
{
|
|
|
|
flakeIgnore = [ "E501" ];
|
|
|
|
} ./update_impl.py);
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2022-11-04 12:27:35 +00:00
|
|
|
# Pass the given arguments to the command, in the ARGS environment variable.
|
|
|
|
# The arguments are just a json object that should be available in the script.
|
|
|
|
passArgs = name: argAttrs: script: writeShellScript name ''
|
|
|
|
env ARGS="$(< ${jsonFile "${name}-args" argAttrs})" \
|
|
|
|
${script} "$@"
|
2020-04-24 23:36:52 +00:00
|
|
|
'';
|
|
|
|
|
2022-11-04 12:27:35 +00:00
|
|
|
foreachSh = attrs: f:
|
|
|
|
lib.concatMapStringsSep "\n" f
|
|
|
|
(lib.mapAttrsToList (k: v: { name = k; } // v) attrs);
|
2021-01-05 17:05:55 +00:00
|
|
|
|
2023-10-19 13:55:26 +00:00
|
|
|
jsonNewlines = lib.concatMapStringsSep "\n" (lib.generators.toJSON { });
|
2021-01-05 17:05:55 +00:00
|
|
|
|
2022-11-04 12:27:35 +00:00
|
|
|
# Run the given script for each of the attr list.
|
|
|
|
# The attrs are passed to the script as a json value.
|
|
|
|
forEachParallel = name: script: listOfAttrs: writeShellScript "for-each-parallel.sh" ''
|
|
|
|
< ${writeText "${name}.json" (jsonNewlines listOfAttrs)} \
|
|
|
|
${xe}/bin/xe -F -j5 ${script} {}
|
2021-01-05 17:05:55 +00:00
|
|
|
'';
|
|
|
|
|
2022-11-04 12:27:35 +00:00
|
|
|
# The output directory in the current source tree.
|
|
|
|
# This will depend on your local environment, but that is intentional.
|
|
|
|
outputDir = "${toString ./.}/grammars";
|
2021-01-05 17:05:55 +00:00
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
update-all-grammars = writeShellScript "update-all-grammars.sh" ''
|
2023-10-19 13:55:26 +00:00
|
|
|
set -euo pipefail
|
|
|
|
${updateImpl} fetch-and-check-tree-sitter-repos '{}'
|
|
|
|
echo "writing files to ${outputDir}" 1>&2
|
|
|
|
mkdir -p "${outputDir}"
|
|
|
|
${forEachParallel
|
|
|
|
"repos-to-fetch"
|
|
|
|
(writeShellScript "fetch-repo" ''
|
|
|
|
${updateImpl} fetch-repo "$1"
|
|
|
|
'')
|
|
|
|
(lib.mapAttrsToList
|
|
|
|
(nixRepoAttrName: attrs: attrs // {
|
|
|
|
inherit
|
|
|
|
nixRepoAttrName
|
|
|
|
outputDir;
|
|
|
|
})
|
|
|
|
allGrammars)
|
|
|
|
}
|
|
|
|
${updateImpl} print-all-grammars-nix-file "$(< ${
|
|
|
|
jsonFile "all-grammars.json" {
|
|
|
|
allGrammars =
|
|
|
|
(lib.mapAttrsToList
|
|
|
|
(nixRepoAttrName: attrs: attrs // {
|
|
|
|
inherit nixRepoAttrName;
|
|
|
|
})
|
|
|
|
allGrammars);
|
|
|
|
inherit outputDir;
|
|
|
|
}
|
|
|
|
})"
|
2020-04-24 23:36:52 +00:00
|
|
|
'';
|
|
|
|
|
2022-11-04 12:27:35 +00:00
|
|
|
|
2021-12-21 02:18:32 +00:00
|
|
|
in
|
|
|
|
update-all-grammars
|