Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Adding in SCP options configuration #340

Merged
merged 5 commits into from
May 6, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
10 changes: 5 additions & 5 deletions lua/oil/adapters/ssh.lua
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ M.perform_action = function(action, cb)
local src_conn = get_connection(action.src_url)
local dest_conn = get_connection(action.dest_url)
if src_conn ~= dest_conn then
shell.run({ "scp", "-C", "-r", url_to_scp(src_res), url_to_scp(dest_res) }, function(err)
shell.run({ "scp", table.unpack(config.extra_scp_options), "-C", "-r", url_to_scp(src_res), url_to_scp(dest_res) }, function(err)
if err then
return cb(err)
end
Expand All @@ -322,7 +322,7 @@ M.perform_action = function(action, cb)
local src_res = M.parse_url(action.src_url)
local dest_res = M.parse_url(action.dest_url)
if not url_hosts_equal(src_res, dest_res) then
shell.run({ "scp", "-C", "-r", url_to_scp(src_res), url_to_scp(dest_res) }, cb)
shell.run({ "scp", table.unpack(config.extra_scp_options), "-C", "-r", url_to_scp(src_res), url_to_scp(dest_res) }, cb)
else
local src_conn = get_connection(action.src_url)
src_conn:cp(src_res.path, dest_res.path, cb)
Expand All @@ -341,7 +341,7 @@ M.perform_action = function(action, cb)
src_arg = fs.posix_to_os_path(path)
dest_arg = url_to_scp(M.parse_url(action.dest_url))
end
shell.run({ "scp", "-C", "-r", src_arg, dest_arg }, cb)
shell.run({ "scp", table.unpack(config.extra_scp_options), "-C", "-r", src_arg, dest_arg }, cb)
end
else
cb(string.format("Bad action type: %s", action.type))
Expand All @@ -365,7 +365,7 @@ M.read_file = function(bufnr)
end
local tmp_bufnr = vim.fn.bufadd(tmpfile)

shell.run({ "scp", "-C", scp_url, tmpfile }, function(err)
shell.run({ "scp", table.unpack(config.extra_scp_options), "-C", scp_url, tmpfile }, function(err)
loading.set_loading(bufnr, false)
vim.bo[bufnr].modifiable = true
vim.cmd.doautocmd({ args = { "BufReadPre", bufname }, mods = { silent = true } })
Expand Down Expand Up @@ -405,7 +405,7 @@ M.write_file = function(bufnr)
vim.cmd.write({ args = { tmpfile }, bang = true, mods = { silent = true, noautocmd = true } })
local tmp_bufnr = vim.fn.bufadd(tmpfile)

shell.run({ "scp", "-C", tmpfile, scp_url }, function(err)
shell.run({ "scp", table.unpack(config.extra_scp_options), "-C", tmpfile, scp_url }, function(err)
vim.bo[bufnr].modifiable = true
if err then
vim.notify(string.format("Error writing file: %s", err), vim.log.levels.ERROR)
Expand Down
4 changes: 4 additions & 0 deletions lua/oil/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ local default_config = {
conceallevel = 3,
concealcursor = "nvic",
},
-- Extra options to send in with SCP command line (i.e. -O for openSSH 9 to older boxes)
-- If you are seeing errors related to sftp servers, this will be your friend
-- For more information: https://www.openssh.com/txt/release-9.0
extra_scp_options = { },
-- Send deleted files to the trash instead of permanently deleting them (:help oil-trash)
delete_to_trash = false,
-- Skip the confirmation popup for simple operations (:help oil.skip_confirm_for_simple_edits)
Expand Down