diff options
| -rw-r--r-- | lua/user/opts.lua | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/lua/user/opts.lua b/lua/user/opts.lua index 3bf5b37..3bf82c7 100644 --- a/lua/user/opts.lua +++ b/lua/user/opts.lua @@ -319,3 +319,33 @@ vim.cmd([[ let &scrollback=s:scroll_value endfunction ]]) + +-- Yank to clipboard in termux +if vim.fn.has('termux') == 1 then + local Job = require('plenary.job') + vim.api.nvim_create_autocmd('TextYankPost', { + pattern = '*', + callback = function() + Job:new({ + command = 'termux-clipboard-set', + writer = vim.fn.getreg('@'), + }):start() + end, + }) +end + +function GetTermuxClipboard() + if vim.fn.has('termux') == 1 then + local sysclip = vim.fn.system('termux-clipboard-get') + if sysclip ~= '@' then + vim.fn.setreg('@', sysclip) + end + end + return '' +end + +if vim.fn.has('termux') == 1 then + vim.cmd('autocmd TextYankPost * call GetTermuxClipboard()') + vim.cmd('noremap <expr> p Paste("p")') + vim.cmd('noremap <expr> P Paste("P")') +end |
