#tree-sitter #incremental #parser #todolang

tree-sitter-todolang

Todolang语法规则针对tree-sitter

1个不稳定版本

0.0.1 2024年6月14日

#163 in #tree-sitter

MIT 许可证

18KB
431

tree-sitter-todolang

todolangmynd 项目的一部分。

使用方法(Neovim)

nvim-treesitter 提供了完整的操作说明。

将此仓库克隆到 ~/projects/tree-sitter-todolang/

mkdir ~/projects/tree-sitter-todolang
git clone https://github.com/Gnarus-G/tree-sitter-todolang ~/projects/tree-sitter-todolang

在您的 init.lua 中添加以下内容

local parser_config = require "nvim-treesitter.parsers".get_parser_configs()
parser_config.todolang = {
  install_info = {
    url = "~/projects/tree-sitter-todolang",       -- local path or git repo
    files = { "src/parser.c" },             -- note that some parsers also require src/scanner.c or src/scanner.cc
    -- optional entries:
    branch = "main",                        -- default branch in case of git repo if different from master
    generate_requires_npm = false,          -- if stand-alone parser without npm dependencies
    requires_generate_from_grammar = false, -- if folder contains pre-generated src/parser.c
  },
}

vim.filetype.add({
  extension = {
    todo = "todolang",
    td = "todolang"
  }
})

并将此仓库中的 queries/highlights.scm 的内容复制到 queries 文件夹,例如 .config/nvim/after/queries/todolang

"todo" @keyword

(chars) @string

[
 "{"
 "}"
] @punctuation.bracket

然后在neovim中运行以下命令

:TSInstall todolang

依赖项

~2.8–4MB
~72K SLoC