Closed 10b14224cc closed 4 months ago
Thanks @10b14224cc seems the contributor who added that doc added in a function that doesn't exist so you won't be able to use that example as is. I don't use that functionality so can't guide you specifically as that whole thing was user contributed. You can play around with it to see what works.
check 283-383 from https://github.com/BlueDrink9/env/blob/359f5863e1f4f85a607d883f1dbcdab2bceb0fec/editors/vim/runtimepath/lua/plugins/main.lua#L287
Idk why it needs vimscript inside, but it works. Probably just adding this somewhere in the relevant code will fix the issue.
local set_opfunc = vim.fn[vim.api.nvim_exec(
[[
func s:set_opfunc(val)
let &opfunc = a:val
endfunc
echon get(function('s:set_opfunc'), 'name')
]],
true
)]
check 283-383 from https://github.com/BlueDrink9/env/blob/359f5863e1f4f85a607d883f1dbcdab2bceb0fec/editors/vim/runtimepath/lua/plugins/main.lua#L287
Idk why it needs vimscript inside, but it works. Probably just adding this somewhere in the relevant code will fix the issue.
local set_opfunc = vim.fn[vim.api.nvim_exec( [[ func s:set_opfunc(val) let &opfunc = a:val endfunc echon get(function('s:set_opfunc'), 'name') ]], true )]
Uhm now it works but the cursor is moved one step to the right at the end of the motion for some reason
Here is a pure LUA implementation
-- Send motion
opts["desc"] = "Send motion"
opts["expr"] = true
_G.send_motion = function(motion_type)
require("toggleterm").send_lines_to_terminal(motion_type, false, { args = vim.v.count })
end
_G.send_motion_d = function()
vim.go.operatorfunc = "v:lua.send_motion"
return "g@"
end
vim.keymap.set("n", ll .. "m", send_motion_d, opts)
It still moves the cursor to the right at the end, which I think is due to https://github.com/akinsho/toggleterm.nvim/blob/193786e0371e3286d3bc9aa0079da1cd41beaa62/lua/toggleterm.lua#L253
Is there an existing issue for this?
Current Behavior
I'm putting this keybinding in my config file, as suggested in the README:
But when I issue
<leader>im
I get:Expected Behavior
<leader>imw
should send a word to the terminalSteps To Reproduce
See above
Environment
Anything else?
No response