Skip to content

Commit

Permalink
fix launch() when nvim is opened with --listen
Browse files Browse the repository at this point in the history
Ref #57
  • Loading branch information
jbyuki committed Dec 22, 2024
1 parent 7f47c32 commit 5d2edc8
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 6 deletions.
27 changes: 23 additions & 4 deletions lua/osv/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -236,6 +245,7 @@ function M.launch(opts)
end

M.attach()

end

return server
Expand Down Expand Up @@ -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
Expand Down
16 changes: 14 additions & 2 deletions src/launch.lua.t
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -180,3 +187,8 @@ while true do
end

M.attach()

@skip_listen_arg+=
elseif arg == '--listen' then
skiparg = true
i = i + 1

0 comments on commit 5d2edc8

Please sign in to comment.