Skip to content

Commit db6a428

Browse files
authored
Merge pull request #42 from wilriker/main
feat: make compatible with latest nvim-treesitter
2 parents 86445d0 + aa91b49 commit db6a428

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

lua/trevj.lua

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
local M = {}
22

33
local ts = vim.treesitter
4-
local get_node_text = vim.treesitter.get_node_text or vim.treesitter.query.get_node_text
5-
local ts_utils = require("nvim-treesitter.ts_utils")
6-
local parsers = require("nvim-treesitter.parsers")
74

85
local make_default_opts = function()
96
return {
@@ -182,8 +179,11 @@ local is_container = function(filetype, node)
182179
end
183180

184181
local get_container_at_cursor = function(filetype)
185-
parsers.get_parser(0):parse()
186-
local node = ts_utils.get_node_at_cursor()
182+
ts.get_parser():parse()
183+
local node = ts.get_node()
184+
if node == nil then
185+
return
186+
end
187187
while not is_container(filetype, node) do
188188
node = node:parent()
189189
if node == nil then
@@ -253,7 +253,7 @@ M.format_at_cursor = function()
253253
table.insert(children, { node = child, name = name })
254254
end
255255
for i, child in ipairs(children) do
256-
local lines = vim.split(get_node_text(child.node, 0), "\n")
256+
local lines = vim.split(ts.get_node_text(child.node, 0), "\n")
257257
if
258258
opts.final_separator
259259
and i > 1

0 commit comments

Comments
 (0)