mirror of
https://github.com/stevearc/aerial.nvim
synced 2024-09-16 14:34:08 +02:00
feat(starlark): treesitter support for Starlark (#402)
This commit is contained in:
parent
bb95e7fed7
commit
e585934fef
5 changed files with 40 additions and 0 deletions
|
@ -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
|
||||
|
|
|
@ -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"
|
||||
|
|
10
queries/starlark/aerial.scm
Normal file
10
queries/starlark/aerial.scm
Normal 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
|
11
tests/symbols/starlark_test.json
Normal file
11
tests/symbols/starlark_test.json
Normal file
|
@ -0,0 +1,11 @@
|
|||
[
|
||||
{
|
||||
"col": 0,
|
||||
"end_col": 1,
|
||||
"end_lnum": 6,
|
||||
"kind": "Function",
|
||||
"level": 0,
|
||||
"lnum": 3,
|
||||
"name": "hello > go_binary"
|
||||
}
|
||||
]
|
6
tests/treesitter/starlark_test.bazel
Normal file
6
tests/treesitter/starlark_test.bazel
Normal file
|
@ -0,0 +1,6 @@
|
|||
load("@io_bazel_rules_go//go:def.bzl", "go_binary")
|
||||
|
||||
go_binary(
|
||||
name = "hello",
|
||||
srcs = ["hello.go"],
|
||||
)
|
Loading…
Reference in a new issue