ojroques / nvim-osc52 Goto Github PK
View Code? Open in Web Editor NEWA Neovim plugin to copy text through SSH with OSC52
License: BSD 2-Clause "Simplified" License
A Neovim plugin to copy text through SSH with OSC52
License: BSD 2-Clause "Simplified" License
Reproduction steps:
ctrl-shift-v
, which output text A as expectyy
ctrl-shift-v
, which output text BMinimal Configuration:
tmux
set -ga terminal-overrides ",xterm*:Tc"
set-option -g status-interval 5
set-option -g automatic-rename on
set-option -g automatic-rename-format '#{b:pane_current_path}'
set-environment -g COLORTERM "truecolor"
set -s set-clipboard on
set -g mouse on
kitty: default configuration
nvim-osc52 configuration:
require('osc52').setup {
max_length = 0, -- Maximum length of selection (0 for no limit)
silent = true, -- Disable message on successful copy
trim = true, -- Trim surrounding whitespaces before copy
tmux_passthrough = true, -- Copy from tmux into vim
}
I'm very confused about this issue, since if I running the following osc52 command in tmux and kitty, the problem won't happened:
esc="\033]52;c;$(base64 <<< 'hello world')\a"
esc="\033Ptmux;\033$esc\033\\" # tmux needs sequence escapement
printf "$esc"
Finally, thanks for your plugin which improves my remote development experience.
I just tried nvim + osc52 plugin in patched konsole with OSC52 support (Linux, KDE Plasma) and there a problem with visual selection function.
Basically, when selecting some piece of text, the plugin copies that plus an additional character after that. And if that selection runs intil the end of the line for example, that will include \n
.
It even reports N+1 characters copied when I selected only N (just checked).
Here is my configuration for it:
" OSC-52 clipboard handling
lua <<EOF
osc52 = require('osc52')
osc52 .setup {
silent = false
}
vim.keymap.set('x', '<C-c>', osc52.copy_visual)
EOF
The way I'm using it - in visual mode select something, then press Ctrl+C. It copes things, but as above, there is that length problem.
When first launching neovim, the first use of the y
operator doesn't copy. I get the message that 'osc52' copied x characters but when trying to put that test using p
I get: E353: Nothing in register "
. Subsequent uses work as expected.
This is consistent in multiple setups I use.
In vim we can go:
:call setreg("+", @+, "b")
how can i do thaton osc52?
The vim-highlightedyank plugin or neovim's on-yank-highlight feature (https://neovim.io/doc/user/lua.html#lua-highlight) can display which regions are yanked via TextYankPost event, but the regions copied by nvim-osc52's copy operator do not seem to update the highlight region correctly; so the plugin does not display the yanked region correctly.
Hi @ojroques,
Thanks for making this and the upstream vim-oscyank. Not able to find the right solution to override the which-key config based on the upstream Lunar Vim docs and source code.
When hitting <Space>c
in normal mode, it complains about E16: Invalid range
. Switching to visual mode, it copies to the system clipboard, but then cuts the text from the open buffer.
Any idea why it's behaving like this?
Thanks in advance! ๐
OS: macOS 12.6.1 (21G217)
iTerm: 3.4.16
neovim: v0.8.1
lvim: 1.2.0 (4d03f65)
config.lua
--[[
lvim is the global options object
Linters should be
filled in as strings with either
a global executable or a path to
an executable
]]
-- general
lvim.log.level = "warn"
lvim.format_on_save = true
-- lvim.colorscheme = "onedarker"
lvim.colorscheme = "onenord"
-- to disable icons and use a minimalist setup, uncomment the following
lvim.use_icons = true
-- keymappings [view all the defaults by pressing <leader>Lk]
lvim.leader = "space"
-- add your own keymapping
lvim.keys.normal_mode["<C-s>"] = ":w<cr>"
-- unmap a default keymapping
-- vim.keymap.del("n", "<C-Up>")
-- override a default keymapping
-- lvim.keys.normal_mode["<C-q>"] = ":q<cr>" -- or vim.keymap.set("n", "<C-q>", ":q<cr>" )
-- TODO: fix osc52 "<leader>c/cc" cutting lines
-- disable close buffer default keybinding
lvim.keys.normal_mode["<leader>c"] = false
lvim.keys.visual_mode["<leader>c"] = false
-- osc52 copy function
function copy()
if vim.v.event.operator == 'y' and vim.v.event.regname == 'c' then
require('osc52').copy_register('c')
end
end
vim.api.nvim_create_autocmd('TextYankPost', {callback = copy})
-- nvim-osc52 clipboard provider
local function copy(lines, _)
require('osc52').copy(table.concat(lines, '\n'))
end
local function paste()
return {vim.fn.split(vim.fn.getreg(''), '\n'), vim.fn.getregtype('')}
end
vim.g.clipboard = {
name = 'osc52',
copy = {['+'] = copy, ['*'] = copy},
paste = {['+'] = paste, ['*'] = paste},
}
-- Now the '+' register will copy to system clipboard using OSC52
vim.keymap.set('n', '<leader>c', '"+y')
vim.keymap.set('n', '<leader>cc', '"+yy')
-- osc52 keymap
vim.keymap.set("n", "<leader>c", require("osc52").copy_operator, {expr = true})
vim.keymap.set("n", "<leader>cc", "<leader>c_", {remap = true})
vim.keymap.set("x", "<leader>c", require("osc52").copy_visual)
-- custom whichkey mapping
lvim.builtin.which_key.mappings = {
-- ["c"] = { "<cmd>BufferKill<CR>", "Close Buffer" }, -- default
["c"] = { "<cmd>copy<CR>", "Copy Selection" }, -- osc52
[";"] = { "<cmd>Alpha<CR>", "Dashboard" },
["w"] = { "<cmd>w!<CR>", "Save" },
["q"] = { "<cmd>lua require('lvim.utils.functions').smart_quit()<CR>", "Quit" },
["/"] = { "<Plug>(comment_toggle_linewise_current)", "Comment toggle current line" },
["f"] = { require("lvim.core.telescope.custom-finders").find_project_files, "Find File" },
["h"] = { "<cmd>nohlsearch<CR>", "No Highlight" },
["e"] = { "<cmd>NvimTreeToggle<CR>", "Explorer" },
b = {
name = "Buffers",
j = { "<cmd>BufferLinePick<cr>", "Jump" },
f = { "<cmd>Telescope buffers<cr>", "Find" },
b = { "<cmd>BufferLineCyclePrev<cr>", "Previous" },
n = { "<cmd>BufferLineCycleNext<cr>", "Next" },
e = {
"<cmd>BufferLinePickClose<cr>",
"Pick which buffer to close",
},
h = { "<cmd>BufferLineCloseLeft<cr>", "Close all to the left" },
l = {
"<cmd>BufferLineCloseRight<cr>",
"Close all to the right",
},
D = {
"<cmd>BufferLineSortByDirectory<cr>",
"Sort by directory",
},
L = {
"<cmd>BufferLineSortByExtension<cr>",
"Sort by language",
},
},
d = {
name = "Debug",
t = { "<cmd>lua require'dap'.toggle_breakpoint()<cr>", "Toggle Breakpoint" },
b = { "<cmd>lua require'dap'.step_back()<cr>", "Step Back" },
c = { "<cmd>lua require'dap'.continue()<cr>", "Continue" },
C = { "<cmd>lua require'dap'.run_to_cursor()<cr>", "Run To Cursor" },
d = { "<cmd>lua require'dap'.disconnect()<cr>", "Disconnect" },
g = { "<cmd>lua require'dap'.session()<cr>", "Get Session" },
i = { "<cmd>lua require'dap'.step_into()<cr>", "Step Into" },
o = { "<cmd>lua require'dap'.step_over()<cr>", "Step Over" },
u = { "<cmd>lua require'dap'.step_out()<cr>", "Step Out" },
p = { "<cmd>lua require'dap'.pause()<cr>", "Pause" },
r = { "<cmd>lua require'dap'.repl.toggle()<cr>", "Toggle Repl" },
s = { "<cmd>lua require'dap'.continue()<cr>", "Start" },
q = { "<cmd>lua require'dap'.close()<cr>", "Quit" },
U = { "<cmd>lua require'dapui'.toggle()<cr>", "Toggle UI" },
},
}
-- After changing plugin config exit and reopen LunarVim, Run :PackerInstall :PackerCompile
lvim.builtin.alpha.active = true
lvim.builtin.alpha.mode = "dashboard"
lvim.builtin.terminal.active = true
lvim.builtin.nvimtree.setup.view.side = "left"
lvim.builtin.nvimtree.setup.renderer.icons.show.git = false
-- if you don't want all the parsers change this to a table of the ones you want
lvim.builtin.treesitter.ensure_installed = {
"bash",
"c",
"javascript",
"json",
"lua",
"python",
"typescript",
"tsx",
"css",
"rust",
"java",
"yaml",
}
lvim.builtin.treesitter.ignore_install = { "haskell" }
lvim.builtin.treesitter.highlight.enabled = true
-- -- set additional linters
-- local linters = require "lvim.lsp.null-ls.linters"
-- linters.setup {
-- { command = "flake8", filetypes = { "python" } },
-- {
-- -- each linter accepts a list of options identical to https://github.com/jose-elias-alvarez/null-ls.nvim/blob/main/doc/BUILTINS.md#Configuration
-- command = "shellcheck",
-- ---@usage arguments to pass to the formatter
-- -- these cannot contain whitespaces, options such as `--line-width 80` become either `{'--line-width', '80'}` or `{'--line-width=80'}`
-- extra_args = { "--severity", "warning" },
-- },
-- {
-- command = "codespell",
-- ---@usage specify which filetypes to enable. By default a providers will attach to all the filetypes it supports.
-- filetypes = { "javascript", "python" },
-- },
-- }
-- Additional Plugins
lvim.plugins = {
-- {"folke/tokyonight.nvim"},
{ "arcticicestudio/nord-vim" },
{
"folke/todo-comments.nvim",
event = "BufRead",
config = function()
require("todo-comments").setup()
end,
},
{ "kassio/neoterm" },
{ "ojroques/nvim-osc52" },
{ "rmehri01/onenord.nvim" },
{ "wfxr/minimap.vim" }
}
-- Autocommands (https://neovim.io/doc/user/autocmd.html)
-- vim.api.nvim_create_autocmd("BufEnter", {
-- pattern = { "*.json", "*.jsonc" },
-- -- enable wrap mode for json files only
-- command = "setlocal wrap",
-- })
-- vim.api.nvim_create_autocmd("FileType", {
-- pattern = "zsh",
-- callback = function()
-- -- let treesitter use bash highlight for zsh files as well
-- require("nvim-treesitter.highlight").attach(0, "bash")
-- end,
-- })
When copying multiple lines with the trim option enabled, only the first whitespace is trimmed.
E.g. when copying:
# some class code here
def foo(self, bar):
return bar * 2
You will get:
def foo(self, bar):
return bar * 2
This is of course because the copy function takes the full string, so it cannot know the lines (except if it would split them again, which will end up in concatting, splitting and concatting again in many cases).
I've created a small function that strips the common indent of the copied lines:
local copy = function(lines, _)
-- Trim indent before copying
local indent, _ = lines[1]:find '[^ ]'
for key, line in ipairs(lines) do
lines[key] = line:sub(indent)
end
require('osc52').copy(table.concat(lines, '\n'))
end
I wonder if this would be something worth integrating? Or mentioning in the README?
I still need to handle cases where the first line(s) are empty, probably could be done in a better way.
When nvim-osc52 has not been previously invoked since Neovim was launched, an attempt to invoke it via copy_visual (per the recommended keybindings, <leader>c
) does not properly copy the visual selection. Instead, the plugin appears to target results for the most recently used search pattern.
Expected behavior:
The visually selected text should be copied to the system clipboard.
Actual behavior (two variants):
E5108: Error executing lua: ...are/nvim/site/pack/packer/start/nvim-osc52/lua/osc52.lua:31: Vim(normal):E486: Pattern not found: hello
stack traceback:
[C]: in function 'cmd'
...are/nvim/site/pack/packer/start/nvim-osc52/lua/osc52.lua:31: in function 'get_text'
...are/nvim/site/pack/packer/start/nvim-osc52/lua/osc52.lua:93: in function <...are/nvim/site/pack/packer/start/nvim-osc52/lua/osc52.lua:92>
Any subsequent invocations of nvim-osc52 within the same session appear to be handled properly.
Why is the first yank after opening NVIM 0 bytes?
The video demonstrated that the first copy had 0 characters, while the second copy had 175 characters.
thank you, I love this plugin.
I got a weird issue.
When using plugin on macos everything works fine, copying overwrites old copy.
But with the same terminal(kitty) with the same nvim config but on linux, copying does not overwrite itself. New lines are added to last copy and so on.
Any ideas how to fix this?
Using LazyVim via this configuration:
return {
"ojroques/nvim-osc52",
keys = {
{
"<leader>y",
function() require("osc52").copy_operator() end,
expr = true,
desc = "copy selection to system clipboard (normal mode)"
},
{
"<leader>Y",
"<leader>c_",
remap = true,
desc = "copy current line into system clipboard (normal mode)"
},
{
mode = "v",
"<leader>y",
function() require("osc52").copy_visual() end,
desc = "copy selection to system clipboard (visual mode)"
}
}
}
<leader>y
in normal mode appears to do nothing. โ<leader>Y
deletes the current line, and puts me into insert mode. โ<leader>y
in visual mode works as expected, text is yanked to my system clipboard via osc52
and a message is printed confirming that. โ
Maybe I don't understand the purpose of <leader>y
โ require("osc52").copy_operator()
mapping in normal mode, but as mentioned I see no effect. <leader>Y
โ <leader>c_
in normal mode is most definitely not copying the currently highlighted line; as I assume that mapping would, given the example configuration's descriptions:
vim.keymap.set('n', '<leader>c', require('osc52').copy_operator, {expr = true})
vim.keymap.set('n', '<leader>cc', '<leader>c_', {remap = true})
vim.keymap.set('v', '<leader>c', require('osc52').copy_visual)
In normal mode, c is an operator that will copy the given text to the clipboard.
In normal mode, cc will copy the current line.
In visual mode, c will copy the current selection.
The second map (normal mode <leader>y
) is doing something, just the wrong thing. Changing the second value, or what the map is being remapped to changes the behavior. I say this because that means that my syntax / configuration is correct in the sense that something is happening, just not the right something. And as previously mentioned, the visual mode mapping works as expected. Using native remapping has an identical effect to the LazyVim syntax remapping.
vim.keymap.set("n", "<leader>Y", "<leader>c_", { remap = true, desc = "copy current line to system clipboard (normal mode)" })
I'm skeptical of replacing my clipboard provider entirely with osc52
as I run the potential risk of using a terminal that doesn't provide osc52
support, and losing access to basic clipboard functionality. So, I'd love to get this working without resorting to that.
When I select around 800 characters, it just hang, clipboard is emptied and no-response window. I have to move a to different windows and back to get the window to be responsive again.
use {'ojroques/nvim-osc52',
config = function ()
local function copy(lines, _)
require('osc52').copy(table.concat(lines, '\n'))
end
local function paste()
return {vim.fn.split(vim.fn.getreg(''), '\n'), vim.fn.getregtype('')}
end
vim.g.clipboard = {
name = 'osc52',
copy = {['+'] = copy, ['*'] = copy},
paste = {['+'] = paste, ['*'] = paste},
}
-- Now the '+' register will copy to system clipboard using OSC52
end
}
No problem whatsoever with the old vimscript plugin though.
use {"ojroques/vim-oscyank",
config = function()
vim.cmd [[ autocmd TextYankPost * if v:event.operator is 'y' && v:event.regname is '+' | execute 'OSCYankReg +' | endif ]]
end }
Thank you for making a great plugin! It's so great to be able to copy text even over an ssh session!
However, after setting up the plugin, I have noticed that my usual workflow of copying and pasting lines (yy
and p
) no longer works. I get the error:
E353: Nothing in register "
I have set the following in my config:
vim.opt.clipboard = "unnamedplus"
local status_ok, osc52 = pcall(require, "osc52")
if not status_ok then
return
end
osc52.setup({
max_length = 0, -- Maximum length of selection (0 for no limit)
silent = false, -- Disable message on successful copy
trim = false, -- Trim text before copy
})
-- set this plugin as the clipboard provider
local function copy(lines, _)
require('osc52').copy(table.concat(lines, '\n'))
end
local function paste()
return {vim.fn.split(vim.fn.getreg(''), '\n'), vim.fn.getregtype('')}
end
vim.g.clipboard = {
name = 'osc52',
copy = {['+'] = copy, ['*'] = copy },
paste = {['+'] = paste, ['*'] = paste },
}
Is there anything I can do to re-enable my copy-line-and-paste workflow? I am new to Neovim so apologies if I am missing something obvious.
Hello,
the configuration examples given all fails to be applied in init.vim as their syntax looks like they are lua pieces of codes and not vimscript syntax.
Is there any instructions that are missing from the readme to actually make this config work ?
Unfortunately the official neovim docs suggest to use win32yank, but for me at least this does not work https://github.com/neovim/neovim/wiki/FAQ#how-to-use-the-windows-clipboard-from-wsl and win32yank looks super buggy.
What setup can you recommend instead? Using powershell + Get-Clipboard
/Set-Clipboard
?
Hello!
Thanks for writing this plugin! Unfortunately, I am connecting to a Windows machine via SSH and the osc52.copy
function will fail every time because vim.fn.filewritable
does not return a boolean but instead returns 0
. In lua, only nil
and false
are actually false
That said, I can say the else
block does work correctly if a small patch is applied:
if vim.fn.filewritable('/dev/fd/2') ~= 0 then
I've applied this and some more experimental stuff (like using the builtin function vim.notify
for errors/status messages) so I couldn't just open a PR directly to fix this, as I've hacked this plugin up quiet a bit on my end ๐
I used the config provided in the readme
function copy()
if vim.v.event.operator == 'y' and vim.v.event.regname == '+' then
require('osc52').copy_register('+')
end
end
vim.api.nvim_create_autocmd('TextYankPost', {callback = copy})
In this case, if I use "+yy
to yank, the contents will be yanked to the system clipboard and I can paste it anywhere, but if I directly use yy
to yank, nothing will be copied to the system clipboard, I used the :reg
to checked the register, the contents is in the +
register, why it is not copied to system clipboard?
hi! relatively new to neovim here and trying to understand the difference between the two usages described in the readme
I see one usage looks like this:
vim.keymap.set('n', '<leader>c', require('osc52').copy_operator, {expr = true})
vim.keymap.set('n', '<leader>cc', '<leader>c_', {remap = true})
and the other looks via "clipboard provider" looks like:
local function copy(lines, _)
require('osc52').copy(table.concat(lines, '\n'))
end
local function paste()
return {vim.fn.split(vim.fn.getreg(''), '\n'), vim.fn.getregtype('')}
end
vim.g.clipboard = {
name = 'osc52',
copy = {['+'] = copy, ['*'] = copy},
paste = {['+'] = paste, ['*'] = paste},
}
-- Now the '+' register will copy to system clipboard using OSC52
vim.keymap.set('n', '<leader>c', '"+y')
vim.keymap.set('n', '<leader>cc', '"+yy')
Questions:
copy
and paste
functions within the library itself so users don't need to specify them when using clipboard provider approach? sort of like what will come in neovim 0.10 require('vim.clipboard.osc52').copy
?Hi,
Thank you for the plugin! It sounds exactly what I was looking for ๐ฅ
My local OS is MacOS 14. I'm using iTerm2 to connect to a remote server with mosh
. The remote server is running Ubuntu 22.04 and has mosh
installed. I can connect to the server, and works perfectly, but the copy to local clipboard and paste from local clipboard functionality doesn't work. Is mosh
supported?
If using ssh
instead of mosh
, things work, even without this plugin. I wanted to use this plugin hoping it would make the copy/paste from/to local clipboard work.
While most terminal emulates don't support reading from the clipboard, there is growing support for this feature โ the next release of iTerm (3.5) will allow for querying the clipboard.
It'd be nice to support pasting for those who use a terminal emulator that supports querying the clipboard via OSC 52!
When pressing gv
(:help reselect-visual), it should reselect the copied region (visual block).
Reproduction:
vim.keymap.set('v', '<leader>y', require('osc52').copy_visual)
<leader>y
(osc52.copy_visual)Some codes like the following would be needed:
local start = vim.fn.getpos("'<")
local end = vim.fn.getpos("'>")
-- copy OSC52...
vim.fn.setpos("'<", start)
vim.fn.setpos("'>", end)
I was testing nvim-osc52 with nvim (0.7.2) and patched konsole with with osc52 support, and noticed that copying gets truncated on certain input (konsole patch here).
For example, copying osc52.lua itself from the source code, produces only this when pasting:
-------------------- VARIABLES -----------------------------
local base64 = require('base64')
local fmt = string.format
local commands = {
operator = {block = "`[\\<C-v>`]y", char = "`[
I'm not sure if it's an issue with plugin or with konsole's handling of osc52.
This plugin is amazing!
Mac is my remote computer at Home, I use windows PC in office to access Mac over SSH
How can I psate from Windows PC clipboard to Mac neovim with key "p" over SSH๏ผ
Thank you
My Mac OS config with lazy.nvim:
return {
{
"ojroques/nvim-osc52",
config = function()
--vim.keymap.set("n", "<leader>c", require("osc52").copy_operator, { expr = true })
--vim.keymap.set("n", "yy", "<leader>c_", { remap = true })
--vim.keymap.set("v", "y", require("osc52").copy_visual)
require("osc52").setup({
silent = true,
})
function copy()
if vim.v.event.operator == "y" and vim.v.event.regname == "+" then
require("osc52").copy_register("+")
end
end
vim.api.nvim_create_autocmd("TextYankPost", { callback = copy })
local function copy(lines, _)
require("osc52").copy(table.concat(lines, "\n"))
end
local function paste()
return { vim.fn.split(vim.fn.getreg(""), "\n"), vim.fn.getregtype("") }
end
vim.g.clipboard = {
name = "osc52",
copy = { ["+"] = copy, ["*"] = copy },
paste = { ["+"] = paste, ["*"] = paste },
}
-- Now the '+' register will copy to system clipboard using OSC52
vim.keymap.set("n", "<leader>c", '"+y')
vim.keymap.set("n", "<leader>cc", '"+yy')
end,
},
}
Hello! I am having an odd issue in that I cannot seem to get osc52 to copy to tmux's system clipboard. I have verified that the tmux clipboard does work as I can copy things from neovim with tmux itself, but that is obviously painful.
I am using the default config in the readme
require('osc52').setup {
max_length = 0, -- Maximum length of selection (0 for no limit)
silent = false, -- Disable message on successful copy
trim = false, -- Trim text before copy
}
local function copy(lines, _)
require('osc52').copy(table.concat(lines, '\n'))
end
local function paste()
return {vim.fn.split(vim.fn.getreg(''), '\n'), vim.fn.getregtype('')}
end
vim.g.clipboard = {
name = 'osc52',
copy = {['+'] = copy, ['*'] = copy},
paste = {['+'] = paste, ['*'] = paste},
}
-- Now the '+' register will copy to system clipboard using OSC52
vim.keymap.set('n', '<leader>c', '"+y')
vim.keymap.set('n', '<leader>cc', '"+yy')
Specifically, my config can be found here
With the old version, I had this autocmd:
autocmd TextYankPost * if v:event.operator is 'y' && v:event.regname is 'c' | execute 'OSCYankReg c' | endif
Which just made the "c" register my system clipboard. I use that along with remapped Control-c and Control-v so that those standard shortcuts copy to the local system when I want that but my "unnamed" register is used normally.
" Use Ctl+c/x/v as secondary clipboard
nnoremap <silent> <C-c> "cy
vnoremap <silent> <C-c> "cy
inoremap <silent> <C-c> <C-o>"cyiw
inoremap <silent> <C-x> <C-o>"cdiw
vnoremap <silent> <C-x> "cd
nnoremap <silent> <C-x> "cdiw
nnoremap <silent> <C-v> "cp
vnoremap <silent> <C-v> "cp
inoremap <silent> <C-v> <C-o>"cp
tnoremap <silent> <C-v> <c-\><c-n>"cpa
Can you tell me the equivalent setting in the new version?
This plugin works well outside tmux, but not inside a tmux session. I've set up tmux-osc52 well (https://github.com/tmux/tmux/wiki/Clipboard#quick-summary) and I can confirm it works:
# (inside a tmux)
esc="\033]52;c;$(base64 <<< 'hello world')\a"
esc="\033Ptmux;\033$esc\033\\" # tmux needs sequence escapement
printf "$esc"
The OSC52 sequence need to be wrapped and escaped properly to enable passthrough. However, the plugin doesn't seem to be aware of tmux escape sequences:
https://github.com/ojroques/nvim-osc52/blob/main/lua/osc52.lua#L58
This can be very annoying for a global or absent statusline, because it must be confirmed via enter. Can you let the user configure this?
Would be also nice to know how to get the return status of your functions from lua code. I'd like to use my statusline instead of popups.
For me at least vim.keymap.set('n', '<leader>cc', '<leader>c_', {remap = true})
does not work properly. What is the underlying lua function to be used for this? To me '<leader>c_'
looks like there is something sneaky hiding below waiting to clash with other keybindings.
Here is a strange problem I could use help with from the good folks here. I'm using nvim-osc52 with nvim 0.7.2.
Config:
osc52
plugin enabled, g:clipboard
set as shown at the bottom here (I don't use the leader mappings, but use everything else):set clipboard=
is empty (not set)Ctrl+V
into Notepad)Behavior on a local machine <-- This is exactly the desired behavior
yy
and "*yy
both yank to clipboardcW
does not yank to clipboardBehavior on a remote machine (via ssh or mosh):
yy
does not yank to clipboard <-- This is the problem"*yy
yanks to clipboardcW
does not yank to clipboardNote that if I :set clipboard=unnamed
, the behavior changes: yy
works on the remote, but cW
also copies to the clipboard (on both local and remote), which is not what I want.
Any idea at all what this could be or even how I could debug it? Thanks much in advance!
-- Save previous visual marks in operator mode
if mode == 'operator' then
local visual_marks = {vim.fn.getpos("'<"), vim.fn.getpos("'>")}
end
-- Retrieve text
vim.go.clipboard = ''
local command = fmt('keepjumps normal! %s', commands[mode][type])
vim.cmd(fmt('silent execute "%s"', command))
local text = vim.fn.getreg('"')
-- Restore user settings
vim.go.clipboard = clipboard
vim.fn.setreg('"', register)
-- Restore previous visual marks in operator mode
if mode == 'operator' then
vim.fn.setpos("'<", visual_marks[1])
vim.fn.setpos("'>", visual_marks[2])
end
return text or ''
end
it seems like the visual_marks need to define out of the if statement?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.