Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
T

tree-sitter-templ

> 编程语言
Open source

Templ grammar for tree-sitter

99 stars0 likes2 views
WebsiteGitHub

About

Templ grammar for tree-sitter

tree-sitter-templ

A tree-sitter grammar for Templ.

Using this with Neovim

To use this parser for syntax highlighting in Neovim, you need nvim-treesitter.

Requirements

  • Neovim 0.11.0+
  • nvim-treesitter

Installation

First, install nvim-treesitter. If using lazy.nvim:

lua
require('lazy').setup({
  {
    'nvim-treesitter/nvim-treesitter',
    lazy = false,
    branch = 'main',
    build = ':TSUpdate'
  }
})

Then install the Templ parser:

lua
require('nvim-treesitter').install({ 'templ' })

Finally, enable syntax highlighting for Templ files by adding this autocmd:

lua
vim.api.nvim_create_autocmd('FileType', {
  pattern = 'templ',
  callback = function()
    vim.treesitter.start()
  end,
})

Manual Installation

If you want to use a specific branch, version, or local development path, you can manually configure the parser:

lua
vim.api.nvim_create_autocmd('User', {
  pattern = 'TSUpdate',
  callback = function()
    require('nvim-treesitter.parsers').templ = {
      install_info = {
        url = 'https://github.com/vrischmann/tree-sitter-templ',
        branch = 'main', -- or specific branch/tag
        -- path = "~/dev/perso/projects/tree-sitter-templ", -- for local development
        queries = 'queries/templ',
      },
    }
  end
})

Then run :TSInstall templ to install the parser with your custom configuration.

You can check its status with :checkhealth, you should see something like this:

…

Finally you can open a templ file and run :InspectTree to see the parse tree.

Contributing

The official tree-sitter documentation for creating a parser contains everything you need to start contributing to this parser.

To make it easier, we use a Justfile to simplify some tasks:

  • just test [filter...] to run tests
  • just gen to generate the parser
  • just build to generate and build the parser

If you want to modify the parser, make sure to add a test or modify an existing one in the corpus directory.

Issues· 0 open

View all issuesOpen on GitHub

No open issues yet, or sync has not completed.

> Tags

JavaScripttempltree-sitter

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 18, 2026
Category编程语言
PricingOpen source

> Related tools

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言