From 0d3260dab1ba308a032713812628cde6b92a7fae Mon Sep 17 00:00:00 2001 From: Brad Anderson Date: Fri, 10 Jul 2026 15:38:33 -0700 Subject: [PATCH] Fix issues when nvim plugin deps aren't available and make system clipboard more consistent --- config/nvim/lua/config/options.lua | 19 +++++++++++++++++++ config/nvim/lua/plugins/lsp.lua | 12 +++++++++++- config/nvim/lua/plugins/treesitter.lua | 19 +++++++++++++++---- config/tmux.conf | 6 ++++++ packages/apt.global | 2 ++ 5 files changed, 53 insertions(+), 5 deletions(-) diff --git a/config/nvim/lua/config/options.lua b/config/nvim/lua/config/options.lua index 82a1fe1..b2f476e 100644 --- a/config/nvim/lua/config/options.lua +++ b/config/nvim/lua/config/options.lua @@ -59,3 +59,22 @@ opt.splitright = true opt.updatetime = 300 opt.shortmess:append("c") + +-- Clipboard: OSC 52 copy-only. This sends the "+ / "* register content to +-- the real terminal via escape sequence, so y works whether nvim is +-- local or several ssh/tmux hops deep -- no xclip/wl-copy/pbcopy needed on +-- the remote host. Paste is intentionally left as a no-op: OSC 52 read +-- support is inconsistent across terminals and can hang waiting for a +-- reply, so use the terminal's own native paste (e.g. Ctrl-Shift-V) instead. +local osc52 = require("vim.ui.clipboard.osc52") +vim.g.clipboard = { + name = "OSC 52 (copy-only)", + copy = { + ["+"] = osc52.copy("+"), + ["*"] = osc52.copy("*"), + }, + paste = { + ["+"] = function() return {} end, + ["*"] = function() return {} end, + }, +} diff --git a/config/nvim/lua/plugins/lsp.lua b/config/nvim/lua/plugins/lsp.lua index 4d08f1b..f0df15c 100644 --- a/config/nvim/lua/plugins/lsp.lua +++ b/config/nvim/lua/plugins/lsp.lua @@ -1,4 +1,14 @@ -local servers = { "ts_ls", "svelte", "html", "cssls", "basedpyright", "ruff", "bashls" } +local servers = { "basedpyright", "ruff" } + +local npm_servers = { "ts_ls", "svelte", "html", "cssls", "bashls" } +if vim.fn.executable("npm") == 1 then + vim.list_extend(servers, npm_servers) +else + vim.notify( + "npm not found: skipping LSP servers " .. table.concat(npm_servers, ", "), + vim.log.levels.WARN + ) +end return { { diff --git a/config/nvim/lua/plugins/treesitter.lua b/config/nvim/lua/plugins/treesitter.lua index a330ce6..9827ffb 100644 --- a/config/nvim/lua/plugins/treesitter.lua +++ b/config/nvim/lua/plugins/treesitter.lua @@ -25,8 +25,16 @@ return { "regex", } - -- Install parsers - require("nvim-treesitter").install(parsers) + -- Install parsers (skip if the tree-sitter CLI isn't available; parsers + -- already cached from a previous run on this machine still work fine) + if vim.fn.executable("tree-sitter") == 1 then + require("nvim-treesitter").install(parsers) + else + vim.notify( + "tree-sitter CLI not found: skipping install of missing parsers", + vim.log.levels.WARN + ) + end -- Enable treesitter highlighting, folding, and indentation for -- filetypes with an installed parser. Note some filetype names differ @@ -53,8 +61,11 @@ return { "markdown", }, callback = function() - -- Highlighting, provided by Neovim - vim.treesitter.start() + -- Highlighting, provided by Neovim. Falls back to Vim's legacy + -- syntax/indent if no parser is installed for this filetype. + if not pcall(vim.treesitter.start) then + return + end -- Folding, provided by Neovim vim.wo.foldexpr = "v:lua.vim.treesitter.foldexpr()" vim.wo.foldmethod = "expr" diff --git a/config/tmux.conf b/config/tmux.conf index bfa6914..d361900 100644 --- a/config/tmux.conf +++ b/config/tmux.conf @@ -52,6 +52,12 @@ set-option -g -q mouse on bind y run 'tmux save-buffer - | reattach-to-user-namespace pbcopy' bind C-y run 'tmux save-buffer - | reattach-to-user-namespace pbcopy' +# Let OSC 52 escape sequences (e.g. nvim's clipboard writes) pass through +# this tmux to the real terminal, even when nested behind ssh/tmux layers. +# allow-passthrough was added in tmux 3.3; older tmux doesn't understand the +# option, so only set it when the running tmux is new enough. +if-shell "tmux -V | awk '{print $2}' | awk -F. '{if ($1*1000+$2 >= 3003) exit 0; else exit 1}'" 'set -g allow-passthrough on' + # tmux renamed the copy-mode key table (vi-copy -> copy-mode-vi) and changed # bind-key's table flag (-t -> -T) in 2.4. Source the file matching the # running tmux so old tmux never parses syntax it doesn't understand. diff --git a/packages/apt.global b/packages/apt.global index 2c5741f..c9633ef 100644 --- a/packages/apt.global +++ b/packages/apt.global @@ -7,6 +7,8 @@ thefuck tree nodejs zsh +npm +tree-sitter-cli # Useless stuff fortune-mod