diff options
| author | William Boman <william@redwill.se> | 2022-04-18 21:34:31 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-04-18 21:34:31 +0200 |
| commit | 43b273803e39f355f704bfdb3037ea83cee664e2 (patch) | |
| tree | b0aca00c9d36a160be512b5d94834e91ac897e7c | |
| parent | add cargo to healthcheck (diff) | |
| download | mason-43b273803e39f355f704bfdb3037ea83cee664e2.tar mason-43b273803e39f355f704bfdb3037ea83cee664e2.tar.gz mason-43b273803e39f355f704bfdb3037ea83cee664e2.tar.bz2 mason-43b273803e39f355f704bfdb3037ea83cee664e2.tar.lz mason-43b273803e39f355f704bfdb3037ea83cee664e2.tar.xz mason-43b273803e39f355f704bfdb3037ea83cee664e2.tar.zst mason-43b273803e39f355f704bfdb3037ea83cee664e2.zip | |
fix(spawn): recursively parse arglist (#610)
| -rw-r--r-- | lua/nvim-lsp-installer/core/spawn.lua | 19 | ||||
| -rw-r--r-- | tests/core/spawn_spec.lua | 1 |
2 files changed, 13 insertions, 7 deletions
diff --git a/lua/nvim-lsp-installer/core/spawn.lua b/lua/nvim-lsp-installer/core/spawn.lua index 8ac06aa4..355df029 100644 --- a/lua/nvim-lsp-installer/core/spawn.lua +++ b/lua/nvim-lsp-installer/core/spawn.lua @@ -33,18 +33,23 @@ local function Failure(err, cmd) })) end +local function parse_args(args, dest) + for _, arg in ipairs(args) do + if type(arg) == "table" then + parse_args(arg, dest) + elseif arg ~= vim.NIL then + dest[#dest + 1] = arg + end + end + return dest +end + setmetatable(spawn, { __index = function(self, k) ---@param args string|nil|string[][] return function(args) local cmd_args = {} - for _, arg in ipairs(args) do - if type(arg) == "table" then - vim.list_extend(cmd_args, arg) - elseif arg ~= vim.NIL then - cmd_args[#cmd_args + 1] = arg - end - end + parse_args(args, cmd_args) ---@type JobSpawnOpts local spawn_args = { stdio_sink = args.stdio_sink, diff --git a/tests/core/spawn_spec.lua b/tests/core/spawn_spec.lua index 7c0a27f8..be23a4ff 100644 --- a/tests/core/spawn_spec.lua +++ b/tests/core/spawn_spec.lua @@ -56,6 +56,7 @@ describe("async spawn", function() spawn._when(true, "-c"), spawn._when(false, "shouldnotbeincluded"), vim.NIL, + { vim.NIL, vim.NIL }, 'echo "Hello $VAR"', env = { "VAR=world" }, } |
