百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
T

tree-sitter-templ

> 编程语言
开源

树座器的 Templ 语法

99 stars0 点赞2 次浏览
访问官网GitHub

工具介绍

树座器的 Templ 语法

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 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

JavaScripttempltree-sitter

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月18日
分类编程语言
定价开源

> 相关工具

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