properly replace deprecated tsutils functions

This commit is contained in:
Kiyoon Kim 2023-02-12 18:18:48 +00:00 committed by Stephan Seitz
parent ab5cc6414e
commit 7eb5f1a2e3
4 changed files with 6 additions and 10 deletions

View file

@ -412,11 +412,6 @@ node_to_lsp_range(node)~
Get an lsp formatted range from a node range Get an lsp formatted range from a node range
*ts_utils.get_node_range*
get_node_range(node_or_range)~
Get the range from either a node or a range
*ts_utils.node_length* *ts_utils.node_length*
node_length(node)~ node_length(node)~

View file

@ -1,6 +1,7 @@
local parsers = require "nvim-treesitter.parsers" local parsers = require "nvim-treesitter.parsers"
local queries = require "nvim-treesitter.query" local queries = require "nvim-treesitter.query"
local tsutils = require "nvim-treesitter.ts_utils" local tsutils = require "nvim-treesitter.ts_utils"
local ts = vim.treesitter
local M = {} local M = {}
@ -82,7 +83,7 @@ function M.get_indent(lnum)
return return
end end
local local_root = tstree:root() local local_root = tstree:root()
if tsutils.is_in_node_range(local_root, lnum - 1, 0) then if ts.is_in_node_range(local_root, lnum - 1, 0) then
if not root or tsutils.node_length(root) >= tsutils.node_length(local_root) then if not root or tsutils.node_length(root) >= tsutils.node_length(local_root) then
root = local_root root = local_root
lang_tree = tree lang_tree = tree

View file

@ -1,6 +1,6 @@
local highlighter = require "vim.treesitter.highlighter" local highlighter = require "vim.treesitter.highlighter"
local ts_utils = require "nvim-treesitter.ts_utils"
local parsers = require "nvim-treesitter.parsers" local parsers = require "nvim-treesitter.parsers"
local ts = vim.treesitter
local COMMENT_NODES = { local COMMENT_NODES = {
markdown = "html_block", markdown = "html_block",
@ -67,7 +67,7 @@ local function check_assertions(file)
assert.Truthy(node) assert.Truthy(node)
assert.is.number(row) assert.is.number(row)
assert.is.number(col) assert.is.number(col)
if hl and ts_utils.is_in_node_range(node, row, col) then if hl and ts.is_in_node_range(node, row, col) then
local c = query._query.captures[capture] -- name of the capture in the query local c = query._query.captures[capture] -- name of the capture in the query
if c ~= nil and c ~= "spell" and c ~= "conceal" then if c ~= nil and c ~= "spell" and c ~= "conceal" then
captures[c] = true captures[c] = true

View file

@ -1,8 +1,8 @@
require "nvim-treesitter.highlight" -- yes, this is necessary to set the hlmap require "nvim-treesitter.highlight" -- yes, this is necessary to set the hlmap
local highlighter = require "vim.treesitter.highlighter" local highlighter = require "vim.treesitter.highlighter"
local configs = require "nvim-treesitter.configs" local configs = require "nvim-treesitter.configs"
local ts_utils = require "nvim-treesitter.ts_utils"
local parsers = require "nvim-treesitter.parsers" local parsers = require "nvim-treesitter.parsers"
local ts = vim.treesitter
local function check_assertions(file) local function check_assertions(file)
local buf = vim.fn.bufadd(file) local buf = vim.fn.bufadd(file)
@ -39,7 +39,7 @@ local function check_assertions(file)
local root = tstree:root() local root = tstree:root()
--- If there are multiple tree with the smallest range possible --- If there are multiple tree with the smallest range possible
--- Check all of them to see if they fit or not --- Check all of them to see if they fit or not
if not ts_utils.is_in_node_range(root, row, col) or root == top_level_root then if not ts.is_in_node_range(root, row, col) or root == top_level_root then
return return
end end
if assertion.expected_capture_name == tree:lang() then if assertion.expected_capture_name == tree:lang() then