Announcing tree-sitter-nix

I recently did some work to improve highlighting in helix:

You could probably steal the highlighting queries for other editors.

Also included some upstream work:

If you wanted to just testdrive everything here you could build my forked branch:
nix build github:nrdxp/helix/fork


Can this be used to evaluate a flake output and generate a nix file of the result?

Tree-sitter is just a parser, so it can’t do any evaulation, but it can generate either an AST or CST for you. I think Toros would be the program that aspires to eventually evaluate Nix code.

Actually, I was thinking it might be useful to use NixEL (the grammar used by Toros) to generate the tree-sitter grammar, so that various tooling (an LSP, editor highlighing, etc) can have a single source of truth for a Nix grammar. Not sure if that’s feasible though. cc @kamadorueda

1 Like

Hey @cstrahan, I’d like to integrate tree-sitter-nix into ast-grep. I think this might involve making a 0.0.2 release. Would you be open to that?