Skip to content

Commit

Permalink
Use the new get_node_text in nvim 0.7 but rely on older code in older…
Browse files Browse the repository at this point in the history
… nvim
  • Loading branch information
Olical committed Apr 24, 2022
1 parent 9be3db4 commit 251d8ef
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
5 changes: 4 additions & 1 deletion fnl/conjure/tree-sitter.fnl
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,10 @@
"Turn the node into a string, nils flow through. Separate forms are joined by
new lines."
(when node
(vim.treesitter.query.get_node_text node (nvim.get_current_buf))))
(if (= 1 (nvim.fn.has "nvim-0.7"))
(vim.treesitter.query.get_node_text node (nvim.get_current_buf))
(-> (vim.treesitter.query.get_node_text node)
(->> (str.join "\n"))))))

(defn parent [node]
"Get the parent if possible."
Expand Down
6 changes: 5 additions & 1 deletion lua/conjure/tree-sitter.lua
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,11 @@ end
_2amodule_2a["enabled?"] = enabled_3f
local function node__3estr(node)
if node then
return vim.treesitter.query.get_node_text(node, nvim.get_current_buf())
if (1 == nvim.fn.has("nvim-0.7")) then
return vim.treesitter.query.get_node_text(node, nvim.get_current_buf())
else
return str.join("\n", vim.treesitter.query.get_node_text(node))
end
else
return nil
end
Expand Down

0 comments on commit 251d8ef

Please sign in to comment.