chore: replace deprecated ts_utils.get_node_text

Fixes #101
master
Stephan Seitz 1 year ago
parent 3421bbbfec
commit 632b649a37

@ -517,7 +517,7 @@ function M.update_query(bufnr, query_bufnr)
for capture_match in ts_query.iter_group_results(query_bufnr, "captures") do
table.insert(M._entries[bufnr].captures, capture_match.capture)
local capture = ts_utils.get_node_text(capture_match.capture.name.node, query_bufnr)[1]
local capture = vim.treesitter.query.get_node_text(capture_match.capture.name.node, query_bufnr)
if not capture_by_color[capture] then
capture_by_color[capture] = "TSPlaygroundCapture" .. index
@ -581,7 +581,7 @@ function M.on_query_cursor_move(bufnr)
local _, _, capture_end = capture.def.node:end_()
local _, _, start = node_at_point:start()
local _, _, _end = node_at_point:end_()
local capture_name = ts_utils.get_node_text(capture.name.node)[1]
local capture_name = vim.treesitter.query.get_node_text(capture.name.node, bufnr)
if start >= capture_start and _end <= capture_end and capture_name then
M.highlight_matched_query_nodes_from_capture(bufnr, capture_name)

@ -20,7 +20,7 @@ local function lint_node(node, buf, error_type, complete_message)
if error_type ~= "Invalid Query" then
ts_utils.highlight_node(node, buf, hl_namespace, ERROR_HL)
end
local node_text = table.concat(ts_utils.get_node_text(node, buf), " ")
local node_text = vim.treesitter.query.get_node_text(node, buf):gsub("\n", " ")
local error_text = complete_message or error_type .. ": " .. node_text
local error_range = { node:range() }
if M.use_virtual_text then
@ -83,7 +83,7 @@ function M.lint(query_buf)
local toplevel_node = utils.get_at_path(m, "toplevel-query.node")
if toplevel_node and query_lang then
local query_text = table.concat(ts_utils.get_node_text(toplevel_node), "\n")
local query_text = vim.treesitter.query.get_node_text(toplevel_node, query_buf)
local err
ok, err = pcall(vim.treesitter.parse_query, query_lang, query_text)
if not ok then
@ -96,7 +96,7 @@ function M.lint(query_buf)
local anonymous_node = utils.get_at_path(m, "anonymous_node.node")
local node = named_node or anonymous_node
if node then
local node_type = ts_utils.get_node_text(node)[1]
local node_type = vim.treesitter.query.get_node_text(node, query_buf)
if anonymous_node then
node_type = node_type:gsub('"(.*)".*$', "%1"):gsub("\\(.)", "%1")
@ -117,7 +117,7 @@ function M.lint(query_buf)
local field_node = utils.get_at_path(m, "field.node")
if field_node then
local field_name = ts_utils.get_node_text(field_node)[1]
local field_name = vim.treesitter.query.get_node_text(field_node, query_buf)
local found = vim.tbl_contains(parser_info.fields, field_name)
if not found then
lint_node(field_node, query_buf, "Invalid Field")

Loading…
Cancel
Save