diff --git a/lua/osv/init.lua b/lua/osv/init.lua index c1b7fed..71a78c8 100644 --- a/lua/osv/init.lua +++ b/lua/osv/init.lua @@ -132,13 +132,22 @@ function M.launch(opts) local has_embed = false local has_headless = false local args = {} - for _, arg in ipairs(vim.v.argv) do + local i = 1 + while i <= #vim.v.argv do + local skiparg = false + local arg = vim.v.argv[i] if arg == '--embed' then has_embed = true elseif arg == '--headless' then has_headless = true + elseif arg == '--listen' then + skiparg = true + i = i + 1 end - table.insert(args, arg) + if not skiparg then + table.insert(args, arg) + end + i = i + 1 end if not has_embed then @@ -236,6 +245,7 @@ function M.launch(opts) end M.attach() + end return server @@ -1468,13 +1478,22 @@ function M.run_this(opts) local has_embed = false local has_headless = false local args = {} - for _, arg in ipairs(vim.v.argv) do + local i = 1 + while i <= #vim.v.argv do + local skiparg = false + local arg = vim.v.argv[i] if arg == '--embed' then has_embed = true elseif arg == '--headless' then has_headless = true + elseif arg == '--listen' then + skiparg = true + i = i + 1 end - table.insert(args, arg) + if not skiparg then + table.insert(args, arg) + end + i = i + 1 end if not has_embed then diff --git a/src/launch.lua.t b/src/launch.lua.t index ca3159f..f55ab11 100644 --- a/src/launch.lua.t +++ b/src/launch.lua.t @@ -122,13 +122,20 @@ end local has_embed = false local has_headless = false local args = {} -for _, arg in ipairs(vim.v.argv) do +local i = 1 +while i <= #vim.v.argv do + local skiparg = false + local arg = vim.v.argv[i] if arg == '--embed' then has_embed = true elseif arg == '--headless' then has_headless = true + @skip_listen_arg end - table.insert(args, arg) + if not skiparg then + table.insert(args, arg) + end + i = i + 1 end if not has_embed then @@ -180,3 +187,8 @@ while true do end M.attach() + +@skip_listen_arg+= +elseif arg == '--listen' then + skiparg = true + i = i + 1