From 7e7944a30c340319665582cf635aed7678b8a353 Mon Sep 17 00:00:00 2001 From: jdhao Date: Wed, 14 Dec 2022 12:52:40 +0800 Subject: [PATCH] use yanky.nvim to replace vim-yoink (#168) --- core/plugins.vim | 25 ------------------------- lua/config/yanky.lua | 13 +++++++++++++ lua/plugins.lua | 10 +++++++--- 3 files changed, 20 insertions(+), 28 deletions(-) create mode 100644 lua/config/yanky.lua diff --git a/core/plugins.vim b/core/plugins.vim index 5846dba..6125514 100644 --- a/core/plugins.vim +++ b/core/plugins.vim @@ -137,31 +137,6 @@ let g:mundo_width = 80 nnoremap u :MundoToggle -""""""""""""""""""""""""""""vim-yoink settings""""""""""""""""""""""""" -if g:is_win || g:is_mac - " ctrl-n and ctrl-p will not work if you add the TextChanged event to vim-auto-save events. - " nmap (YoinkPostPasteSwapBack) - " nmap (YoinkPostPasteSwapForward) - - " The following p/P mappings are also needed for ctrl-n and ctrl-p to work - " nmap p (YoinkPaste_p) - " nmap P (YoinkPaste_P) - - " Cycle the yank stack with the following mappings - nmap [y (YoinkRotateBack) - nmap ]y (YoinkRotateForward) - - " Do not change the cursor position - nmap y (YoinkYankPreserveCursorPosition) - xmap y (YoinkYankPreserveCursorPosition) - - " Move cursor to end of paste after multiline paste - let g:yoinkMoveCursorToEndOfPaste = 0 - - " Record yanks in system clipboard - let g:yoinkSyncSystemClipboardOnFocus = 1 -endif - """"""""""""""""""""""""""""better-escape.vim settings""""""""""""""""""""""""" let g:better_escape_interval = 200 diff --git a/lua/config/yanky.lua b/lua/config/yanky.lua new file mode 100644 index 0000000..0f8eceb --- /dev/null +++ b/lua/config/yanky.lua @@ -0,0 +1,13 @@ +require("yanky").setup({ + ring = { + history_length = 50, + storage = "memory", + }, + preserve_cursor_position = { + enabled = false, + }, +}) + +-- cycle through the yank history, only work after paste +vim.keymap.set("n", "[y", "(YankyCycleForward)") +vim.keymap.set("n", "]y", "(YankyCycleBackward)") diff --git a/lua/plugins.lua b/lua/plugins.lua index 0ab0f69..bcbfe29 100644 --- a/lua/plugins.lua +++ b/lua/plugins.lua @@ -208,10 +208,14 @@ packer.startup { -- Show undo history visually use { "simnalamburt/vim-mundo", cmd = { "MundoToggle", "MundoShow" } } + -- better UI for some nvim actions + use {'stevearc/dressing.nvim'} + -- Manage your yank history - if vim.g.is_win or vim.g.is_mac then - use { "svermeulen/vim-yoink", event = "VimEnter" } - end + use({ + "gbprod/yanky.nvim", + config = [[require('config.yanky')]] + }) -- Handy unix command inside Vim (Rename, Move etc.) use { "tpope/vim-eunuch", cmd = { "Rename", "Delete" } }