feat(tui): restore 'ttyfast' to control tty requests #38699

Problem:
When running nvim on a remote machine over SSH, if there is high ping,
then bg detection may not complete in time. This results in a warning
every time nvim is started. #38648

Solution:
Restore 'ttyfast' option and allow it to control whether or not bg
detection is performed. Because this is during startup and before any
user config or commands, we use the environment variable
`NVIM_NOTTYFAST` to allow disabling `ttyfast` during initialization.
This commit is contained in:
Kyle
2026-04-24 13:45:20 -05:00
committed by GitHub
parent 393f687503
commit 66149ca668
11 changed files with 53 additions and 9 deletions

View File

@@ -847,7 +847,10 @@ do
--- ignored in the calculations.
---
--- [1] https://en.wikipedia.org/wiki/Luma_%28video%29
do
---
--- In slow environments (e.g. SSH with high latency), this will increase
--- startup time and produce a warning, so users may want to disable it.
if vim.o.ttyfast then
--- Parse a string of hex characters as a color.
---
--- The string can contain 1 to 4 hex characters. The returned value is
@@ -999,7 +1002,7 @@ do
and os.getenv('NVIM_TEST') == nil
then
vim.notify(
'defaults.lua: Did not detect DSR response from terminal. This results in a slower startup time.',
"defaults.lua: Did not detect DSR response from terminal for 'background' detection. This results in a slower startup time. To disable this and other 'ttyfast' features during startup, set the environment variable NVIM_NOTTYFAST",
vim.log.levels.WARN,
{ _truncate = true }
)
@@ -1017,7 +1020,7 @@ do
-- The TUI was able to determine truecolor support or $COLORTERM explicitly indicates
-- truecolor support
setoption('termguicolors', true)
elseif colorterm == nil or colorterm == '' then
elseif (colorterm == nil or colorterm == '') and vim.o.ttyfast then
-- Neither the TUI nor $COLORTERM indicate that truecolor is supported, so query the
-- terminal
local caps = {} ---@type table<string, boolean>