-- Options are automatically loaded before lazy.nvim startup -- Default options that are always set: https://github.com/LazyVim/LazyVim/blob/main/lua/lazyvim/config/options.lua -- Add any additional options here -- Clipboard provider. LazyVim disables `clipboard=unnamedplus` under SSH, so -- select the right provider and explicitly re-enable clipboard-linked yanks: -- * tmux -> tmux's own clipboard buffer (readable) -- * SSH/remote -> OSC 52 copy-only (see note below) -- * local macOS -> native pbcopy/pbpaste. -- Do NOT use OSC 52 locally: yanky's `sync_with_ring` reads the system -- clipboard, and OSC 52 reads depend on the terminal answering a query, which -- Ghostty refuses by default -> OSC 52 error + yanky stack trace. Neovim 0.12 -- also auto-prefers OSC 52 over pbcopy, so the macOS provider must be explicit. if vim.env.TMUX then vim.g.clipboard = "tmux" elseif vim.env.SSH_CONNECTION then -- Remote session (bare SSH, or a multiplexer like herdr that exports no env -- var of its own). Copy via OSC 52 so yanks reach the OUTER terminal's -- clipboard, but NEVER read the clipboard back: OSC 52 reads require the -- terminal to answer a query, which Warp/herdr don't, so a read returns stale -- data (or hangs) and blows up yanky's ring sync. Trade-off: pasting FROM the -- local host INTO nvim over SSH won't work here -- use the terminal's own -- paste in insert mode. -- -- The paste function below must NOT call vim.fn.getreg('"')/'*'/'+' itself: -- Neovim's clipboard provider (autoload/provider/clipboard.vim) guards -- against re-entrant provider calls (`s:here`, see nvim#7184), so a getreg() -- of a clipboard-linked register issued from *inside* a registered paste() -- callback is swallowed and silently returns empty -- not the register's -- real content. Cache what copy() was last given instead, and have paste() -- return that cached value directly. local osc52 = require("vim.ui.clipboard.osc52") local last = { lines = {}, regtype = "" } local function make_copy(reg) local osc52_copy = osc52.copy(reg) return function(lines, regtype) last.lines, last.regtype = lines, regtype osc52_copy(lines, regtype) end end local function paste_from_cache() return { last.lines, last.regtype } end vim.g.clipboard = { name = "osc52-copyonly", copy = { ["+"] = make_copy("+"), ["*"] = make_copy("*") }, paste = { ["+"] = paste_from_cache, ["*"] = paste_from_cache }, cache_enabled = 0, } elseif vim.fn.has("mac") == 1 then vim.g.clipboard = { name = "pbcopy", copy = { ["+"] = "pbcopy", ["*"] = "pbcopy" }, paste = { ["+"] = "pbpaste", ["*"] = "pbpaste" }, cache_enabled = 0, } end -- Make ordinary y/Y use the selected provider. LazyVim applies its SSH default -- after this file is read, so restore the option once startup has settled. The -- schedule keeps this callback after LazyVim's own VeryLazy clipboard callback. vim.api.nvim_create_autocmd("User", { pattern = "VeryLazy", once = true, callback = function() vim.schedule(function() vim.opt.clipboard = "unnamedplus" end) end, }) -- VS Code-like visual improvements vim.opt.cursorline = true -- Highlight current line -- vim.opt.colorcolumn = "80,120" -- Disabled: renders poorly with some themes vim.opt.scrolloff = 8 -- Keep 8 lines visible above/below cursor vim.opt.sidescrolloff = 8 -- Keep 8 columns visible left/right vim.opt.smoothscroll = true -- Smooth scrolling -- Make Shift+movement and mouse selections behave like a conventional editor. -- Keep `cmd` out of selectmode so v/V continue to enter Vim's Visual mode. vim.opt.keymodel = { "startsel", "stopsel" } vim.opt.selectmode = { "key", "mouse" }