From 8eb09645378845f163814e2b93924fd08aab65c7 Mon Sep 17 00:00:00 2001 From: Gregory Anders Date: Thu, 2 Oct 2025 16:51:26 -0500 Subject: [PATCH] feat(tui): native progress bars for Progress events #35973 --- runtime/doc/news.txt | 2 ++ runtime/doc/vim_diff.txt | 10 +++++++--- runtime/lua/vim/_defaults.lua | 17 ++++++++++++++++- 3 files changed, 25 insertions(+), 4 deletions(-) diff --git a/runtime/doc/news.txt b/runtime/doc/news.txt index 8ffa70f60e..0dc6193106 100644 --- a/runtime/doc/news.txt +++ b/runtime/doc/news.txt @@ -327,6 +327,8 @@ TREESITTER TUI • |TermResponse| now supports DA1 and APC query responses. +• Native progress bars are displayed for |Progress| events using the OSC 9;4 + sequence. UI diff --git a/runtime/doc/vim_diff.txt b/runtime/doc/vim_diff.txt index 470378d87e..86fc4937be 100644 --- a/runtime/doc/vim_diff.txt +++ b/runtime/doc/vim_diff.txt @@ -200,17 +200,21 @@ nvim.terminal: - |[[| and |]]| to navigate between shell prompts nvim.cmdwin: -- CmdwinEnter: Limits syntax sync to maxlines=1 in the |cmdwin|. +- |CmdwinEnter|: Limits syntax sync to maxlines=1 in the |cmdwin|. 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…" message. 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. +nvim.progress: +- |Progress|: Display native progress bars in the TUI using the OSC 9;4 escape + sequence. + ============================================================================== New Features *nvim-features* diff --git a/runtime/lua/vim/_defaults.lua b/runtime/lua/vim/_defaults.lua index 99282f6aba..f728bb9949 100644 --- a/runtime/lua/vim/_defaults.lua +++ b/runtime/lua/vim/_defaults.lua @@ -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