Skip to content

MuntasirSZN/tree-sitter-tera

 
 

Repository files navigation

tree-sitter-tera

Tree-sitter grammar and syntax highlight queries for the Tera templating language.

Tip

See also Tera extensions for other editors:

Usage

Neovim

Important

Requires Neovim v0.11 or later.

Install the grammar by running the following command inside Neovim:

:TSInstall tera

Helix

Note

As of 2025-02-02 (unreleased), tree-sitter-tera is included for Tera language support in Helix.

  1. Add the following language and grammar configuration to your own languages.toml configuration file:
[[grammar]]
name = "tera"

[grammar.source]
git = "https://github.com/uncenter/tree-sitter-tera"
rev = "main"

[[language]]
file-types = ["tera"]
grammar = "tera"
injection-regex = "tera"
name = "tera"
scope = "source.tera"
block-comment-tokens = [
  { start = "{#", end = "#}" },
  { start = "{#-", end = "-#}" },
  { start = "{#", end = "-#}" },
  { start = "{#-", end = "#}" },
]

[language.auto-pairs]
"\"" = "\""
"'" = "'"
"`" = "`"
"(" = ")"
"[" = "]"
"{" = "}"
"%" = "%"
  1. Run hx --grammar fetch to fetch the grammar from this repository, and then hx --grammar build to build the grammars.
  2. Run just helix sync or just helix link to copy or symlink the Helix-specific queries to Helix's runtime directory, as unfortunately queries are not used from the grammar repository by default.

Important

Helix uses the reverse query precedence ordering, meaning that the first matching highlight query is used rather than last; this is the opposite behavior of Neovim and Zed, both of which use the last matching highlight query - think of it like CSS, where queries gain precedence by being located further down. Helix does seemingly plan to change this soon, but for now this repository has a separate folder for Helix-converted queries (built with just helix build, using tree-sitter-query-reverser.

License

MIT

About

⛩️ Tree-sitter grammar for the Tera templating language.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Sponsor this project

Packages

No packages published

Languages

  • JavaScript 38.3%
  • Scheme 32.9%
  • C 21.0%
  • Just 4.3%
  • Tree-sitter Query 3.5%