ts_utils.is_in_node_range for old nevim versions

pull/268/head
ray-x 1 year ago
parent c000890350
commit f16029fd25

@ -15,6 +15,11 @@ local parsers = require('nvim-treesitter.parsers')
local utils = require('nvim-treesitter.utils')
local locals = require('nvim-treesitter.locals')
local ts_utils = require('nvim-treesitter.ts_utils')
local is_in_node_range = vim.treesitter.is_in_node_range
if not is_in_node_range then
is_in_node_range = ts_utils.is_in_node_range
end
local api = vim.api
local util = require('navigator.util')
local M = {}
@ -126,7 +131,7 @@ function M.get_tsnode_at_pos(pos, bufnr, ignore_injected_langs)
if ignore_injected_langs then
for _, tree in ipairs(root_lang_tree:trees()) do
local tree_root = tree:root()
if tree_root and vim.treesitter.is_in_node_range(tree_root, cursor_range[1], cursor_range[2]) then
if tree_root and is_in_node_range(tree_root, cursor_range[1], cursor_range[2]) then
root = tree_root
break
end

Loading…
Cancel
Save