uncenter / tree-sitter-tera

⛩️ Tree-sitter grammar for the Tera templating language (work-in-progress)
MIT License
5 stars 1 forks source link
tera tree-sitter

tree-sitter-tera

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

Usage

Helix

  1. Add the sample language and grammar configuration for Tera from languages.toml to your own languages.toml configuration file.
  2. Run hx --grammar fetch to fetch the grammar from this repository, and then hx --grammar build to build the grammars.
  3. Run just helix sync or just helix link to copy or symlink the queries to Helix's runtime directory, as unfortunately queries are not used from the grammar repository by default.

[!TIP] See https://docs.helix-editor.com/guides/adding_languages.html for more details.

Neovim

Lazy.nvim

Extend your nvim-treesitter plugin with this Tera plugin.

{
    "nvim-treesitter/nvim-treesitter",
    config = function()
        -- setup treesitter with config
    end,
    dependencies = {
        ...
        { "uncenter/tree-sitter-tera", build = ":TSUpdate tera" },
        ...
    },
    build = ":TSUpdate",
},

Manual

local parser_config = require("nvim-treesitter.parsers").get_parser_configs()

parser_config.tera = {
  install_info = {
    url = "https://github.com/uncenter/tree-sitter-tera",
    files = { "src/parser.c" },
    branch = "main",
  },
  filetype = "tera",
}

Run :TSInstall tera in Neovim to install the above parser.

License

MIT