3
3
local ts_utils = require " nvim-treesitter.ts_utils"
4
4
local locals = require " nvim-treesitter.locals"
5
5
local configs = require " nvim-treesitter.configs"
6
- local ts_query = vim .treesitter .query
7
6
local api = vim .api
8
7
9
8
local M = {}
@@ -16,6 +15,8 @@ local function index_of(tbl, obj)
16
15
end
17
16
end
18
17
18
+ local get_node_text = vim .treesitter .get_node_text or vim .treesitter .query .get_node_text
19
+
19
20
function M .goto_definition (bufnr , fallback_function )
20
21
local bufnr = bufnr or api .nvim_get_current_buf ()
21
22
local node_at_point = ts_utils .get_node_at_cursor ()
@@ -78,7 +79,7 @@ function M.list_definitions(bufnr)
78
79
for _ , node in ipairs (definitions ) do
79
80
local lnum , col , _ = node .node :start ()
80
81
local type = string.upper (node .type :sub (1 , 1 ))
81
- local text = ts_query . get_node_text (node .node , bufnr ) or " "
82
+ local text = get_node_text (node .node , bufnr ) or " "
82
83
table.insert (qf_list , {
83
84
bufnr = bufnr ,
84
85
lnum = lnum + 1 ,
@@ -133,7 +134,7 @@ function M.list_definitions_toc()
133
134
134
135
local lnum , col , _ = def .node :start ()
135
136
local type = string.upper (def .type :sub (1 , 1 ))
136
- local text = ts_query . get_node_text (def .node , bufnr ) or " "
137
+ local text = get_node_text (def .node , bufnr ) or " "
137
138
table.insert (loc_list , {
138
139
bufnr = bufnr ,
139
140
lnum = lnum + 1 ,
0 commit comments