From 197b1f4ca09945dba8a5617bfb33b958fdc69dbb Mon Sep 17 00:00:00 2001 From: Baipyrus Date: Wed, 3 Jul 2024 12:42:15 +0200 Subject: [PATCH] copying extracted data to system clipboard --- lua/keymaps.lua | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lua/keymaps.lua b/lua/keymaps.lua index 55c2df2..4825d2a 100644 --- a/lua/keymaps.lua +++ b/lua/keymaps.lua @@ -83,6 +83,7 @@ end local function global_cmd_yank() -- Prompt user input for expression local inexpr = vim.fn.input 'Enter expression: ' + local outsep = vim.fn.input 'Enter separator: ' -- Get the (selected) lines local lines = nil @@ -98,6 +99,11 @@ local function global_cmd_yank() local extracted = vim.tbl_map(function(value) return value['text'] end, matches) + + -- Concat matches according to separator + local value = table.concat(extracted, outsep) + -- Write to system register + vim.fn.setreg('+', value) end vim.keymap.set({ 'n', 'v' }, 'gy', global_cmd_yank, { desc = '[G]lobal command [Y]ank' })