mirror of
https://github.com/neovim/neovim.git
synced 2025-10-06 01:46:29 +00:00
feat(tui): native progress bars for Progress events #35973
This commit is contained in:
@@ -676,7 +676,7 @@ do
|
||||
end,
|
||||
})
|
||||
|
||||
-- Only do the following when the TUI is attached
|
||||
-- Check if a TTY is attached
|
||||
local tty = nil
|
||||
for _, ui in ipairs(vim.api.nvim_list_uis()) do
|
||||
if ui.chan == 1 and ui.stdout_tty then
|
||||
@@ -974,6 +974,21 @@ do
|
||||
end
|
||||
end,
|
||||
})
|
||||
|
||||
if tty then
|
||||
-- Show progress bars in supporting terminals
|
||||
vim.api.nvim_create_autocmd('Progress', {
|
||||
group = vim.api.nvim_create_augroup('nvim.progress', {}),
|
||||
desc = 'Display native progress bars',
|
||||
callback = function(ev)
|
||||
if ev.data.status == 'running' then
|
||||
vim.api.nvim_ui_send(string.format('\027]9;4;1;%d\027\\', ev.data.percent))
|
||||
else
|
||||
vim.api.nvim_ui_send('\027]9;4;0;0\027\\')
|
||||
end
|
||||
end,
|
||||
})
|
||||
end
|
||||
end
|
||||
|
||||
--- Default options
|
||||
|
Reference in New Issue
Block a user