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>

View File

@@ -7555,6 +7555,19 @@ vim.o.ttm = vim.o.ttimeoutlen
vim.go.ttimeoutlen = vim.o.ttimeoutlen
vim.go.ttm = vim.go.ttimeoutlen
--- Assume that the underlying terminal can respond quickly to queries
--- required by features such as 'background' detection.
---
--- Nvim issues terminal queries before reading the user's `config` file,
--- so disabling this option there will not work. Set $NVIM_NOTTYFAST
--- before starting Nvim to disable terminal queries.
---
--- @type boolean
vim.o.ttyfast = true
vim.o.tf = vim.o.ttyfast
vim.go.ttyfast = vim.o.ttyfast
vim.go.tf = vim.go.ttyfast
--- List of directory names for undo files, separated with commas.
--- See 'backupdir' for details of the format.
--- "." means using the directory of the file. The undo file name for