feat: nvim config tracks the live tree
Port the live ~/.config/nvim working tree (bcherb2/nvim master plus its uncommitted git.lua and minimap.lua edits): adds claudecode, eslint, lsp, typescript, meow-yarn and refactoring-fix specs, drops the files the live repo deleted, and takes live for everything else. Kept from public: lazy.lua with luarocks disabled, the ai_assist cond guard (nvim-ai-assist is not anonymously clonable, so a fresh box only gets it from the private clone list), and the scrubbed endpoint comment in place of live's LAN address.
This commit is contained in:
1 parent
9baaf78522
commit
0aaaf51421
28 files changed
+1001
-611
No files matched your search
@@ -13,3 +13,27 @@ vim.keymap.set("n", "<leader>cY", function()
|
||||
vim.fn.setreg("+", vim.fn.expand("%:p"))
|
||||
print("Copied absolute path: " .. vim.fn.expand("%:p"))
|
||||
end, { desc = "Copy absolute path" })
|
||||
|
||||
-- Select mode (Shift+arrows) replaces the selection with what you type, so `y`
|
||||
-- types a "y". Conventional copy/cut instead (<C-g> switches to Visual first).
|
||||
-- The `y`/`d` is fed remappable so buffer maps still apply (md-render's render
|
||||
-- view copies markdown source); `"+` is fed noremap so which-key's `"` trigger
|
||||
-- stays out. Both go to the front of typeahead, in this order.
|
||||
local function clipboard_op(prefix, op)
|
||||
return function()
|
||||
vim.api.nvim_feedkeys(op, "mi", false)
|
||||
vim.api.nvim_feedkeys(vim.keycode(prefix) .. '"+', "ni", false)
|
||||
end
|
||||
end
|
||||
vim.keymap.set("s", "<C-c>", clipboard_op("<C-g>", "y"), { desc = "Copy selection to clipboard" })
|
||||
vim.keymap.set("s", "<C-x>", clipboard_op("<C-g>", "d"), { desc = "Cut selection to clipboard" })
|
||||
vim.keymap.set("x", "<C-c>", clipboard_op("", "y"), { desc = "Copy selection to clipboard" })
|
||||
|
||||
-- VS Code's terminal toggle (Ctrl+`, the ~ key), mirroring LazyVim's <C-/>.
|
||||
-- Only reaches nvim when the terminal sends CSI u / kitty keys; the legacy
|
||||
-- encoding of Ctrl+` is NUL, which is <C-Space> (flash) and is left alone.
|
||||
local function toggle_terminal()
|
||||
Snacks.terminal.focus(nil, { cwd = LazyVim.root() })
|
||||
end
|
||||
vim.keymap.set({ "n", "t" }, "<C-`>", toggle_terminal, { desc = "Terminal (Root Dir)" })
|
||||
vim.keymap.set({ "n", "t" }, "<C-~>", toggle_terminal, { desc = "which_key_ignore" })
|
||||
@@ -2,10 +2,16 @@
|
||||
-- Default options that are always set: https://github.com/LazyVim/LazyVim/blob/main/lua/lazyvim/config/options.lua
|
||||
-- Add any additional options here
|
||||
|
||||
-- No AI/inline completion: LazyVim's blink extra sets
|
||||
-- completion.ghost_text.enabled = vim.g.ai_cmp (grey inline preview of the top
|
||||
-- item). Must be set here, before LazyVim imports its extras.
|
||||
vim.g.ai_cmp = false
|
||||
|
||||
-- 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)
|
||||
-- * tmux -> tmux buffer (p first asks the outer terminal via
|
||||
-- `refresh-client -l`; only works if it allows OSC 52 reads)
|
||||
-- * SSH/remote -> OSC 52 copy + host-local paste cache (see 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
|
||||
@@ -17,34 +23,97 @@ 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.
|
||||
-- terminal to answer a query, which Warp/herdr/Ghostty don't, and the runtime
|
||||
-- reader then blocks for up to 10 s. Pasting FROM the Mac INTO nvim is the
|
||||
-- terminal's own paste (Cmd-V, bracketed paste; works in every mode).
|
||||
--
|
||||
-- `p` returns the last copy made by ANY nvim on this host: copy() also writes
|
||||
-- {regtype, lines...} to stdpath("state")/clipboard/last (dir 0700, file 0600,
|
||||
-- atomic rename; writefile/readfile "b" keep NUL bytes and trailing empty
|
||||
-- lines), so a yank in one herdr pane pastes in another. Falls back to this
|
||||
-- instance's last copy. Over 8 MiB the shared file is removed, not left stale.
|
||||
-- No "nothing to paste" hint: yanky reads "+ when it loads, so paste() can't
|
||||
-- tell a user's `p` from a plugin's read.
|
||||
--
|
||||
-- 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)
|
||||
-- real content. It reads the shared file or what copy() was last given.
|
||||
-- Neither function may throw: an error would land in the middle of a yank.
|
||||
local osc52_send = require("vim.ui.clipboard.osc52").copy("+")
|
||||
local share_dir = vim.fn.stdpath("state") .. "/clipboard"
|
||||
local share_file = share_dir .. "/last"
|
||||
local SHARE_MAX, OSC52_WARN = 8 * 1024 * 1024, 512 * 1024
|
||||
local last, dir_mode_set = { lines = {}, regtype = "v" }, false
|
||||
local stale -- identity of a shared file we failed to replace or remove
|
||||
local function file_id()
|
||||
local st = vim.uv.fs_stat(share_file)
|
||||
return st and ("%d:%d.%d:%d"):format(st.ino, st.mtime.sec, st.mtime.nsec, st.size)
|
||||
end
|
||||
local function share(lines, regtype, size)
|
||||
local tmp = ("%s.%d.tmp"):format(share_file, vim.uv.os_getpid())
|
||||
local ok = pcall(function()
|
||||
if size > SHARE_MAX then error("too large to share") end
|
||||
if vim.fn.isdirectory(share_dir) == 0 then
|
||||
vim.fn.mkdir(share_dir, "p", tonumber("700", 8))
|
||||
dir_mode_set = false
|
||||
end
|
||||
if not dir_mode_set then -- once per process, also for a pre-existing dir
|
||||
dir_mode_set = true
|
||||
vim.uv.fs_chmod(share_dir, tonumber("700", 8))
|
||||
end
|
||||
local data = { regtype }
|
||||
vim.list_extend(data, lines)
|
||||
if vim.fn.writefile(data, tmp, "bS") ~= 0 then error("write failed") end
|
||||
assert(vim.uv.fs_chmod(tmp, tonumber("600", 8)))
|
||||
assert(vim.uv.fs_rename(tmp, share_file))
|
||||
end)
|
||||
stale = nil
|
||||
if not ok then -- never serve a stale shared copy
|
||||
pcall(os.remove, tmp)
|
||||
pcall(os.remove, share_file)
|
||||
stale = file_id() -- still there (read-only dir): ignore it until replaced
|
||||
end
|
||||
end
|
||||
local function paste_from_cache()
|
||||
local function remember(lines, regtype)
|
||||
last.lines, last.regtype = lines, regtype
|
||||
local size = 0
|
||||
for _, l in ipairs(lines) do size = size + #l + 1 end
|
||||
share(lines, regtype, size)
|
||||
return size
|
||||
end
|
||||
local function copy_plus(lines, regtype)
|
||||
local size = remember(lines, regtype)
|
||||
pcall(osc52_send, lines, regtype)
|
||||
if size > OSC52_WARN then
|
||||
vim.schedule(function()
|
||||
vim.notify(("Copied %d KiB via OSC 52; the terminal may drop payloads this large (nvim `p` on this host still has it)."):format(math.floor(size / 1024)), vim.log.levels.WARN)
|
||||
end)
|
||||
end
|
||||
end
|
||||
-- OSC 52 'p' (primary selection) means nothing on the Mac, so "* only updates
|
||||
-- the paste cache. A yank that fans out to "+ AND "* (provider:
|
||||
-- s:copy['*'] != s:copy['+'], i.e. 'clipboard' has unnamed) still sends
|
||||
-- exactly one OSC 52 sequence.
|
||||
local function copy_star(lines, regtype)
|
||||
remember(lines, regtype)
|
||||
end
|
||||
local function paste()
|
||||
if vim.fn.filereadable(share_file) == 1 and (not stale or file_id() ~= stale) then
|
||||
local ok, data = pcall(vim.fn.readfile, share_file, "b")
|
||||
if ok and type(data) == "table" and #data > 0 and data[1]:match("^[vVb]$") then
|
||||
local regtype = table.remove(data, 1)
|
||||
return { data, regtype }
|
||||
end
|
||||
end
|
||||
return { last.lines, last.regtype }
|
||||
end
|
||||
vim.g.clipboard = {
|
||||
name = "osc52-copyonly",
|
||||
copy = { ["+"] = make_copy("+"), ["*"] = make_copy("*") },
|
||||
paste = { ["+"] = paste_from_cache, ["*"] = paste_from_cache },
|
||||
copy = { ["+"] = copy_plus, ["*"] = copy_star },
|
||||
paste = { ["+"] = paste, ["*"] = paste },
|
||||
cache_enabled = 0,
|
||||
}
|
||||
elseif vim.fn.has("mac") == 1 then
|
||||
@@ -76,7 +145,10 @@ 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.
|
||||
-- Shift+arrows start Select mode like a conventional editor: typing replaces
|
||||
-- the selection; <C-c>/<C-x> copy/cut it to the clipboard (keymaps.lua).
|
||||
-- Mouse drags start Visual mode so y/d/p work as usual (over SSH with
|
||||
-- mouse=a the terminal can't copy a drag itself). 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" }
|
||||
vim.opt.selectmode = { "key" }
|
||||
Reference in new issue
Block a user