File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11local M = {}
22
33local 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
85local make_default_opts = function ()
96 return {
@@ -182,8 +179,11 @@ local is_container = function(filetype, node)
182179end
183180
184181local 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
You can’t perform that action at this time.
0 commit comments