I would like to test tree-sitter
to parse python
programs. I started by trying:
$ nix-shell -p tree-sitter --run "tree-sitter parse ast.py"
[...]
Warning: You have not configured any parser directories!
Please run `tree-sitter init-config` and edit the resulting
configuration file to indicate where we should look for
language grammars.
No language found
Seems that init-config
would clutter my home. I hope there is a way to avoid that home-dependent plumbing in NixOS…
As far as I understand, we package common grammars, for example tree-sitter-grammars.tree-sitter-python
.
Following nixpkgs/pkgs/development/tools/parsing/tree-sitter/default.nix at 50b3bd3fed0442bcbf7f58355e990da84af1749d · NixOS/nixpkgs · GitHub, I tried:
$ nix-shell -p "tree-sitter.withPlugins(ps: [ ps.tree-sitter-python ])" --run "tree-sitter parse atbdx2024/examples/ast.py"
[...]
/tmp/nix-shell-213097-0/rc: line 3: tree-sitter: command not found
Am I misunderstanding how withPlugins
is supposed to work?
cc @Profpatsch