Down the road, we could do some fun stuff, like provide syntax highlighting in nix repl (Tree Sitter tries its best to come up with a sensible parse tree, even if there are errors).
I would love to use this instead of my Nix grammar. The Nix grammar canāt express the full language correctly because itās only regular expressions.
However, that would mean having tree-sitter support in editors, something that doesnāt exist yet it seems
Iāll note that Iāve pushed some changes that add a pretty decent test suite, fixes a couple bugs, and overhauls the shape of the resulting parse tree (it was pretty verbose before, but now itās very clean).
I think at this point it should be very robust, and I donāt expect much churn. Iād love for some people to play around with it and report back. If no one can find some improvements / faults, Iāll cut a 1.0.0 release.
Nice catch. I just pushed a fix for that in the custom scanner (Iād link to the commit, but it looks like we canāt link to github on this setup of Discourse ).
Hey, while looking at the status of language server implementations for nix, and stumbling upon this project, I think itād be worth mentioning for reference GitHub - bash-lsp/bash-language-server: A language server for Bash which implements a very fast and rather performent language server for bash using a tree-sitter grammer as well. I assume the same could be leveraged for a language server implementation for nix as well.
I would like to load your grammar into neovim. Iāve started following Guide to writing your first Tree-sitter grammar Ā· GitHub and trial by error led me to this command line nix run nixpkgs.tree-sitter nixpkgs:nodePackages.node-gyp nixpkgs:python27 but then it doesnāt find /bin/sh . Do you have some recipe on how to generate a module onx nixos from your grammar ? the CI configuration was not very information-heavy either xD
something like add tree-sitter-nix Ā· milahu/syntax-highlighter@617abbf Ā· GitHub
the āgrammarā file maps node types to token categories
todo: update package-lock.json, use npmlock2nix or nix-npm-buildpackage,
use tree-sitter from nixpkgs instead of tree-sitter-cli from npm