| Crates.io | codebook-tree-sitter-typst |
| lib.rs | codebook-tree-sitter-typst |
| version | 0.12.1 |
| created_at | 2025-11-05 21:43:00.409818+00 |
| updated_at | 2025-12-23 22:19:05.414352+00 |
| description | typst grammar for the tree-sitter parsing library |
| homepage | |
| repository | https://github.com/uben0/tree-sitter-typst |
| max_upload_size | |
| id | 1918677 |
| size | 5,318,634 |
This is a fork of https://github.com/uben0/tree-sitter-typst for publishing to crates.io. Please submit issues there.
Typst official page https://typst.app
Tree-Sitter documentation page https://tree-sitter.github.io
Typst doesn't have yet an official Tree-Sitter grammar. This grammar is complete but may contains bug as it is very recent.
Your help is welcome. You don't have to know anything about Tree-Sitter to help. You just have to use this grammar and report any bad highlighting you see! You can open an issue or simply send me by email the Typst code causing the bug. See below installation instructions for this grammar. Even if your not sure it is a bug, it doesn't hurt to repport it.
I need help to:
rewrite. This time the code is documented and you may get involve however you want. Ask me how to help, ask me what needs to be explained and documented. I aim at making this new implementation maintainable by the community.Don't hesitate to contact me (mailto:eddie.gerbais-nief@proton.me) or to open an issue, even if you're not sure. It doesn't hurt.
The documentation of the current implementation (not the rewrite) is available in DOC. But I suggest to ignore the current implementation as it is a spaghetti mess. However, the DOC brings up interesting chalenges.
rewrite)rewrite branch)Having syntax highlighting is great but having syntax highlighting and the language server is even greater. If you have cargo installed (Rust's package manager), you can install Typst language server with the following command (you don't have to be in any particular directory):
cargo install --git https://github.com/Myriad-Dreamin/tinymist --locked tinymist
The https://github.com/nvim-treesitter/nvim-treesitter provides this grammar.
Typst support for Emacs is available through the following package:
(use-package typst-ts-mode
:elpaca (:type git :host sourcehut :repo "meow_king/typst-ts-mode")
:custom
(typst-ts-mode-watch-options "--open"))
This grammar is already builtin Helix. But it might not be up to date. To manyally install it:
~/.config/helix/usr/share/helixlanguages.toml file (create it if it doesn't exist).[[language]]
name = "typst"
scope = "source.typst"
file-types = ["typst", "typ"]
indent = { tab-width = 2, unit = " " }
comment-token = "//"
injection-regex = "typ(st)?"
roots = ["typst.toml"]
language-servers = [ "typst-lsp" ]
[language.auto-pairs]
'(' = ')'
'{' = '}'
'[' = ']'
'$' = '$'
'"' = '"'
[[grammar]]
name = "typst"
source.git = "https://github.com/uben0/tree-sitter-typst"
source.rev = "master"
queries directory (highlights.scm and injections.scm) inside your corresponding runtime/queries/typst directory. You should have the following structure:config.toml
languages.toml
runtime
└── queries
└── typst
├── highlights.scm
└── injections.scm
hx --grammar fetch
hx --grammar build
The fetch command will clone the git repository, and the build command will compile the grammar. Open the logs to have insightfull messages in case it doesn't work.