fixup! refactor(struct_tags): use new ts_util
This commit is contained in:
parent
99f13e699d
commit
59169df030
1 changed files with 3 additions and 6 deletions
|
|
@ -1,7 +1,7 @@
|
||||||
local ts = {
|
local ts = {
|
||||||
queries = {
|
queries = {
|
||||||
struct = [[
|
struct = [[
|
||||||
(type_spec name: (type_identifier) @name
|
(type_spec name: (type_identifier) @_name
|
||||||
type: (struct_type))
|
type: (struct_type))
|
||||||
]],
|
]],
|
||||||
|
|
||||||
|
|
@ -55,14 +55,11 @@ function ts.get_struct_node_at_pos(bufnr)
|
||||||
res["end_line"] = end_row + 1
|
res["end_line"] = end_row + 1
|
||||||
|
|
||||||
local query = vim.treesitter.query.parse("go", ts.queries.struct)
|
local query = vim.treesitter.query.parse("go", ts.queries.struct)
|
||||||
|
|
||||||
for _, match, _ in query:iter_matches(r, bufnr) do
|
for _, match, _ in query:iter_matches(r, bufnr) do
|
||||||
for capture_id, captured_node in pairs(match) do
|
for capture_id, captured_node in pairs(match) do
|
||||||
local capture_name = query.captures[capture_id]
|
local capture_name = query.captures[capture_id]
|
||||||
local text = vim.treesitter.get_node_text(captured_node, bufnr)
|
if capture_name == "_name" then
|
||||||
|
res["name"] = vim.treesitter.get_node_text(captured_node, bufnr)
|
||||||
if capture_name == "name" then
|
|
||||||
res["name"] = text
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue