Skip to content

Commit 327cb4c

Browse files
authored
fix: avoid vim.tbl_flatten (#514)
Fixes #513
1 parent 4d74e75 commit 327cb4c

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

lua/nvim-autopairs/ts-utils.lua

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,25 @@
11
local ts_get_node_text = vim.treesitter.get_node_text or vim.treesitter.query.get_node_text
22
local M = {}
33

4+
local flatten = (function()
5+
if vim.fn.has "nvim-0.11" == 1 then
6+
return function(t)
7+
return vim.iter(t):flatten():totable()
8+
end
9+
else
10+
return function(t)
11+
return vim.tbl_flatten(t)
12+
end
13+
end
14+
end)()
15+
16+
417
--- Returns the language tree at the given position.
518
---@return LanguageTree
619
function M.get_language_tree_at_position(position)
720
local language_tree = vim.treesitter.get_parser()
821
language_tree:for_each_tree(function(_, tree)
9-
if tree:contains(vim.tbl_flatten({ position, position })) then
22+
if tree:contains(flatten({ position, position })) then
1023
language_tree = tree
1124
end
1225
end)

0 commit comments

Comments
 (0)