Skip to content

Commit 251d8ef

Browse files
committed
Use the new get_node_text in nvim 0.7 but rely on older code in older nvim
1 parent 9be3db4 commit 251d8ef

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

fnl/conjure/tree-sitter.fnl

+4-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,10 @@
3131
"Turn the node into a string, nils flow through. Separate forms are joined by
3232
new lines."
3333
(when node
34-
(vim.treesitter.query.get_node_text node (nvim.get_current_buf))))
34+
(if (= 1 (nvim.fn.has "nvim-0.7"))
35+
(vim.treesitter.query.get_node_text node (nvim.get_current_buf))
36+
(-> (vim.treesitter.query.get_node_text node)
37+
(->> (str.join "\n"))))))
3538

3639
(defn parent [node]
3740
"Get the parent if possible."

lua/conjure/tree-sitter.lua

+5-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,11 @@ end
4545
_2amodule_2a["enabled?"] = enabled_3f
4646
local function node__3estr(node)
4747
if node then
48-
return vim.treesitter.query.get_node_text(node, nvim.get_current_buf())
48+
if (1 == nvim.fn.has("nvim-0.7")) then
49+
return vim.treesitter.query.get_node_text(node, nvim.get_current_buf())
50+
else
51+
return str.join("\n", vim.treesitter.query.get_node_text(node))
52+
end
4953
else
5054
return nil
5155
end

0 commit comments

Comments
 (0)