From 0339338316c7e0d62b03191d81cc68ca8101fc02 Mon Sep 17 00:00:00 2001 From: shiwei Date: Thu, 21 Apr 2022 14:30:42 +0800 Subject: [PATCH] fix: ts_utils.get_node_text function deprecated --- lua/nvim-ts-autotag/internal.lua | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/lua/nvim-ts-autotag/internal.lua b/lua/nvim-ts-autotag/internal.lua index a048732..26c21c8 100644 --- a/lua/nvim-ts-autotag/internal.lua +++ b/lua/nvim-ts-autotag/internal.lua @@ -1,8 +1,7 @@ local _, ts_utils = pcall(require, 'nvim-treesitter.ts_utils') +local get_node_text = vim.treesitter.query.get_node_text local configs = require'nvim-treesitter.configs' local parsers = require'nvim-treesitter.parsers' -local log = require('nvim-ts-autotag._log') --- local utils=require('nvim-ts-autotag.utils') local M = {} @@ -163,8 +162,8 @@ local function find_parent_match(opts) local function get_tag_name(node) local tag_name = nil - if node ~=nil then - tag_name = ts_utils.get_node_text(node)[1] + if node ~= nil then + tag_name = get_node_text(node, vim.api.nvim_get_current_buf()) end return tag_name end @@ -285,8 +284,8 @@ end local function validate_tag_regex(node,start_regex,end_regex) - if node == nil then return false end - local texts = ts_utils.get_node_text(node) + if node == nil then return false end + local texts = get_node_text(node, vim.api.nvim_get_current_buf()) if string.match(texts[1],start_regex) and string.match(texts[#texts],end_regex)