Closed danielo515 closed 1 year ago
+1 on this, I was trying it for 30 minutes, wondering why it's not working
paste_on_remote_yank
works fine for me on 748b261 with this setup and default leap
bindings.
config = function()
require("leap-spooky").setup({
paste_on_remote_yank = true,
})
end,
What's in your configs?
I'm on the same commit, using lazy.nvim
, and this is what I have:
{
'ggandor/leap-spooky.nvim',
event = 'BufReadPost',
dependencies = { 'leap.nvim' },
opts = {
paste_on_remote_yank = true,
},
}
Using your config worked for me as well. What's your leap config and what mappings are you using for spooky motions, and what Nvim version?
My nvim version is 0.8.3
My leap
config is also very basic (I haven't set up its default mappings, and I want to use it in the context of spooky)
{
'ggandor/leap.nvim',
config = function()
vim.api.nvim_set_hl(0, 'LeapBackdrop', { link = 'Comment' }) -- grey out search area
end,
}
As for the mappings, I'm trying, for example, doing yrr
, then the leap search (2 char, marker, jump). The line is indeed yanked, but it isn't pasted
This is my also very basic (IMO) config:
return {
"ggandor/leap-spooky.nvim",
requires = "ggandor/leap.nvim",
config = function()
require("leap-spooky").setup {
affixes = {
-- These will generate mappings for all native text objects, like:
-- (ir|ar|iR|aR|im|am|iM|aM){obj}.
-- E.g `darw` for delete a remote word
-- Special line objects will also be added, by repeating the affixes.
-- E.g. `yrr<leap>` and `ymm<leap>` will yank a line in the current
-- window.
-- You can also use 'rest' & 'move' as mnemonics.
remote = { window = "r", cross_window = "R" },
-- magnetic means you are going to move to the position where you are yanking
magnetic = { window = "m", cross_window = "M" },
},
-- If this option is set to true, the yanked text will automatically be pasted
-- at the cursor position if the unnamed register is in use.
paste_on_remote_yank = true,
}
end,
}
Yeah, I think our setups are the same (if I'm not mistaken, the values you have for affixes
are the defaults, and that's why I didn't add them, so I think, basically we have the same configuration. So confused as to why it works for you and not me 🤔
@farzadmf Have you tried without lazy.nvim
, calling setup
manually?
This feature used to work for me, but stopped at some point in the last couple of weeks. I've been making heavy changes in my config over this time (including migration to lazy.nvim
). So after reading this thread I thought this may be due to lazy.nvim
indeed. Turns out, the problem is the default register used for yanking. For some reason, Spooky pastes only if the target register is "
:
As a part of my migration, I adopted this option from LazyVim
:
This changed my default yanking register to system clipboard (+
) and thus broke Spooky paste.
@taketwo Thanks, good catch!
For some reason, Spooky pastes only if the target register is
"
That is because you never want to allow pasting right away if you use a non-default register - you usually use a named register to accumulate multiple selections, or store yanked stuff to be used later, after certain in-between operations. The thing I missed is that v.clipboard
can actually change the value of the default register.
Thank you @ggandor for fixing this, I guess I had a similar setting somewhere because I am using system clipboard as well
@ggandor Thanks for the explanation and the quick fix! (and the plugin itself, of course)
Yeah, I think our setups are the same (if I'm not mistaken, the values you have for
affixes
are the defaults, and that's why I didn't add them, so I think, basically we have the same configuration. So confused as to why it works for you and not me 🤔
Who says it works for me? I'm commenting here because it does not work for me either.
Who says it works for me? I'm commenting here because it does not work for me either.
Oops, sorry, I mixed up the usernames, and I thought you're the one that has it working.
But I think the recent change actually fixed the issue, and seems to be working for me
I can confirm that, after updating to 0bb68f0 it works for me. Thank you very much! Now I will be able to duplicate code much much faster.
Hello. Thanks for experimenting with this idea for a plugin. My main use case 99% of the times is to bring some remote piece of code to the place I have the cursor, but I always have to do too many keystrokes because after yank, I have to manually paste, which is almost as much work as jumping there using normal motion, yank,
c-o
to get back and then paste. Will be cool to be able to enablepaste_on_remote_yank
for everything. And, I never got it working, not sure how it is supposed to be used, if you can explain I will be grateful.