feat(lsp): support connect via named pipes/unix domain sockets (#26032)

Closes https://github.com/neovim/neovim/issues/26031

Co-authored-by: Mathias Fussenegger <f.mathias@zignar.net>
This commit is contained in:
TheLeoP
2024-01-02 04:08:36 -05:00
committed by GitHub
parent 4ee656e4f3
commit 3f788e73b3
4 changed files with 255 additions and 81 deletions

View File

@@ -3861,6 +3861,39 @@ describe('LSP', function()
]]
eq(result.method, "initialize")
end)
it('can connect to lsp server via rpc.domain_socket_connect', function()
local tmpfile
if is_os("win") then
tmpfile = "\\\\.\\\\pipe\\pipe.test"
else
tmpfile = helpers.tmpname()
os.remove(tmpfile)
end
local result = exec_lua([[
local SOCK = ...
local uv = vim.uv
local server = uv.new_pipe(false)
server:bind(SOCK)
local init = nil
server:listen(127, function(err)
assert(not err, err)
local client = uv.new_pipe()
server:accept(client)
client:read_start(require("vim.lsp.rpc").create_read_loop(function(body)
init = body
client:close()
end))
end)
vim.lsp.start({ name = "dummy", cmd = vim.lsp.rpc.domain_socket_connect(SOCK) })
vim.wait(1000, function() return init ~= nil end)
assert(init, "server must receive `initialize` request")
server:close()
server:shutdown()
return vim.json.decode(init)
]], tmpfile)
eq(result.method, "initialize")
end)
end)
describe('handlers', function()