aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/lua/vim.lua
diff options
context:
space:
mode:
authorJustin M. Keyes <justinkz@gmail.com>2019-08-21 01:55:12 +0200
committerJustin M. Keyes <justinkz@gmail.com>2019-08-27 21:19:10 +0200
commit5ae6849517d2a025c3359e771ac1e01a68ec24c8 (patch)
treee0aed7c5a93206235ed1304079f6201f6d07ad2e /src/nvim/lua/vim.lua
parent93e5f0235b8e85423d0284231661ba4b0d7caa07 (diff)
downloadrneovim-5ae6849517d2a025c3359e771ac1e01a68ec24c8.tar.gz
rneovim-5ae6849517d2a025c3359e771ac1e01a68ec24c8.tar.bz2
rneovim-5ae6849517d2a025c3359e771ac1e01a68ec24c8.zip
paste: phases, dots
- Send `phase` parameter to the paste handler. - Redraw at intervals and when paste terminates. - Show "..." throbber during paste to indicate activity.
Diffstat (limited to 'src/nvim/lua/vim.lua')
-rw-r--r--src/nvim/lua/vim.lua46
1 files changed, 33 insertions, 13 deletions
diff --git a/src/nvim/lua/vim.lua b/src/nvim/lua/vim.lua
index 0b94417b3e..dca61d814a 100644
--- a/src/nvim/lua/vim.lua
+++ b/src/nvim/lua/vim.lua
@@ -94,19 +94,39 @@ local function _os_proc_children(ppid)
end
-- Default paste function.
-local function _paste(lines)
- -- local eof = (lines == {''})
- local call = vim.api.nvim_call_function
- local mode = call('mode', {})
- local curline = call('line', {'.'})
- -- vim.api.nvim_set_option('paste', true)
- vim.api.nvim_put(lines, 'c', true, true)
- -- vim.api.nvim_set_option('paste', false)
- -- TODO: do not redraw (slow!) until paste is finished.
- -- if eof then
- vim.api.nvim_command('redraw')
- return true -- Paste will not continue if not returning `true`.
-end
+local _paste = (function()
+ local tdots = 0
+ local tredraw = 0
+ local tick = 0
+ return function(lines, phase)
+ local call = vim.api.nvim_call_function
+ local now = vim.loop.now()
+ if phase == 1 then
+ tdots = now
+ tredraw = now
+ tick = 0
+ if (call('mode', {})):find('[vV]') then
+ vim.api.nvim_feedkeys('', 'n', false)
+ end
+ end
+ vim.api.nvim_put(lines, 'c', true, true)
+ if (now - tredraw >= 1000) or phase == 1 or phase == 3 then
+ tredraw = now
+ vim.api.nvim_command('redraw')
+ vim.api.nvim_command('redrawstatus')
+ end
+ if (now - tdots >= 100) then
+ local dots = ('.'):rep(tick % 4)
+ tdots = now
+ tick = tick + 1
+ vim.api.nvim_command(('echo "%s"'):format(dots))
+ end
+ if phase == 3 then
+ vim.api.nvim_command('echo ""')
+ end
+ return true -- Paste will not continue if not returning `true`.
+ end
+end)()
-- TODO(ZyX-I): Create compatibility layer.
--{{{1 package.path updater function