gbprod / yanky.nvim Goto Github PK
View Code? Open in Web Editor NEWImproved Yank and Put functionalities for Neovim
License: Do What The F*ck You Want To Public License
Improved Yank and Put functionalities for Neovim
License: Do What The F*ck You Want To Public License
I ran into conflicts when I was trying to use tmux.nvim since this plugin also tries to hijack P key
Is there any way to have a function to insert arbitrary values into the kill ring? I have a message selector that inserts a value into the " register and would love for it to also insert it into yanky.
Executing :YankyRingHistory
will put the selected text on the last position you yanked from, substituting the last text yanked.
My current config:
use{
'gbprod/yanky.nvim',
config = function()
require("yanky").setup({
picker = {
select = {
action = require("yanky.picker").actions.put("p"),
},
telescope = {
mappings = nil, -- nil to use default mappings
},
},
})
end
}
Just like yoink#canSwap() resolve potential conflict with other famous plugins. (aka. visual-multi-cursor)
Nvim now natively provides vim.highlight.on_yank()
, which seems to have identical outcome as highlight.on_yank
. Perhaps I would consider setting highlight.on_yank
off by default so that it doesn't clash out of the box with config of others.
What do you think?
I found out that to achieve the same behavior as in native nvim, I have to set up like this
local map = vim.keymap.set
map({"n", "x"}, "p", "<Plug>(YankyPutAfter)")
map({"n", "x"}, "P", "<Plug>(YankyPutBefore)")
map({"n", "x"}, "gp", "<Plug>(YankyGPutBefore)")
map({"n", "x"}, "gP", "<Plug>(YankyGPutAfter)")
effectively switching the meanings of gp
and gP
. Then pasting works like in nvim -u NONE
.
Is this a bug or feature?
Hi!
First of all I really love what you did with Yanky. Awesome plugin!
I enabled the new sqlite
storage earlier today and started having lock ups of Neovim pretty consistent.
The lockup itself is caused by some sort of notifying -> triggers error -> tries to notify the error loop.
That part I can fix on my end, but the reason seems to be this error:
E565: Not allowed to change text or change window
I get the lock ups when yanking or deleting lines. About 80% of the time.
It seems the usage of sqlite
is causing this somehow. Any ideas?
Suppose I need to insert time into text, I can do (<c-M>
means ctrl-M)
"=strftime('%c')<C-M>p
In normal mode
With yanky.nvim default mapping of p
, it does not insert "=
register to current text. I have to nunmap p
and "=strftime('%c')<C-M>p
it will work.
The keymap:
vim.keymap.set({ "n", "x" }, "y", "<Plug>(YankyYank)")
-- TODO: do not yank on paste
vim.keymap.set({ "n", "x" }, "p", '<Plug>(YankyPutAfter)')
vim.keymap.set({ "n", "x" }, "P", "<Plug>(YankyPutBefore)")
vim.keymap.set({ "n", "x" }, "gp", "<Plug>(YankyGPutAfter)")
vim.keymap.set({ "n", "x" }, "gP", "<Plug>(YankyGPutBefore)")
The current writing style does not allow the option to be disabled.
:lua options = { system_clipboard = { sync_with_ring = false}}
:lua print(options.system_clipboard and options.system_clipboard.sync_with_ring or true)
-- output: true
:lua print(options.system_clipboard and "aaa" or "bbb")
-- output: aaa
so I want e.g <c-n>
to fallback to normal ctrl_n
or something if it is not in a paste/cycle state
I write something like
local function map_c_n()
if require('yanky').ring.state then
require('yanky').cycle(1)
else
vim.cmd[[execute "normal! \<c-n>"]]
end
end
to remap <c-n>
but it seems ring.state
can only back to nil
if line content is changed. Will it possible back to nil
also if cursor moved out of pasted line ?
Hi,
I've noticed this plugin as well as the other two of yours that I'm using (stay-in-place.nvim, substitue.nvim) have plenery.nvim as a git submodule. The plugin folders are 13MiB each on my computer.
It would be much better to handle it as other plugins do - to instead specify plenery.nvim as a dependency in the README and in the suggested plugin spec.
I get the message Clipboard error : Target STRING not available
when starting neovim with this plugin setup. The message does not appear when I disable yanky in my config.
I found this issue on neovims repo: neovim/neovim#2642
Where the last comment states:
On the off chance someone else still sees this error, you could be using an older yank plugin like https://github.com/svermeulen/vim-easyclip
Moving to something newer like https://github.com/svermeulen/vim-cutlass will avoid these issues.
So I guess there is some configuration that needs to be done plugin side to avoid this
Hi, I would like to setup yanky.nvim
as follows:
local map = vim.keymap.set
map({"n", "x"}, "y", "<Plug>(YankyYank)")
map({"n", "x"}, "P", "<Plug>(YankyPutBefore)")
map({"n", "x"}, "gP", "<Plug>(YankyGPutBefore)")
map({"n", "x"}, "=P", "<Plug>(YankyPutBeforeFilter)")
map({"n", "x"}, "=gP", "<Plug>(YankyGPutBeforeFilter)")
map({"n", "x"}, "p", "<Plug>(YankyPutAfter)")
map({"n", "x"}, "gp", "<Plug>(YankyGPutAfter)")
map({"n", "x"}, "=p", "<Plug>(YankyPutAfterFilter)")
map({"n", "x"}, "=gp", "<Plug>(YankyGPutAfterFilter)")
map("n", "<A-n>", "<Plug>(YankyCycleForward)")
map("n", "<A-p>", "<Plug>(YankyCycleBackward)")
That is, standard p
, P
and gP
work as usual, the =
versions should also indent when pasted and are intended to be used linewise only and for programming.
With this code
void test() {
int a = 1;
int b = 2;
for (int i = 0; i < 10; ++i) {
cout << a;
cout << b;
}
}
copying the two cout
lines linewise, positioning the cursor on the line with for
, I get
for P
:
void test() {
int a = 1;
int b = 2;
cout << a;
cout << b;
for (int i = 0; i < 10; ++i) {
cout << a;
cout << b;
}
}
with cursor on first cout
for gP
:
void test() {
int a = 1;
int b = 2;
cout << a;
cout << b;
for (int i = 0; i < 10; ++i) {
cout << a;
cout << b;
}
}
with cursor before at the beginning of the for
line.
for =P
void test() {
int a = 1;
int b = 2;
cout << a;
cout << b;
for (int i = 0; i < 10; ++i) {
cout << a;
cout << b;
}
}
with cursor on the first cout
.
I would expect =gP
to give me a combination of gP
and =P
, but I get this:
void test() {
int a = 1;
int b = 2;
cout << a;
cout << b;
for (int i = 0; i < 10; ++i) {
cout << a;
cout << b;
}
}
which is neither indented correctly, and the cursor is on the cout << b;
line, instead of on the for
line as in the gP
case.
The same behavior occurs for p
. When I copy the two int
definition lines, position the cursor on the for
line, and perform =gp
, I get
void test() {
int a = 1;
int b = 2;
for (int i = 0; i < 10; ++i) {
int a = 1;
int b = 2;
cout << a;
cout << b;
}
}
with cursor on the pasted int b = 2;
instead of one more line below.
I'm using the treesitter indentation, but I tested all wrongly indented examples and =ip
indents everything correctly, so =
should work properly.
Thank you!
I would like to run Cycle only right after <Plug>(YankyPutAfter)
.
For example, in yankround.vim, I can use yankround#is_active()
to fall back to another map if not immediately after put.
https://github.com/LeafCage/yankround.vim
nnoremap <Plug>(ctrl-p) <Nop>
nmap <C-p> <Plug>(ctrl-p)
nnoremap <Plug>(ctrl-n) <Nop>
nmap <C-n> <Plug>(ctrl-n)
nmap <expr> <C-p> yankround#is_active() ? '<Plug>(yankround-prev)' : '<Plug>(ctrl-p)'
nmap <expr> <C-n> yankround#is_active() ? '<Plug>(yankround-next)' : '<Plug>(ctrl-n)'
nnoremap <Plug>(ctrl-n) <Cmd>OtherPluginMap1<CR>
nnoremap <Plug>(ctrl-p) <Cmd>OtherPluginMap2<CR>
When I use yanky as a extension of telessope, I find a keymapping conflict that is bound to telescope.actions.move_selection_previous and also to yanky.telescope.mapping.put("p") as default. When I hit , the selected item just being pasted, which is not I expect. I want to know if there a solution for this keymap conflict, Thanks.
Here is my telescope config:
local status_ok, telescope = pcall(require, "telescope")
if not status_ok then
return
end
telescope.load_extension "file_browser"
telescope.load_extension "yank_history"
local actions = require "telescope.actions"
telescope.setup {
defaults = {
prompt_prefix = " ",
selection_caret = " ",
path_display = { "smart" },
color_devicons = true,
scroll_strategy = 'cycle',
sorting_strategy = 'ascending',
-- file_ignore_patterns = ignore_these,
layout_strategy = 'flex',
layout_config = {
prompt_position = 'bottom',
horizontal = {
mirror = false,
preview_cutoff = 80,
preview_width = 0.5,
},
vertical = {
mirror = true,
preview_cutoff = 0.4,
},
flex = {
flip_columns = 110,
},
height = 0.94,
width = 0.86,
},
mappings = {
i = {
["<C-n>"] = actions.cycle_history_next,
["<C-p>"] = actions.cycle_history_prev,
["<C-j>"] = actions.move_selection_next,
["<C-k>"] = actions.move_selection_previous,
["<C-c>"] = actions.close,
["<Down>"] = actions.move_selection_next,
["<Up>"] = actions.move_selection_previous,
["<CR>"] = actions.select_default,
["<C-x>"] = actions.select_horizontal,
["<C-v>"] = actions.select_vertical,
["<C-t>"] = actions.select_tab,
["<C-u>"] = actions.preview_scrolling_up,
["<C-d>"] = actions.preview_scrolling_down,
["<PageUp>"] = actions.results_scrolling_up,
["<PageDown>"] = actions.results_scrolling_down,
["<Tab>"] = actions.toggle_selection + actions.move_selection_worse,
["<S-Tab>"] = actions.toggle_selection + actions.move_selection_better,
["<C-q>"] = actions.send_to_qflist + actions.open_qflist,
["<M-q>"] = actions.send_selected_to_qflist + actions.open_qflist,
["<C-l>"] = actions.complete_tag,
["<C-/>"] = actions.which_key, -- keys from pressing <C-/>
},
n = {
["<esc>"] = actions.close,
["<CR>"] = actions.select_default,
["<C-x>"] = actions.select_horizontal,
["<C-v>"] = actions.select_vertical,
["<C-t>"] = actions.select_tab,
["<Tab>"] = actions.toggle_selection + actions.move_selection_worse,
["<S-Tab>"] = actions.toggle_selection + actions.move_selection_better,
["<C-q>"] = actions.send_to_qflist + actions.open_qflist,
["<M-q>"] = actions.send_selected_to_qflist + actions.open_qflist,
["j"] = actions.move_selection_next,
["k"] = actions.move_selection_previous,
["H"] = actions.move_to_top,
["M"] = actions.move_to_middle,
["L"] = actions.move_to_bottom,
["<Down>"] = actions.move_selection_next,
["<Up>"] = actions.move_selection_previous,
["gg"] = actions.move_to_top,
["G"] = actions.move_to_bottom,
["<C-u>"] = actions.preview_scrolling_up,
["<C-d>"] = actions.preview_scrolling_down,
["<PageUp>"] = actions.results_scrolling_up,
["<PageDown>"] = actions.results_scrolling_down,
["?"] = actions.which_key,
},
},
},
-- pickers = {
-- Default configuration for builtin pickers goes here:
-- picker_name = {
-- picker_config_key = value,
-- ...
-- }
-- Now the picker_config_key will be applied every time you call this
-- builtin picker
-- },
extensions = {
file_browser = {
theme = "ivy",
-- disables netrw and use telescope-file-browser in its place
hijack_netrw = true,
mappings = {
["i"] = {
-- your custom insert mode mappings
},
["n"] = {
-- your custom normal mode mappings
},
},
},
-- Your extension configuration goes here:
-- extension_name = {
-- extension_config_key = value,
-- }
-- please take a look at the readme of the extension you want to configure
},
}
and here is my yanky config:
local status_ok, yanky = pcall(require, "yanky")
if not status_ok then
return
end
local actions = require "telescope.actions"
local mapping = require "yanky.telescope.mapping"
yanky.setup {
ring = {
history_length = 10,
storage = "shada",
sync_with_numbered_registers = true,
},
picker = {
select = {
action = {
}, -- nil to use default put action
},
telescope = {
mappings = {
default = mapping.put("p"),
i = {
["<C-j>"] = actions.move_selection_next,
["<C-k>"] = actions.move_selection_previous,
}
}
},
},
system_clipboard = {
sync_with_ring = true,
},
highlight = {
on_put = true,
on_yank = true,
timer = 500,
},
preserve_cursor_position = {
enabled = true,
},
}
After updating neovim
to its latest nightly
, getting this warning
vim.highlight.link
is deprecated, usevim.api.nvim_set_hl
instead. See :h deprecated
This function will be removed in Nvim version 0.9
Are we going to do something for this?
Good day! I love this plugin and use it every day but there is 1 feature that I think would push it over the top: previews in the Ring History similar to neoclip
I do not know how difficult that would be with telescope but I think it'd be great!
Thanks again for the great work on this plugin!
Thanks for the fix, I'll try to improve error handling using `vim.schedule` or `pcall`.
Originally posted by @gbprod in #56 (comment)
As mentioned in the subject line, when I call YankRingHistory
command after selecting the whole line(including newline char) throws following error
However if the line does not have a new line character, this issue is not seen.
My lua config:
use({
"stevearc/dressing.nvim",
after = { "yanky.nvim" },
disable = false,
event = "BufEnter",
config = function() require("dressing").setup() end
})
use({
"gbprod/yanky.nvim",
disable = false,
event = "BufEnter",
-- after = "dressing",
config = function()
require("yanky").setup({
highlight = {
on_put = true,
on_yank = true,
timer = 200,
},
preserve_cursor_position = {
enabled = true,
},
})
vim.keymap.set("n", "p", "<Plug>(YankyPutAfter)", {})
vim.keymap.set("n", "P", "<Plug>(YankyPutBefore)", {})
vim.keymap.set("x", "p", "<Plug>(YankyPutAfter)", {})
vim.keymap.set("x", "P", "<Plug>(YankyPutBefore)", {})
vim.keymap.set("n", "gp", "<Plug>(YankyGPutAfter)", {})
vim.keymap.set("n", "gP", "<Plug>(YankyGPutBefore)", {})
vim.keymap.set("x", "gp", "<Plug>(YankyGPutAfter)", {})
vim.keymap.set("x", "gP", "<Plug>(YankyGPutBefore)", {})
end
})
:telescope yank_history
works but ...
when I select an entry from the list I get this error.
E5108: Error executing lua .../packer/start/yanky.nvim/lua/yanky/telescope/mapping.lua:11: attempt to call field 'make_put_handler' (a nil value)
stack traceback:
.../packer/start/yanky.nvim/lua/yanky/telescope/mapping.lua:11: in function 'run_replace_or_original'
...packer/start/telescope.nvim/lua/telescope/actions/mt.lua:65: in function 'key_func'
...k/packer/start/telescope.nvim/lua/telescope/mappings.lua:242: in function 'execute_keymap'
[string ":lua"]:1: in main chunk
My Settings:
require("yanky").setup({
ring = {
history_length = 10,
storage = "shada",
sync_with_numbered_registers = true,
},
picker = {
select = {
action = nil, -- nil to use default put action
},
telescope = {
mappings = nil, -- nil to use default mappings
},
},
system_clipboard = {
sync_with_ring = true,
},
highlight = {
on_put = true,
on_yank = true,
timer = 500,
},
preserve_cursor_position = {
enabled = true,
},
})
vim.api.nvim_set_keymap("n", "p", "<Plug>(YankyPutAfter)", {})
vim.api.nvim_set_keymap("n", "P", "<Plug>(YankyPutBefore)", {})
vim.api.nvim_set_keymap("x", "p", "<Plug>(YankyPutAfter)", {})
vim.api.nvim_set_keymap("x", "P", "<Plug>(YankyPutBefore)", {})
vim.api.nvim_set_keymap("n", "gp", "<Plug>(YankyGPutAfter)", {})
vim.api.nvim_set_keymap("n", "gP", "<Plug>(YankyGPutBefore)", {})
vim.api.nvim_set_keymap("x", "gp", "<Plug>(YankyGPutAfter)", {})
vim.api.nvim_set_keymap("x", "gP", "<Plug>(YankyGPutBefore)", {})
vim.api.nvim_set_keymap("n", "<c-n>", "<Plug>(YankyCycleForward)", {})
vim.api.nvim_set_keymap("n", "<c-p>", "<Plug>(YankyCycleBackward)", {})
require("telescope").load_extension("yank_history")
'yy' works properly - copy whole line.
The command 'Y' is synonym of 'yy', but it copies line from cursor to end of line.
Hi
Thanks for yanky.
“I occasionally do a linewise yank, and then want to insert that yanked text in the middle of some other line (or vice versa).”
I use the UnconditionalPaste plugin for this and would like to use some of it’s functionality from yanky.
I can’t see how but perhaps it’s possible to use now with config changes ?
Would you see this as integration or would you consider adding the ability to have options do the character-, line-, or block-wise paste ?
Cheers
yanky.nvim config:
require('yanky').setup({})
vim.keymap.set('n', 'p', '<Plug>(YankyPutAfter)', {})
vim.keymap.set('n', 'P', '<Plug>(YankyPutBefore)', {})
vim.keymap.set('x', 'p', '<Plug>(YankyPutAfter)', {})
vim.keymap.set('x', 'P', '<Plug>(YankyPutBefore)', {})
vim.keymap.set('n', 'gp', '<Plug>(YankyGPutAfter)', {})
vim.keymap.set('n', 'gP', '<Plug>(YankyGPutBefore)', {})
vim.keymap.set('x', 'gp', '<Plug>(YankyGPutAfter)', {})
vim.keymap.set('x', 'gP', '<Plug>(YankyGPutBefore)', {})
vim.keymap.set('n', '<c-n>', '<Plug>(YankyCycleForward)', {})
vim.keymap.set('n', '<c-p>', '<Plug>(YankyCycleBackward)', {})
require("telescope").load_extension("yank_history")
Neovim version:
NVIM v0.7.0
Build type: Release
LuaJIT 2.1.0-beta3
Compiled by builduser
Features: +acl +iconv +tui
See ":help feature-compile"
system vimrc file: "$VIM/sysinit.vim"
fall-back for $VIM: "/usr/share/nvim"
Run :checkhealth for more info
OS info:
OS: Arch Linux x86_64
Kernel: 5.18.1-arch1-1
DE: Plasma 5.24.5
Graphics platform: X11
Is there any way to make this compatible with https://github.com/vim-scripts/ReplaceWithRegister? At the moment it will warn that Your last action was not put, ignoring cycle
when replacing the text rather than putting it. Thanks in advance, cool plugin!
I generally find that when I use the yank ring and paste mutliple times in a row I usually want to paste from the same position in the yank ring. Therefore I would personally like if the yank ring remembered my position between pastes. For example, if I yank the word foo
, then yank bar
, then paste with <Plug>(YankyPutAfter)
(bar
) and then cycle with <Plug>(YankyCycleForward)
(foo
), the next time I paste I would like yanky to paste foo
again (currently it would paste bar
).
If anything new is added to the paste ring (i.e. if I yank something) yanky would reset the ring position to the latest yanked item. What do you think about this idea?
Hello gbprod! Big fan of your plugin series (substitute.nvim
, cutlass.nvim
, yanky.nvim
(not so much due to this annoying bug)).
Since I have more than 100 plugins it's very difficult to isolate the cause of this nvim freezing. Initially it was only a hunch that yanky
was the cause, since I can't reliably reproduce this freezing. So I disabled yanky
and went about using nvim, no problem. Then I enabled yanky
and nvim would freeze randomly. By freeze I mean I can't enter nvim. nvim would freeze while opening files.
I tried my best to isolate the cause for more than a month, and I finally captured it in video:
vim init.lua
(I have aliased vim with nvim)init.lua
without any issueyanky.nvim
vim init.lua
againAnother video:
yanky
enabled. nvim used to freeze randomly but this morning it freezes every time with yanky
enabledvim -u NONE init.lua
to enter nvim and disable yanky
I suspect this freezing is due to xclip
. nvim used to freeze randomly but this morning it froze every time. The only change I have is manually compiling xclip from xclip/master. I had some other issues with xclip unrelated to nvim so tested with compiling the latest version. I used to use xclip 0.13.
Interestingly, I tried yoink.vim
and this random freezing also happened. With the advice from vim-yoink/issues/16, I used xsel
instead of xclip
and this random freezing seemed to happen less:
severe freezing like videos above: compiling from xclip/master
random freezing here and there: xclip
version 0.13 or xsel
The reason I used yanky
is for its yank-ring feature. Because, sigh, my nvim would freeze randomly with the following:
I couldn't capture the above in video because it happens randomly.
nvim config:
NVIM v0.7.0
Build type: Release
LuaJIT 2.1.0-beta3
Compiled by builduser
OS: Manjaro Linux
Kernel: 5.15.41-1-MANJARO
I tried compiling nvim to the latest 0.8 version and this freezing still happened.
Any help is much appreciated. Thank you again for creating this awesome nvim plugin series:)
I'm able to reproduce this even with minconfig:
-- nvim --clean -u mini.lua mini.lua
vim.o.packpath = '~/.local/share/nvim/site'
vim.cmd 'packadd yanky'
require('yanky').setup({})
I'm using nvim 7.2
and Fedora 36 with Wayland.
Would it be possible to also add actions like YankyGPutIndentAfter
and YankyGPutIndentBefore
?
One of the vim-easyclip
's useful features is to automatically format text immediately after paste. It's very useful, but not usable with yanky.
It is slightly different than PutIndent*
because the pasted lines do not necessarily have the same indentation as the current line. They can have an extra indent depending on the context.
For example, if the text let a = 1
is pasted when the cursor is on the second line in this example:
function f(flag) {
if (flag === true) { // <= cursor is on this line
}
}
the expected result would be:
function f() {
if (flag === true) {
let a = 1
}
}
with YankyPutIndentAfter
, we get this:
function f() {
if (flag === true) {
let a = 1
}
}
Note: the request is not to change the behavior of YankyPutIndent*
but to add a new option to auto format pasted lines.
It would be awesome to send to specific registers when using YankyYank
.
I use https://github.com/christoomey/vim-system-copy, and have different mappings for the normal register and the system (global) register.
It would be awesome to have separate keymaps, but also use the preserve cursor feature! for both.
Given a config like the following packer config:
(use {1 "gbprod/yanky.nvim"
:config #(let [yanky (require :yanky)]
(yanky.setup))})
(use {1 "telescope-nvim/telescope.nvim"
:requires ["gbprod/yanky.nvim"]
:config #(let [ts (require :telescope)]
(ts.setup {})
(ts.load_extension "yank_history"))})
I would expect that yanky initializes before telescope does given that yanky is a dependency of telescope.
It seems like a race condition for which :config function runs first. Some loads it's fine, other times I get an error about yank_history not existing at the time the load_extension
call fires.
It's possible I'm just being a super noob here and using the wrong packer API here but based on the docs that seems like how it should work?
Please let me know if the fennel is too unfamiliar, I can convert it back to lua if needed.
I will log here news and api changes, feel free to subscribe to this issue.
E5108: Error executing lua ...e/pack/packer/opt/yanky.nvim/lua/yanky/storage/shada.lua:23: attempt to get length of fi
eld 'YANKY_HISTORY' (a nil value)
stack traceback:
...e/pack/packer/opt/yanky.nvim/lua/yanky/storage/shada.lua:23: in function 'length'
...im/site/pack/packer/opt/yanky.nvim/lua/yanky/history.lua:38: in function 'first'
...share/nvim/site/pack/packer/opt/yanky.nvim/lua/yanky.lua:87: in function 'put'
[string ":lua"]:1: in main chunk
setup
keys = {
"<C-v>",
"<Plug>(YankyPutAfter)",
"<Plug>(YankyPutBefore)",
"<Plug>(YankyPutAfter)",
"<Plug>(YankyPutBefore)",
"<Plug>(YankyGPutAfter)",
"<Plug>(YankyGPutBefore)",
"<Plug>(YankyGPutAfter)",
"<Plug>(YankyGPutBefore)",
"<Plug>(YankyCycleForward)",
"<Plug>(YankyCycleBackward)",
},
setup = function()
local default_keymaps = {
{ "n", "p", "<Plug>(YankyPutAfter)" },
{ "n", "P", "<Plug>(YankyPutBefore)" },
{ "x", "p", "<Plug>(YankyPutAfter)" },
{ "x", "P", "<Plug>(YankyPutBefore)" },
{ "n", "<leader>p", "<Plug>(YankyGPutAfter)" },
{ "n", "<leader>P", "<Plug>(YankyGPutBefore)" },
{ "x", "<leader>p", "<Plug>(YankyGPutAfter)" },
{ "x", "<leader>P", "<Plug>(YankyGPutBefore)" },
{ "n", "<Leader>n", "<Plug>(YankyCycleForward)" },
{ "n", "<Leader>N", "<Plug>(YankyCycleBackward)" },
}
for _, m in ipairs(default_keymaps) do
vim.keymap.set(m[1], m[2], m[3], {})
end
end,
config = function()
require("yanky").setup({
ring = {
history_length = 10,
storage = "shada",
},
})
end,
Hello, thanks for the plugin !
I have an error when trying to use yanky to paste (using p
).
E5108: Error executing lua: ...ite/pack/packer/start/yanky.nvim/lua/yanky/highlight.lua:36: attempt to index field 'config' (a nil value)
stack traceback:
...ite/pack/packer/start/yanky.nvim/lua/yanky/highlight.lua:36: in function 'highlight_put'
...are/nvim/site/pack/packer/start/yanky.nvim/lua/yanky.lua:77: in function 'callback'
...are/nvim/site/pack/packer/start/yanky.nvim/lua/yanky.lua:141: in function 'init_ring'
...are/nvim/site/pack/packer/start/yanky.nvim/lua/yanky.lua:90: in function 'put'
...are/nvim/site/pack/packer/start/yanky.nvim/lua/yanky.lua:267: in function <...are/nvim/site/pack/packer/start/yanky.nvim/lua/yanky.lua:266>
I have NVIM v0.9.0-dev
. I tried on a remote machine with NVIM v0.8.0
and I have the same problem.
I put in my init.lua
use({
"gbprod/yanky.nvim",
config = function()
require("yanky").setup({
-- your configuration comes here
-- or leave it empty to use the default settings
-- refer to the configuration section below
})
end
})
and
vim.keymap.set({"n","x"}, "p", "<Plug>(YankyPutAfter)")
vim.keymap.set({"n","x"}, "P", "<Plug>(YankyPutBefore)")
vim.keymap.set({"n","x"}, "gp", "<Plug>(YankyGPutAfter)")
vim.keymap.set({"n","x"}, "gP", "<Plug>(YankyGPutBefore)")
Any idea what could be causing this ?
One of vim-unimpaired
's useful features is to force pasting below or above the current line, while preserving indents. It's very useful, but not usable with yanky
.
The expected behavior for [p
and ]p
would be that every item is forced line-wise, but any character-wise yanks beyond the first item get inserted character-wise.
Steps to reproduce:
[p
<C-p>
Use any color scheme
Change colorscheme e.g. colorscheme default
:hi YankyYanked
YankyYanked xxx cleared
Miminal example, save the folliwing in putcharwise.vim
let s:plug_dir = expand('/tmp/plugged/vim-plug')
if !filereadable(s:plug_dir .. '/plug.vim')
execute printf('!curl -fLo %s/autoload/plug.vim --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim', s:plug_dir)
end
execute 'set runtimepath+=' . s:plug_dir
call plug#begin(s:plug_dir)
Plug 'gbprod/yanky.nvim'
call plug#end()
PlugInstall | quit
" Setup global configuration. More on configuration below.
lua << EOF
require('yanky').setup()
vim.keymap.set('n', 'cp', '<Plug>(YankyPutAfterCharwiseJoined)')
vim.keymap.set('n', 'cP', '<Plug>(YankyPutAfterCharwise)')
EOF
Runnvim --clean -u putcharwise.vim
.
Open a new buffer, type ilol<Esc>yiwo<Esc>cp
and lol
is inserted twice.
The content of the register seems correct, and cP
works correctly, too, so the problem seems to be in the 'Joined' implementation.
Quick grepping indicates this might be the significant code:
function wrappers.trim_and_join_lines(next)
return function(state, callback)
local body = vim.fn.getreg(state.register)
local reformated_body = body:gsub("%s*\r?\n%s*", " "):gsub("^%s*", ""):gsub("%s*$", "")
vim.fn.setreg(state.register, reformated_body, vim.fn.getregtype(state.register))
if nil == next then
callback(state)
else
next(state, callback)
end
callback(state)
vim.fn.setreg(state.register, body, vim.fn.getregtype(state.register))
end
end
My suspicion is that calling callback(state)
twice is the problem, is that possible?
Looks like this broke in
#74
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.