mirror of
https://github.com/neovim/neovim.git
synced 2025-10-21 09:12:07 +00:00
feat(lsp): support hostname in rpc.connect #30238
Updated the `rpc.connect` function to support connecting to LSP servers using hostnames, not just IP addresses. This change includes updates to the documentation and additional test cases to verify the new functionality. - Modified `connect` function to resolve hostnames. - Updated documentation to reflect the change. - Added test case for connecting using hostname. Added a TCP echo server utility function to the LSP test suite. This server echoes the first message it receives and is used in tests to verify LSP server connections via both IP address and hostname. Refactored existing tests to use the new utility function.
This commit is contained in:
@@ -627,12 +627,12 @@ end
|
||||
---
|
||||
--- - a named pipe (windows)
|
||||
--- - a domain socket (unix)
|
||||
--- - a host and port via TCP (host must be IP address)
|
||||
--- - a host and port via TCP
|
||||
---
|
||||
--- Return a function that can be passed to the `cmd` field for
|
||||
--- |vim.lsp.start_client()| or |vim.lsp.start()|.
|
||||
---
|
||||
---@param host_or_path string host (IP address) to connect to or path to a pipe/domain socket
|
||||
---@param host_or_path string host to connect to or path to a pipe/domain socket
|
||||
---@param port integer? TCP port to connect to. If absent the first argument must be a pipe
|
||||
---@return fun(dispatchers: vim.lsp.rpc.Dispatchers): vim.lsp.rpc.PublicClient
|
||||
function M.connect(host_or_path, port)
|
||||
@@ -703,7 +703,9 @@ function M.connect(host_or_path, port)
|
||||
if port == nil then
|
||||
handle:connect(host_or_path, on_connect)
|
||||
else
|
||||
handle:connect(host_or_path, port, on_connect)
|
||||
local info = uv.getaddrinfo(host_or_path, nil)
|
||||
local resolved_host = info and info[1] and info[1].addr or host_or_path
|
||||
handle:connect(resolved_host, port, on_connect)
|
||||
end
|
||||
|
||||
return public_client(client)
|
||||
|
Reference in New Issue
Block a user