Language-rust-treesitter: A better Rust tree-sitter syntax highlight package for atom

Hi there, people!!

I would like to announce my new package language-rust-treesitter. It’s a package that uses tree-sitter-rust to get fast and powerful rust syntax highlight with much better tokennization than language-rust-bundled

The key features of it are:

  • Contextualized tokennization using tree-sitter.
  • Backup TextMate language support, just in case Tree Sitter one doesn’t work on your machine.
  • Several snippets.
  • Expose much more classes to make better syntax theme stylization.

What is “contextualized tokennization”?
With tree-sitter, one can use and abuse the generated tree to get more accurate tokennization. That means that we can have equal symbols being tokennized into different things depending of the source code context. That means we have 2 consequences, considering a theme with proper styling:

  1. Easy to know the meaning of a symbol in the code (e.g. If “|” is a bitwise or or a closure definition || If “*” is a deference or a pointer definition or multiplication operator || If “…” is a range or a match remaining)
  2. Easy to get wrong syntax: since it will be tokennized only if in the right context (e.g. “@” will not be tokennized if it’s not in the right || “&” will not be tokennized if the following lifetime has no name (&') or of there is no type specified (&'a <BlankHere>))

I would be more than happy if people at lest test it and give feedback :smile:

Github repository:

P.S.: I made my theme support this, it you’re interested, the package is monokai-grayjack-syntax

1 Like

Doesn’t language-rust-bundled also use the same Tree-sitter grammar?

It does use use the same tree-sitter-rust package, but doesn’t use much of it’s power to tokennize the language in Atom.

If you look at the tree-sitter-rust code, there is do much more nodes that it can handle that language-rust-bundled don’t use.

I cannot say that my package uses all that tree-sitter-rust offer, but for sure my package uses way more than language-rust-bundled

A good visual way to compare is to open Atom, open dev-tools, and check what each package tokennize and how many tokens one create. (That’s how I do that fist when choosing a language-package over multiple ones) :smiley: