Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

tree-sitter-macaulay2

The tree-sitter grammar: what editors use for highlighting, folding and indentation, and the parser at the bottom of everything Rust-side in this bundle.

It follows M2’s own precedence and newline rules, and part of the tests are generated from what M2’s own parse says, so it sees the code the same way M2 does.

It comes with highlight, fold, indent, injection (TEST /// … /// bodies are highlighted as M2) and tags queries, and bindings for Rust, Node and Python.

In your editor

See Setting up tree-sitter.

In your code

cargo add tree-sitter tree-sitter-macaulay2
#![allow(unused)]
fn main() {
let mut parser = tree_sitter::Parser::new();
parser.set_language(&tree_sitter_macaulay2::language())?;
let tree = parser.parse("R = QQ[x, y]", None).unwrap();
}

Same name on npm and PyPI. If you’d rather have typed syntax nodes than a generic tree, use m2-syn.

Repository · crates.io