Mercurial > dotfiles
comparison .chezmoitemplates/init.lua @ 619:6bd8aecfdaaa
use the updated trim function from nvim-osc52
author | zegervdv <zegervdv@me.com> |
---|---|
date | Tue, 26 Jul 2022 17:12:11 +0200 |
parents | 7d581ebd5508 |
children | 15c9da15a2f5 |
comparison
equal
deleted
inserted
replaced
618:7d581ebd5508 | 619:6bd8aecfdaaa |
---|---|
27 use { 'tpope/vim-rsi' } | 27 use { 'tpope/vim-rsi' } |
28 use { 'sgur/vim-editorconfig' } | 28 use { 'sgur/vim-editorconfig' } |
29 use { | 29 use { |
30 'ojroques/nvim-osc52', | 30 'ojroques/nvim-osc52', |
31 config = function() | 31 config = function() |
32 require('osc52').setup { trim = false } | 32 require('osc52').setup { trim = true } |
33 local copy = function(lines, _) | 33 local copy = function(lines, _) require('osc52').copy(table.concat(lines, '\n')) end |
34 -- Trim indent before copying | |
35 local indent = 0 | |
36 for _, line in ipairs(lines) do | |
37 local index, _ = line:find '[^ ]' | |
38 if index ~= nil then | |
39 indent = index | |
40 break | |
41 end | |
42 end | |
43 if indent ~= nil then | |
44 for key, line in ipairs(lines) do | |
45 lines[key] = line:sub(indent) | |
46 end | |
47 end | |
48 require('osc52').copy(table.concat(lines, '\n')) | |
49 end | |
50 local paste = function() return { vim.fn.split(vim.fn.getreg '', '\n'), vim.fn.getregtype '' } end | 34 local paste = function() return { vim.fn.split(vim.fn.getreg '', '\n'), vim.fn.getregtype '' } end |
51 vim.g.clipboard = { | 35 vim.g.clipboard = { |
52 name = 'osc52', | 36 name = 'osc52', |
53 copy = { ['+'] = copy, ['*'] = copy }, | 37 copy = { ['+'] = copy, ['*'] = copy }, |
54 paste = { ['+'] = paste, ['*'] = paste }, | 38 paste = { ['+'] = paste, ['*'] = paste }, |