From 5098a6987009199d5a5c4bfb8086d0fe4a94e0bb Mon Sep 17 00:00:00 2001 From: narutozxp <41829090+narutozxp@users.noreply.github.com> Date: Thu, 23 Oct 2025 18:04:47 +0800 Subject: [PATCH] fix(clipboard): connecting via vscpde's remote-ssh extension causes severe lag during yank and copy operations. (#6664) ## Description When connecting to a remote server via VSCode's Remote-SSH extension, the `SSH_TTY` environment variable is not set. Consequently, both the `vscode-neovim` extension (when using the remote Neovim instance) and Neovim launched from VSCode's integrated terminal use the system clipboard, resulting in severe lag. Additionally, the `yanky.nvim` plugin synchronizes with the system clipboard by default, regardless of whether the `clipboard` option is set to an empty string (`""`). This causes similar performance issues as described above. Using the `SSH_CONNECTION` environment variable instead of `SSH_TTY` can effectively resolve this issue. ## Checklist - [x] I've read the [CONTRIBUTING](https://github.com/LazyVim/LazyVim/blob/main/CONTRIBUTING.md) guidelines. --- lua/lazyvim/config/options.lua | 2 +- lua/lazyvim/plugins/extras/coding/yanky.lua | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/lua/lazyvim/config/options.lua b/lua/lazyvim/config/options.lua index 2ae1b38d..809f5003 100644 --- a/lua/lazyvim/config/options.lua +++ b/lua/lazyvim/config/options.lua @@ -54,7 +54,7 @@ local opt = vim.opt opt.autowrite = true -- Enable auto write -- only set clipboard if not in ssh, to make sure the OSC 52 -- integration works automatically. -opt.clipboard = vim.env.SSH_TTY and "" or "unnamedplus" -- Sync with system clipboard +opt.clipboard = vim.env.SSH_CONNECTION and "" or "unnamedplus" -- Sync with system clipboard opt.completeopt = "menu,menuone,noselect" opt.conceallevel = 2 -- Hide * markup for bold and italic, but not markers with substitutions opt.confirm = true -- Confirm to save changes before exiting modified buffer diff --git a/lua/lazyvim/plugins/extras/coding/yanky.lua b/lua/lazyvim/plugins/extras/coding/yanky.lua index 6285796d..5b43b7df 100644 --- a/lua/lazyvim/plugins/extras/coding/yanky.lua +++ b/lua/lazyvim/plugins/extras/coding/yanky.lua @@ -5,6 +5,9 @@ return { desc = "Better Yank/Paste", event = "LazyFile", opts = { + system_clipboard = { + sync_with_ring = not vim.env.SSH_CONNECTION, + }, highlight = { timer = 150 }, }, keys = {