Bump ttimeoutlen to 50ms on SSH/TTY

ttimeoutlen=10 fragments multi-byte key codes (F-keys, arrows, Alt-
prefixes) when one-way latency exceeds 10ms, which is normal on SSH.
Vim then sees ESC followed by a literal letter and either returns to
Normal mode mid-insert or treats the trailing byte as a separate
keypress (so <F4> inserts "4").

50ms is the standard "slow link" value: well below perceptible <Esc>
delay locally and big enough for typical residential/long-haul SSH.
g:is_tty already gates several other terminal accommodations; reuse
it here.

Closes #74
This commit is contained in:
m1ngsama 2026-05-17 10:33:57 +08:00
parent 5156543702
commit 8756af3478
3 changed files with 16 additions and 1 deletions

View file

@ -26,6 +26,10 @@
- README badge and `install.sh` recommend Vim 8.1+ instead of 8.0+ —
the runtime conditionally relies on patches `8.1.0360` (diffopt) and
`8.1.1517` (completeopt+=popup), so 8.0 users hit option errors
- `ttimeoutlen` is now 50ms when `g:is_tty` (was 10ms unconditionally);
fixes F-keys, arrow keys, and Alt-prefixes fragmenting on SSH where
one-way latency exceeds 10ms. Local terminals keep the 10ms snappy
default
- `install.sh` no longer silently `PlugClean!`s user-added plugins from
`~/.vim/plugged`; it now lists undeclared plugin directories first and
asks before removing them (`--yes` skips the removal entirely)

View file

@ -42,7 +42,10 @@ set noerrorbells
set novisualbell
set t_vb=
set ttimeout
set ttimeoutlen=10
" Wait long enough on SSH/TTY for multi-byte key codes to arrive intact —
" 10ms fragments F-keys, arrows, and Alt-prefixes when one-way latency > 10ms.
" 50ms is well under perceptible <Esc>→Normal delay locally.
let &ttimeoutlen = g:is_tty ? 50 : 10
if $COLORTERM ==# 'gnome-terminal'
set t_Co=256

View file

@ -257,6 +257,14 @@ check_vim() {
-c 'if maparg(",F", "n") !~# "gg=G" | cquit | endif' \
-c 'qa!' 2>&1
XDG_CONFIG_HOME="$EMPTY_XDG" vim -u .vimrc -i NONE -es -N \
-c 'if &ttimeoutlen != 10 | cquit | endif' \
-c 'qa!' 2>&1
TERM=linux XDG_CONFIG_HOME="$EMPTY_XDG" vim -u .vimrc -i NONE -es -N \
-c 'if !g:is_tty || &ttimeoutlen != 50 | cquit | endif' \
-c 'qa!' 2>&1
XDG_CONFIG_HOME="$EMPTY_XDG" vim -u .vimrc -i NONE -es -N \
-c 'silent! delcommand LspStatus' \
-c 'silent! delcommand LspInstallServer' \