Announcing tree-sitter-nix

#1

I wrote a tree-sitter grammar for Nix: https://github.com/cstrahan/tree-sitter-nix

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).

7 Likes

Nix-lsp: Language server for nix
#2

I was thinking about it for a long time, is there a plan to have it included in Atom? Maybe including it in @wmertens extnsion?

0 Likes

#3

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 :frowning:

0 Likes

#4

However, that would mean having tree-sitter support in editors, something that doesn’t exist yet it seems :frowning:

Atom has support, but I don’t know about any other editors. There’s some ongoing work to support tree-sitter in Neovim, though.

I was thinking about it for a long time, is there a plan to have it included in Atom?

Yeah, that’s something I’d like to do eventually.

0 Likes

#5

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.

0 Likes

#6

Does it support escaping of dollar in strings ‘’$ ?

0 Likes

#7

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 :man_shrugging:).

0 Likes

#8

:thinking: just ftr

logged out
on the first post on this thread i see

This post was flagged by the community and is temporarily hidden.
View hidden content.

logged in
i see

This is the first time cstrahan has posted — let’s welcome them to our community!

and

This post was flagged by the community and is temporarily hidden.
View hidden content.

/ftr

:confused:

0 Likes

#9

Oh yeah. That’s kinda weird. I saw that my first post, and a subsequent post here, are showing up as slightly grayed out. Bizarre.

0 Likes

#10

I also saw these strange things… on another post too. Something fishy with discourse.

0 Likes

#11

Discourse just plainly hates URLs. It flags posts of new users with them, it loses them in the plain-text parts of emails…

0 Likes

#12

I started putting together a formatter using this grammar here: https://github.com/justinwoo/format-nix

It’s a simple PureScript Node application using the node tree-sitter bindings.

5 Likes

#13

That’s awesome! Glad to see the grammar is already proving useful.

Thanks for your contributions and feedback, btw.

0 Likes