ayamir / nvimdots

A well configured and structured Neovim.
BSD 3-Clause "New" or "Revised" License
2.95k stars 461 forks source link

proposal:给ssh远程开发提供一个全局剪切板能力 #303

Closed kevin1sMe closed 2 years ago

kevin1sMe commented 2 years ago

描述Bug

给ssh远程开发提供一个全局剪切板能力?

如何复现 本地机器MacOS,远程机器为Ubuntu等linux系统,目前插件配置不了解如何可支持远程复制。

期待的表现

最好可以用原生复制方式拷贝到系统(全局)剪切板,本机和远程开发机共享剪切板的效果。 希望默认仓库可以支持这个能力。若有需要我可以提PR:)

截图

运行环境

额外信息 我尝试用了这个插件:ojroques/vim-oscyank能解决问题。 见这个commit

注意:没有任何信息的issue将会被直接关闭,请不要浪费双方的时间。

ayamir commented 2 years ago

I tend to use its lua version: ojroques/nvim-osc52. But there is no convenient method to detect whether it runs on a remote machine AFAIK. I have no idea to set clipboard for it like what I did for wsl and macOS here.

kevin1sMe commented 2 years ago

I tend to use its lua version: ojroques/nvim-osc52. But there is no convenient method to detect whether it runs on a remote machine AFAIK. I have no idea to set clipboard for it like what I did for wsl and macOS here.

I try to use nvim-osc52, but not work. Can you show me example config? Thanks.

CharlesChiuGit commented 2 years ago
require("osc52").setup({
    max_length = 0, -- Maximum length of selection (0 for no limit)
    silent = true, -- Disable message on successful copy
    trim = false, -- Trim text before copy
})

--- nvim-osc52 keymap
-- In normal mode, <leader>c is an operator that will copy the given text to the clipboard.
vim.keymap.set("n", "<leader>c", require("osc52").copy_operator, { expr = true })
-- In normal mode, <leader>cc will copy the current line.
vim.keymap.set("n", "<leader>cc", "<leader>c_", { remap = true })
-- In visual mode, <leader>c will copy the current selection.
vim.keymap.set("x", "<leader>c", require("osc52").copy_visual)
CharlesChiuGit commented 2 years ago

@kevin1sMe Also, please check #275 . And make sure your terminal and remote program both supports osc.

My smartyank config:

require("smartyank").setup({
    highlight = {
        enabled = false, -- highlight yanked text
        higroup = "IncSearch", -- highlight group of yanked text
        timeout = 2000, -- timeout for clearing the highlight
    },
    clipboard = {
        enabled = true,
    },
    tmux = {
        enabled = true,
        -- remove `-w` to disable copy to host client's clipboard
        cmd = { "tmux", "set-buffer", "-w" },
    },
    osc52 = {
        enabled = true,
        ssh_only = true, -- false to OSC52 yank also in local sessions
        silent = false, -- true to disable the "n chars copied" echo
        echo_hl = "Directory", -- highlight group of the OSC52 echo message
    },
})
CharlesChiuGit commented 2 years ago

There's also another option which is to mount your remote files in your local system. Pleae check this video.

ayamir commented 2 years ago

You can create a PR for smartyank if it support osc52 :)

kevin1sMe commented 2 years ago

There's also another option which is to mount your remote files in your local system. Pleae check this video.

Thank you for your reply. I'll have a try for your smartyank config!

BTW: I connect to remote server for coding using nvim. So... I don't like mount to local filesystem for edit:(

CharlesChiuGit commented 2 years ago

@kevin1sMe That's totally fine! It's up to u. I like to mount the remote files b/c i have quite a few remote servers to deal with. 🥲

@ayamir Sure, I'll do some tests to make sure everything works as expected before sending the PR.

kevin1sMe commented 2 years ago

@kevin1sMe That's totally fine! It's up to u. I like to mount the remote files b/c i have quite a few remote server sto deal with. 🥲

@ayamir Sure, I'll do some tests to make sure everything works as expected before sending the PR.

smartyank work for me, thanks