feat: serverlist({peer=true}) returns peer addresses #34806

Problem:
serverlist() only lists servers that were started by the current Nvim.

Solution:
Look for other Nvim servers in stdpath("run").
This commit is contained in:
Siddhant Agarwal
2025-07-28 10:10:04 +05:30
committed by GitHub
parent d08b265111
commit 5151f635ca
6 changed files with 112 additions and 5 deletions

View File

@@ -162,7 +162,7 @@ describe('server', function()
end)
it('serverlist() returns the list of servers', function()
clear()
local current_server = clear()
-- There should already be at least one server.
local _n = eval('len(serverlist())')
@@ -186,6 +186,24 @@ describe('server', function()
end
-- After serverstop() the servers should NOT be in the list.
eq(_n, eval('len(serverlist())'))
-- serverlist({ peer = true }) returns servers from other Nvim sessions.
if t.is_os('win') then
return
end
local client_address = n.new_pipename()
local client = n.new_session(
true,
{ args = { '-u', 'NONE', '--listen', client_address, '--embed' }, merge = false }
)
n.set_session(client)
eq(client_address, fn.serverlist()[1])
n.set_session(current_server)
new_servs = fn.serverlist({ peer = true })
eq(true, vim.list_contains(new_servs, client_address))
client:close()
end)
end)