changeset 615:0cace1b99e77

disable trim on osc52 copy
author zegervdv <zegervdv@me.com>
date Mon, 25 Jul 2022 14:18:02 +0200
parents ad5e870cd4b2
children 08bb1c92e5e5
files .chezmoitemplates/init.lua
diffstat 1 files changed, 9 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/.chezmoitemplates/init.lua	Mon Jul 25 14:09:08 2022 +0200
+++ b/.chezmoitemplates/init.lua	Mon Jul 25 14:18:02 2022 +0200
@@ -29,7 +29,15 @@
   use {
     'ojroques/nvim-osc52',
     config = function()
-      local copy = function(lines, _) require('osc52').copy(table.concat(lines, '\n')) end
+      require('osc52').setup { trim = false }
+      local copy = function(lines, _)
+        -- Trim indent before copying
+        local indent, _ = lines[1]:find '[^ ]'
+        for key, line in ipairs(lines) do
+          lines[key] = line:sub(indent)
+        end
+        require('osc52').copy(table.concat(lines, '\n'))
+      end
       local paste = function() return { vim.fn.split(vim.fn.getreg '', '\n'), vim.fn.getregtype '' } end
       vim.g.clipboard = {
         name = 'osc52',