Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions nvim/lua/config/options.lua
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,40 @@ opt.timeoutlen = 400
opt.updatetime = 250
opt.completeopt = { "menu", "menuone", "noselect" }
opt.clipboard = "unnamedplus"

do
local function in_tmux()
local tmux_env = vim.env.TMUX
return type(tmux_env) == "string" and tmux_env ~= ""
end

local function tmux_binary_available()
return vim.fn.executable("tmux") == 1
end

-- Older tmux releases (for example the version bundled with CentOS 7) do not
-- passthrough OSC 52 sequences. When Neovim detects an unavailable clipboard
-- provider it falls back to OSC 52, which results in the escape sequence
-- becoming visible in the editor instead of copying the text. Detect this
-- scenario and prefer the tmux load-buffer / save-buffer workflow instead of
-- relying on OSC 52.
if vim.g.clipboard == nil and in_tmux() and tmux_binary_available() then
local copy = "tmux load-buffer -w -"
local paste = "tmux save-buffer -"

vim.g.clipboard = {
name = "tmux",
copy = {
["+"] = copy,
["*"] = copy,
},
paste = {
["+"] = paste,
["*"] = paste,
},
cache_enabled = false,
}
end
end
opt.wrap = false
opt.mouse = "a"