From 17bcd37f8d91dcb987456be456d8a95db1a772ba Mon Sep 17 00:00:00 2001 From: Chip Senkbeil Date: Mon, 24 Jul 2023 14:14:08 -0500 Subject: [PATCH] Fix several distant commands where optional parameters were not parsed in the correct format --- README.md | 3 +++ lua/distant/commands/distant_cancel_search.lua | 5 +---- lua/distant/commands/distant_check_health.lua | 2 +- lua/distant/commands/distant_metadata.lua | 1 + lua/distant/commands/distant_mkdir.lua | 1 + lua/distant/commands/distant_open.lua | 14 +++++++++++++- lua/distant/commands/distant_search.lua | 13 +++++++++++-- lua/distant/init.lua | 2 +- 8 files changed, 32 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 3ef7e02..ab77dff 100644 --- a/README.md +++ b/README.md @@ -10,6 +10,9 @@ enables users to edit remote files from the comfort of their local environment. Visit https://distant.dev/editors/neovim/ for full documentation! +🚧 **(Alpha stage software) This plugin is in rapid development and may +break or change frequently!** 🚧 + ## Installation ### lazy.nvim diff --git a/lua/distant/commands/distant_cancel_search.lua b/lua/distant/commands/distant_cancel_search.lua index 5edc462..d4c583b 100644 --- a/lua/distant/commands/distant_cancel_search.lua +++ b/lua/distant/commands/distant_cancel_search.lua @@ -1,12 +1,9 @@ local plugin = require('distant') -local utils = require('distant.commands.utils') --- DistantCancelSearch --- @param cmd NvimCommand +--- @diagnostic disable-next-line:unused-local local function command(cmd) - local input = utils.parse_args(cmd.args) - utils.paths_to_number(input.opts, { 'timeout', 'interval' }) - plugin.editor.cancel_search() end diff --git a/lua/distant/commands/distant_check_health.lua b/lua/distant/commands/distant_check_health.lua index 242ca6f..a16a2c2 100644 --- a/lua/distant/commands/distant_check_health.lua +++ b/lua/distant/commands/distant_check_health.lua @@ -1,4 +1,4 @@ ---- DistantCancelSearch +--- DistantCheckHealth --- @param cmd NvimCommand --- @diagnostic disable-next-line:unused-local local function command(cmd) diff --git a/lua/distant/commands/distant_metadata.lua b/lua/distant/commands/distant_metadata.lua index 891f81b..36a49ca 100644 --- a/lua/distant/commands/distant_metadata.lua +++ b/lua/distant/commands/distant_metadata.lua @@ -6,6 +6,7 @@ local utils = require('distant.commands.utils') local function command(cmd) local input = utils.parse_args(cmd.args) utils.paths_to_number(input.opts, { 'timeout', 'interval' }) + utils.paths_to_bool(input.opts, { 'canonicalize', 'resolve_file_type' }) local path = input.args[1] input.opts.path = path diff --git a/lua/distant/commands/distant_mkdir.lua b/lua/distant/commands/distant_mkdir.lua index 9743384..2461679 100644 --- a/lua/distant/commands/distant_mkdir.lua +++ b/lua/distant/commands/distant_mkdir.lua @@ -6,6 +6,7 @@ local utils = require('distant.commands.utils') local function command(cmd) local input = utils.parse_args(cmd.args) utils.paths_to_number(input.opts, { 'timeout', 'interval' }) + utils.paths_to_bool(input.opts, { 'all' }) local path = input.args[1] input.opts.path = path diff --git a/lua/distant/commands/distant_open.lua b/lua/distant/commands/distant_open.lua index d3ba00c..4e52157 100644 --- a/lua/distant/commands/distant_open.lua +++ b/lua/distant/commands/distant_open.lua @@ -5,7 +5,19 @@ local utils = require('distant.commands.utils') --- @param cmd NvimCommand local function command(cmd) local input = utils.parse_args(cmd.args) - utils.paths_to_number(input.opts, { 'buf', 'win' }) + utils.paths_to_number(input.opts, { + 'bufnr', + 'winnr', + 'line', + 'col', + 'client_id', + 'timeout', + 'interval', + }) + utils.paths_to_bool(input.opts, { + 'reload', + 'no_focus', + }) local opts = input.opts local path = input.args[1] diff --git a/lua/distant/commands/distant_search.lua b/lua/distant/commands/distant_search.lua index 4e12c01..211e350 100644 --- a/lua/distant/commands/distant_search.lua +++ b/lua/distant/commands/distant_search.lua @@ -5,8 +5,17 @@ local utils = require('distant.commands.utils') --- @param cmd NvimCommand local function command(cmd) local input = utils.parse_args(cmd.args) - utils.paths_to_number(input.opts, { 'pagination', 'limit', 'max_depth', 'timeout', 'interval' }) - utils.paths_to_bool(input.opts, { 'follow_symbolic_links' }) + utils.paths_to_number(input.opts, { + 'pagination', + 'limit', + 'max_depth', + 'timeout', + 'interval', + }) + utils.paths_to_bool(input.opts, { + 'follow_symbolic_links', + 'upward', + }) local timeout = tonumber(input.opts.timeout) local interval = tonumber(input.opts.interval) diff --git a/lua/distant/init.lua b/lua/distant/init.lua index 21afcf8..ca72c8b 100644 --- a/lua/distant/init.lua +++ b/lua/distant/init.lua @@ -753,7 +753,7 @@ end --- --- Will fail with an error if the shell fails to spawn. --- ---- @param opts {bufnr:number, winnr?:number, cmd?:string|string[], cwd?:string, env?:table} +--- @param opts {bufnr?:number, winnr?:number, cmd?:string|string[], cwd?:string, env?:table} --- @return number bufnr function M:spawn_shell(opts) opts = opts or {}