feat(config): add per-host/bucket extra args for SSH, S3, and FTP (#171)
* fix(view): reapply column highlights after paste and buffer edits Problem: Column extmarks (icon color, per-character permissions) are applied via `util.set_highlights` only during `render_buffer`. Neovim does not duplicate extmarks on yank/paste, so lines inserted via `yyp` or `p` render without any column highlights. Solution: Store `col_width` and `col_align` in `session[bufnr]` after each render. Add `M.reapply_highlights` which re-parses all buffer lines, reconstructs the column chunk table, and re-applies extmarks via `util.set_highlights`. Wire it to a `TextChanged` autocmd (guarded by `_rendering[bufnr]` to skip oil's own `nvim_buf_set_lines` calls). * fix(view): resolve LuaLS warnings in `reapply_highlights` * feat(config): add per-host/bucket extra args for SSH, S3, and FTP Problem: `extra_scp_args`, `extra_s3_args`, and `extra_curl_args` are global — there's no way to pass adapter-specific args only to a single host or bucket (e.g. `-O` for a Synology NAS that requires legacy SCP protocol, or `--endpoint-url` for an R2 bucket). Solution: add `ssh_hosts`, `s3_buckets`, and `ftp_hosts` config tables that map exact hostnames/bucket names to per-target arg lists. Per-target args are appended after the global args at call time. The `scp()` helper in `ssh.lua` accepts a `hosts` list so cross-host copies deduplicate host lookups. `create_s3_command` in `s3fs.lua` extracts the bucket from the command args with no call-site changes needed. `resolved_curl_args` in `ftp.lua` is called by both `curl()` and `ftpcmd()`. Based on: stevearc/oil.nvim#607
This commit is contained in:
parent
f988996059
commit
e387a57c0e
7 changed files with 227 additions and 22 deletions
|
|
@ -106,6 +106,17 @@ local function curl_ftp_url(url)
|
|||
return table.concat(pieces, '')
|
||||
end
|
||||
|
||||
---@param host string
|
||||
---@return string[]
|
||||
local function resolved_curl_args(host)
|
||||
local extra = vim.deepcopy(config.extra_curl_args)
|
||||
local host_cfg = config.ftp_hosts[host]
|
||||
if host_cfg and host_cfg.extra_curl_args then
|
||||
vim.list_extend(extra, host_cfg.extra_curl_args)
|
||||
end
|
||||
return extra
|
||||
end
|
||||
|
||||
---@param url oil.ftpUrl
|
||||
---@param py_lines string[]
|
||||
---@param cb fun(err: nil|string)
|
||||
|
|
@ -113,8 +124,8 @@ local function ftpcmd(url, py_lines, cb)
|
|||
local lines = {}
|
||||
local use_tls = url.scheme == 'oil-ftps://'
|
||||
if use_tls then
|
||||
local insecure = vim.tbl_contains(config.extra_curl_args, '--insecure')
|
||||
or vim.tbl_contains(config.extra_curl_args, '-k')
|
||||
local curl_args = resolved_curl_args(url.host)
|
||||
local insecure = vim.tbl_contains(curl_args, '--insecure') or vim.tbl_contains(curl_args, '-k')
|
||||
table.insert(lines, 'import ftplib, ssl')
|
||||
table.insert(lines, 'ctx = ssl.create_default_context()')
|
||||
if insecure then
|
||||
|
|
@ -170,7 +181,7 @@ local function curl(url, extra_args, opts, cb)
|
|||
end
|
||||
local cmd = { 'curl', '-sS', '--netrc-optional' }
|
||||
vim.list_extend(cmd, ssl_args(url))
|
||||
vim.list_extend(cmd, config.extra_curl_args)
|
||||
vim.list_extend(cmd, resolved_curl_args(url.host))
|
||||
vim.list_extend(cmd, extra_args)
|
||||
shell.run(cmd, opts, cb)
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue