13 # https://github.com/tree-sitter/tree-sitter/blob/master/docs/index.md
16 # Grammars we want to fetch from the tree-sitter github orga
17 knownTreeSitterOrgGrammarRepos = [
18 "tree-sitter-javascript"
26 "tree-sitter-typescript"
41 "tree-sitter-ql-dbscheme"
42 "tree-sitter-embedded-template"
46 knownTreeSitterOrgGrammarReposJson = jsonFile "known-tree-sitter-org-grammar-repos" knownTreeSitterOrgGrammarRepos;
48 # repos of the tree-sitter github orga we want to ignore (not grammars)
49 ignoredTreeSitterOrgRepos = [
52 # this is the haskell language bindings, tree-sitter-haskell is the grammar
54 # this is the ruby language bindings, tree-sitter-ruby is the grammar
55 "ruby-tree-sitter.old"
56 # this is the (unmaintained) rust language bindings, tree-sitter-rust is the grammar
58 # this is the nodejs language bindings, tree-sitter-javascript is the grammar
60 # this is the python language bindings, tree-sitter-python is the grammar
62 # afl fuzzing for tree sitter
64 # this is the kotlin language bindings, tree-sitter-kotlin is the grammar
66 # this is the go language bindings, tree-sitter-go is the grammar
68 # this is the java language bindings, tree-sitter-java is the grammar
73 "tree-sitter.github.io"
76 # rust library for constructing arbitrary graph structures from source code
84 # to unblock my update
86 # (experimental) java bindings to the Tree-sitter parsing library
88 # go bindings to the Tree-sitter parsing library
90 # kotlin bindings to the Tree-sitter parsing library
92 # not ready to be used
96 # Non-grammar repositories
100 "parser-setup-action"
102 "parser-update-action"
106 ignoredTreeSitterOrgReposJson = jsonFile "ignored-tree-sitter-org-repos" ignoredTreeSitterOrgRepos;
108 # Additional grammars that are not in the official github orga.
109 # If you need a grammar that already exists in the official orga,
110 # make sure to give it a different name.
112 "tree-sitter-bitbake" = {
114 repo = "tree-sitter-bitbake";
116 "tree-sitter-beancount" = {
118 repo = "tree-sitter-beancount";
120 "tree-sitter-bqn" = {
122 repo = "tree-sitter-bqn";
124 "tree-sitter-clojure" = {
126 repo = "tree-sitter-clojure";
128 "tree-sitter-comment" = {
130 repo = "tree-sitter-comment";
132 "tree-sitter-dart" = {
133 orga = "usernobody14";
134 repo = "tree-sitter-dart";
136 "tree-sitter-elisp" = {
138 repo = "tree-sitter-elisp";
140 "tree-sitter-just" = {
141 orga = "IndianBoy42";
142 repo = "tree-sitter-just";
144 "tree-sitter-nix" = {
146 repo = "tree-sitter-nix";
148 "tree-sitter-latex" = {
150 repo = "tree-sitter-latex";
152 "tree-sitter-lua" = {
153 orga = "MunifTanjim";
154 repo = "tree-sitter-lua";
156 "tree-sitter-fennel" = {
158 repo = "tree-sitter-fennel";
160 "tree-sitter-make" = {
162 repo = "tree-sitter-make";
164 "tree-sitter-markdown" = {
166 repo = "tree-sitter-markdown";
168 "tree-sitter-proto" = {
170 repo = "tree-sitter-proto";
172 "tree-sitter-rego" = {
173 orga = "FallenAngel97";
174 repo = "tree-sitter-rego";
176 "tree-sitter-rst" = {
178 repo = "tree-sitter-rst";
180 "tree-sitter-svelte" = {
182 repo = "tree-sitter-svelte";
184 "tree-sitter-sql" = {
185 orga = "derekstride";
186 repo = "tree-sitter-sql";
189 "tree-sitter-talon" = {
191 repo = "tree-sitter-talon";
193 "tree-sitter-typst" = {
195 repo = "tree-sitter-typst";
197 "tree-sitter-vim" = {
199 repo = "tree-sitter-viml";
201 "tree-sitter-yaml" = {
203 repo = "tree-sitter-yaml";
205 "tree-sitter-zig" = {
207 repo = "tree-sitter-zig";
209 "tree-sitter-fish" = {
211 repo = "tree-sitter-fish";
213 "tree-sitter-dot" = {
215 repo = "tree-sitter-dot";
217 "tree-sitter-norg" = {
219 repo = "tree-sitter-norg";
221 "tree-sitter-norg-meta" = {
223 repo = "tree-sitter-norg-meta";
225 "tree-sitter-commonlisp" = {
227 repo = "tree-sitter-commonlisp";
229 "tree-sitter-cuda" = {
231 repo = "tree-sitter-cuda";
233 "tree-sitter-glsl" = {
235 repo = "tree-sitter-glsl";
237 "tree-sitter-dockerfile" = {
238 orga = "camdencheek";
239 repo = "tree-sitter-dockerfile";
241 "tree-sitter-ledger" = {
243 repo = "tree-sitter-ledger";
245 "tree-sitter-gomod" = {
246 orga = "camdencheek";
247 repo = "tree-sitter-go-mod";
249 "tree-sitter-gowork" = {
251 repo = "tree-sitter-go-work";
253 "tree-sitter-graphql" = {
255 repo = "tree-sitter-graphql";
257 "tree-sitter-pgn" = {
258 orga = "rolandwalker";
259 repo = "tree-sitter-pgn";
261 "tree-sitter-perl" = {
262 orga = "ganezdragon";
263 repo = "tree-sitter-perl";
265 "tree-sitter-kotlin" = {
267 repo = "tree-sitter-kotlin";
269 "tree-sitter-scss" = {
271 repo = "tree-sitter-scss";
273 "tree-sitter-erlang" = {
274 orga = "abstractmachineslab";
275 repo = "tree-sitter-erlang";
277 "tree-sitter-elixir" = {
278 orga = "elixir-lang";
279 repo = "tree-sitter-elixir";
281 "tree-sitter-surface" = {
283 repo = "tree-sitter-surface";
285 "tree-sitter-eex" = {
287 repo = "tree-sitter-eex";
289 "tree-sitter-heex" = {
291 repo = "tree-sitter-heex";
293 "tree-sitter-supercollider" = {
294 orga = "madskjeldgaard";
295 repo = "tree-sitter-supercollider";
297 "tree-sitter-tlaplus" = {
298 orga = "tlaplus-community";
299 repo = "tree-sitter-tlaplus";
301 "tree-sitter-glimmer" = {
302 orga = "alexlafroscia";
303 repo = "tree-sitter-glimmer";
305 "tree-sitter-pug" = {
307 repo = "tree-sitter-pug";
309 "tree-sitter-vue" = {
311 repo = "tree-sitter-vue";
313 "tree-sitter-elm" = {
314 orga = "elm-tooling";
315 repo = "tree-sitter-elm";
317 "tree-sitter-yang" = {
319 repo = "tree-sitter-yang";
321 "tree-sitter-query" = {
322 orga = "nvim-treesitter";
323 repo = "tree-sitter-query";
325 "tree-sitter-sparql" = {
327 repo = "tree-sitter-sparql";
329 "tree-sitter-gdscript" = {
330 orga = "prestonknopp";
331 repo = "tree-sitter-gdscript";
333 "tree-sitter-godot-resource" = {
334 orga = "prestonknopp";
335 repo = "tree-sitter-godot-resource";
337 "tree-sitter-turtle" = {
339 repo = "tree-sitter-turtle";
341 "tree-sitter-devicetree" = {
343 repo = "tree-sitter-devicetree";
347 repo = "tree-sitter-r";
349 "tree-sitter-bibtex" = {
351 repo = "tree-sitter-bibtex";
353 "tree-sitter-fortran" = {
354 orga = "stadelmanma";
355 repo = "tree-sitter-fortran";
357 "tree-sitter-cmake" = {
359 repo = "tree-sitter-cmake";
361 "tree-sitter-janet-simple" = {
363 repo = "tree-sitter-janet-simple";
365 "tree-sitter-json5" = {
367 repo = "tree-sitter-json5";
369 "tree-sitter-pioasm" = {
371 repo = "tree-sitter-pioasm";
373 "tree-sitter-hjson" = {
374 orga = "winston0410";
375 repo = "tree-sitter-hjson";
377 "tree-sitter-llvm" = {
378 orga = "benwilliamgraham";
379 repo = "tree-sitter-llvm";
381 "tree-sitter-http" = {
382 orga = "ntbbloodbath";
383 repo = "tree-sitter-http";
385 "tree-sitter-prisma" = {
387 repo = "tree-sitter-prisma";
389 "tree-sitter-org-nvim" = {
391 repo = "tree-sitter-org";
393 "tree-sitter-hcl" = {
394 orga = "MichaHoffmann";
395 repo = "tree-sitter-hcl";
397 "tree-sitter-scheme" = {
399 repo = "tree-sitter-scheme";
401 "tree-sitter-tiger" = {
403 repo = "tree-sitter-tiger";
405 "tree-sitter-nickel" = {
406 orga = "nickel-lang";
407 repo = "tree-sitter-nickel";
409 "tree-sitter-smithy" = {
410 orga = "indoorvivants";
411 repo = "tree-sitter-smithy";
413 "tree-sitter-jsonnet" = {
414 orga = "sourcegraph";
415 repo = "tree-sitter-jsonnet";
417 "tree-sitter-solidity" = {
419 repo = "tree-sitter-solidity";
423 repo = "tree-sitter-nu";
425 "tree-sitter-cue" = {
427 repo = "tree-sitter-cue";
429 "tree-sitter-uiua" = {
431 repo = "tree-sitter-uiua";
433 "tree-sitter-wing" = {
435 repo = "tree-sitter-wing";
437 "tree-sitter-wgsl" = {
439 repo = "tree-sitter-wgsl";
441 "tree-sitter-templ" = {
443 repo = "tree-sitter-templ";
445 "tree-sitter-gleam" = {
447 repo = "tree-sitter-gleam";
449 "tree-sitter-koka" = {
451 repo = "tree-sitter-koka";
453 "tree-sitter-earthfile" = {
455 repo = "tree-sitter-earthfile";
457 "tree-sitter-river" = {
459 repo = "tree-sitter-river";
461 "tree-sitter-twig" = {
462 orga = "kaermorchen";
463 repo = "tree-sitter-twig";
465 "tree-sitter-hyprlang" = {
466 orga = "tree-sitter-grammars";
467 repo = "tree-sitter-hyprlang";
469 "tree-sitter-kdl" = {
470 orga = "tree-sitter-grammars";
471 repo = "tree-sitter-kdl";
473 "tree-sitter-tera" = {
475 repo = "tree-sitter-tera";
481 treeSitterOrgaGrammars =
487 orga = "tree-sitter";
491 knownTreeSitterOrgGrammarRepos);
494 lib.attrsets.unionOfDisjoint otherGrammars treeSitterOrgaGrammars;
498 jsonFile = name: val: (formats.json { }).generate name val;
500 # implementation of the updater
501 updateImpl = passArgs "updateImpl-with-args"
504 curl = "${curl}/bin/curl";
505 nix-prefetch-git = "${nix-prefetch-git}/bin/nix-prefetch-git";
506 printf = "${coreutils}/bin/printf";
509 knownTreeSitterOrgGrammarRepos
510 ignoredTreeSitterOrgRepos
513 (writers.writePython3 "updateImpl"
515 flakeIgnore = [ "E501" ];
518 # Pass the given arguments to the command, in the ARGS environment variable.
519 # The arguments are just a json object that should be available in the script.
520 passArgs = name: argAttrs: script: writeShellScript name ''
521 env ARGS="$(< ${jsonFile "${name}-args" argAttrs})" \
525 foreachSh = attrs: f:
526 lib.concatMapStringsSep "\n" f
527 (lib.mapAttrsToList (k: v: { name = k; } // v) attrs);
529 jsonNewlines = lib.concatMapStringsSep "\n" (lib.generators.toJSON { });
531 # Run the given script for each of the attr list.
532 # The attrs are passed to the script as a json value.
533 forEachParallel = name: script: listOfAttrs: writeShellScript "for-each-parallel.sh" ''
534 < ${writeText "${name}.json" (jsonNewlines listOfAttrs)} \
535 ${xe}/bin/xe -F -j5 ${script} {}
538 # The output directory in the current source tree.
539 # This will depend on your local environment, but that is intentional.
540 outputDir = "${toString ./.}/grammars";
542 update-all-grammars = writeShellScript "update-all-grammars.sh" ''
544 ${updateImpl} fetch-and-check-tree-sitter-repos '{}'
545 echo "writing files to ${outputDir}" 1>&2
546 mkdir -p "${outputDir}"
549 (writeShellScript "fetch-repo" ''
550 ${updateImpl} fetch-repo "$1"
553 (nixRepoAttrName: attrs: attrs // {
560 ${updateImpl} print-all-grammars-nix-file "$(< ${
561 jsonFile "all-grammars.json" {
564 (nixRepoAttrName: attrs: attrs // {
565 inherit nixRepoAttrName;