feat(starlark): treesitter support for Starlark (#402)

This commit is contained in:
Qiu Yu 2024-08-21 20:40:59 -07:00 committed by GitHub
parent bb95e7fed7
commit e585934fef
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 40 additions and 0 deletions

View file

@ -168,6 +168,7 @@ In addition, you will need to have either Treesitter or a working LSP client. Yo
- scala
- snakemake
- solidity
- starlark
- teal
- toml
- tsx

View file

@ -340,6 +340,18 @@ M.rst = {
end,
}
M.starlark = {
postprocess = function(bufnr, item, match)
if item.kind == "Function" then
local rule_kind = node_from_match(match, "rule_kind")
local rule_name = assert(node_from_match(match, "rule_name"))
local name_text = get_node_text(rule_name, bufnr) or "<parse error>"
local kind_text = get_node_text(rule_kind, bufnr) or "<parse error>"
item.name = string.format("%s > %s", name_text, kind_text)
end
end,
}
M.typescript = {
---@note Additionally processes the following captures:
--- `@method`, `@string`, and `@modifier` - replaces name with "@method[.@modifier] @string"

View file

@ -0,0 +1,10 @@
(expression_statement
(call
function: (identifier) @rule_kind
(#not-any-of? @rule_kind "load")
arguments: (argument_list
(keyword_argument
name: (identifier)
value: (string
(string_content) @rule_name))))
(#set! "kind" "Function")) @symbol

View file

@ -0,0 +1,11 @@
[
{
"col": 0,
"end_col": 1,
"end_lnum": 6,
"kind": "Function",
"level": 0,
"lnum": 3,
"name": "hello > go_binary"
}
]

View file

@ -0,0 +1,6 @@
load("@io_bazel_rules_go//go:def.bzl", "go_binary")
go_binary(
name = "hello",
srcs = ["hello.go"],
)