From c5aeb6f34a5980c3fc2447d7ef2fbbb27031a21c Mon Sep 17 00:00:00 2001 From: Manuel Coenen Date: Tue, 15 Jul 2025 07:45:28 +0200 Subject: [PATCH 1/3] feat: make compatible with latest nvim-treesitter nvim-trevJ will not work anymore with nvim-treesitter main branch. All relevant parts have been moved into stock neovim. --- lua/trevj.lua | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/lua/trevj.lua b/lua/trevj.lua index b4ce9d5..d124c01 100644 --- a/lua/trevj.lua +++ b/lua/trevj.lua @@ -1,9 +1,7 @@ local M = {} local ts = vim.treesitter -local get_node_text = vim.treesitter.get_node_text or vim.treesitter.query.get_node_text -local ts_utils = require("nvim-treesitter.ts_utils") -local parsers = require("nvim-treesitter.parsers") +local get_node_text = ts.get_node_text or ts.query.get_node_text local make_default_opts = function() return { @@ -182,8 +180,11 @@ local is_container = function(filetype, node) end local get_container_at_cursor = function(filetype) - parsers.get_parser(0):parse() - local node = ts_utils.get_node_at_cursor() + ts.get_parser():parse() + local node = vim.treesitter.get_node() + if node == nil then + return + end while not is_container(filetype, node) do node = node:parent() if node == nil then From a8bc1198e9bc2d4dccb18ba9fe7161a695777a90 Mon Sep 17 00:00:00 2001 From: Manuel Date: Mon, 21 Jul 2025 12:41:16 +0200 Subject: [PATCH 2/3] Apply suggestion from @AckslD Co-authored-by: Axel Dahlberg --- lua/trevj.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/trevj.lua b/lua/trevj.lua index d124c01..610510f 100644 --- a/lua/trevj.lua +++ b/lua/trevj.lua @@ -181,7 +181,7 @@ end local get_container_at_cursor = function(filetype) ts.get_parser():parse() - local node = vim.treesitter.get_node() + local node = ts.get_node() if node == nil then return end From aa91b49c33795dd6813e040e0336b43637265d19 Mon Sep 17 00:00:00 2001 From: Manuel Coenen Date: Mon, 21 Jul 2025 14:47:36 +0200 Subject: [PATCH 3/3] chore: remove fallback for < nvim 0.9 --- lua/trevj.lua | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lua/trevj.lua b/lua/trevj.lua index 610510f..38a951d 100644 --- a/lua/trevj.lua +++ b/lua/trevj.lua @@ -1,7 +1,6 @@ local M = {} local ts = vim.treesitter -local get_node_text = ts.get_node_text or ts.query.get_node_text local make_default_opts = function() return { @@ -254,7 +253,7 @@ M.format_at_cursor = function() table.insert(children, { node = child, name = name }) end for i, child in ipairs(children) do - local lines = vim.split(get_node_text(child.node, 0), "\n") + local lines = vim.split(ts.get_node_text(child.node, 0), "\n") if opts.final_separator and i > 1