Open timoleistner opened 2 years ago
This would definitely be an amazing addition.. I'll have a look at it and will try to come up with something workable :)
I use succesfully the following snippet.
local is = require("nvim-treesitter.incremental_selection")
local function treesitter_selection()
is.init_selection()
is.node_incremental()
end
require("iron").core.visual_send(vim.bo.ft, treesitter_selection)
local is = require("nvim-treesitter.incremental_selection") local function treesitter_selection() is.init_selection() is.node_incremental() end require("iron").core.visual_send(vim.bo.ft, treesitter_selection)
I might be mistaken, but it seems that visual_send
doesn't take any arguments. Am I missing something?
Not entirely sure this is needed at repl level given searching / selecting treesitter object is a non-trivial task and can be used beyond the scope of repl. This is actually implemented neatly by motion plugins:
Some simple keymap would achieve what is requested. e..g,
vim.keymap.set(
{ "n" },
"gt",
function()
vim.cmd('normal V')
require("leap.treesitter").select()
require("iron.core").visual_send()
vim.cmd("norm! j")
end,
{ desc = "send treesitter textobj" }
)
In my opinion, we could simply update the README
instead of reinvent the wheel.
I was thinking about sending the output of a treesitter.textobjects command to irons REPL but I fear my lua skills aren't there yet. I tried this
:lua require('iron').core.send(vim.bo.ft, require'nvim-treesitter.textobjects.select'.select_textobject('@function.outer', 'o'))
and thisrequire("iron").core.visual_send(vim.bo.ft, require'nvim-treesitter.textobjects.select'.select_textobject('@function.outer', 'o'))
without success and I dont really understand whats meant with "data" in the documentation, help about this would be appreciated. If it is feasible it would be nice to have native support for treesitter objects :)