Skip to content
This repository was archived by the owner on Nov 28, 2025. It is now read-only.

Commit 34c1d80

Browse files
theHamstaamaanq
authored andcommitted
fix: vendor removed function index_of
`utils.index_of` was removed in nvim-treesitter/nvim-treesitter@853b1ab#diff-80e9d2073d6762e6b809df6f9b2da04be7f0d87384ccd3abe8c723d88b1be3e6 Fixes #46
1 parent b216290 commit 34c1d80

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

lua/nvim-treesitter-refactor/navigation.lua

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,21 @@
11
-- Definition based navigation module
22

33
local ts_utils = require "nvim-treesitter.ts_utils"
4-
local utils = require "nvim-treesitter.utils"
54
local locals = require "nvim-treesitter.locals"
65
local configs = require "nvim-treesitter.configs"
76
local ts_query = vim.treesitter.query
87
local api = vim.api
98

109
local M = {}
1110

11+
local function index_of(tbl, obj)
12+
for i, o in ipairs(tbl) do
13+
if o == obj then
14+
return i
15+
end
16+
end
17+
end
18+
1219
function M.goto_definition(bufnr, fallback_function)
1320
local bufnr = bufnr or api.nvim_get_current_buf()
1421
local node_at_point = ts_utils.get_node_at_cursor()
@@ -153,7 +160,7 @@ function M.goto_adjacent_usage(bufnr, delta)
153160
local def_node, scope = locals.find_definition(node_at_point, bufnr)
154161
local usages = locals.find_usages(def_node, scope, bufnr)
155162

156-
local index = utils.index_of(usages, node_at_point)
163+
local index = index_of(usages, node_at_point)
157164
if not index then
158165
return
159166
end

0 commit comments

Comments
 (0)