feat(tui): native progress bars for Progress events #35973

This commit is contained in:
Gregory Anders
2025-10-02 16:51:26 -05:00
committed by GitHub
parent 28ccebd138
commit 8eb0964537
3 changed files with 25 additions and 4 deletions

View File

@@ -327,6 +327,8 @@ TREESITTER
TUI TUI
• |TermResponse| now supports DA1 and APC query responses. • |TermResponse| now supports DA1 and APC query responses.
• Native progress bars are displayed for |Progress| events using the OSC 9;4
sequence.
UI UI

View File

@@ -200,17 +200,21 @@ nvim.terminal:
- |[[| and |]]| to navigate between shell prompts - |[[| and |]]| to navigate between shell prompts
nvim.cmdwin: nvim.cmdwin:
- CmdwinEnter: Limits syntax sync to maxlines=1 in the |cmdwin|. - |CmdwinEnter|: Limits syntax sync to maxlines=1 in the |cmdwin|.
nvim.swapfile: nvim.swapfile:
- SwapExists: Skips the swapfile prompt (sets |v:swapchoice| to "e") when the - |SwapExists|: Skips the swapfile prompt (sets |v:swapchoice| to "e") when the
swapfile is owned by a running Nvim process. Shows |W325| "Ignoring swapfile is owned by a running Nvim process. Shows |W325| "Ignoring
swapfile…" message. swapfile…" message.
nvim.exrc: nvim.exrc:
- VimEnter: Extend 'exrc' to also search for project-local configuration files - |VimEnter|: Extend 'exrc' to also search for project-local configuration files
in all parent directories. in all parent directories.
nvim.progress:
- |Progress|: Display native progress bars in the TUI using the OSC 9;4 escape
sequence.
============================================================================== ==============================================================================
New Features *nvim-features* New Features *nvim-features*

View File

@@ -676,7 +676,7 @@ do
end, end,
}) })
-- Only do the following when the TUI is attached -- Check if a TTY is attached
local tty = nil local tty = nil
for _, ui in ipairs(vim.api.nvim_list_uis()) do for _, ui in ipairs(vim.api.nvim_list_uis()) do
if ui.chan == 1 and ui.stdout_tty then if ui.chan == 1 and ui.stdout_tty then
@@ -974,6 +974,21 @@ do
end end
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 end
--- Default options --- Default options