Skip to content
Open
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ Please read the associated comments before changing the value.
ssh_binary = "ssh", -- Binary to use for running SSH command
scp_binary = "scp", -- Binary to use for running SSH copy commands
ssh_config_file_paths = { "$HOME/.ssh/config" }, -- Which files should be considered to contain the ssh host configurations. NOTE: `Include` is respected in the provided files.
parse_osc52 = true, -- Workaround for nvim copy on remote problem (https://github.com/neovim/neovim/issues/28792)

-- These are useful for password-based SSH authentication.
-- It provides parsing pattern for the plugin to detect that an input is requested.
Expand Down
3 changes: 2 additions & 1 deletion doc/remote-nvim.txt
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,8 @@ value.
ssh_binary = "ssh", -- Binary to use for running SSH command
scp_binary = "scp", -- Binary to use for running SSH copy commands
ssh_config_file_paths = { "$HOME/.ssh/config" }, -- Which files should be considered to contain the ssh host configurations. NOTE: `Include` is respected in the provided files.

parse_osc52 = true, -- Workaround for nvim copy on remote problem (https://github.com/neovim/neovim/issues/28792)

-- These are useful for password-based SSH authentication.
-- It provides parsing pattern for the plugin to detect that an input is requested.
-- Each element contains the following attributes:
Expand Down
2 changes: 2 additions & 0 deletions lua/remote-nvim/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ local utils = require("remote-nvim.utils")
---@field scp_binary string Name of binary on runtime path for scp
---@field ssh_config_file_paths string[] Location of SSH configuration files that you want the plugin to consider
---@field ssh_prompts remote-nvim.config.PluginConfig.SSHConfig.SSHPrompt[] List of SSH prompts that should be considered for input
---@field parse_osc52 boolean Should the plugin parse for OSC52 sequences and copy them to the local clipboard

---@class remote-nvim.config.RemoteConfig.LocalClientConfig
---@field callback function<string, remote-nvim.providers.WorkspaceConfig> Function that would be called upon to start a Neovim client
Expand Down Expand Up @@ -107,6 +108,7 @@ M.default_opts = {
ssh_binary = "ssh",
scp_binary = "scp",
ssh_config_file_paths = { "$HOME/.ssh/config" },
parse_osc52 = true,
ssh_prompts = {
{ -- Handle default password style on Linux/macOS
match = "password:",
Expand Down
18 changes: 17 additions & 1 deletion lua/remote-nvim/providers/provider.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1032,10 +1032,26 @@ function Provider:run_command(command, desc, extra_opts, exit_cb, on_local_execu
if exit_cb ~= nil then
exit_cb = exit_cb(section_node)
end

local node_stdout_cb = self:_get_stdout_fn_for_node(section_node)
local stdout_cb = function(stdout_chunk)
node_stdout_cb(stdout_chunk)

if remote_nvim.config.ssh_config.parse_osc52 then
local data = stdout_chunk:match("^%c%]%d*;c;([^\a]*)%c\\")
if data then
stdout_chunk = stdout_chunk:gsub("^%c%]%d*;c;([^\a]*)%c\\", "")
local text = vim.fn.systemlist("base64 --decode", data)
vim.fn.setreg("+", text)
vim.notify("Copied to clipboard via OSC52")
end
end
end

executor:run_command(command, {
additional_conn_opts = extra_opts,
exit_cb = exit_cb,
stdout_cb = self:_get_stdout_fn_for_node(section_node),
stdout_cb = stdout_cb,
})
self.logger.fmt_debug("[%s][%s] Running %s completed", self.provider_type, self.unique_host_id, command)
if exit_cb == nil then
Expand Down