diff options
author | Tristan Knight <admin@snappeh.com> | 2024-09-03 16:10:39 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-09-03 08:10:39 -0700 |
commit | 45e76acaa053a077cab49b6606536d3f2646f033 (patch) | |
tree | 41f6c72705df360f795777bb68b6a36e75643ab0 /test/functional/plugin/lsp/testutil.lua | |
parent | fdd3a9cdf7167ca8fc84ec9a7e583f6410a27188 (diff) | |
download | rneovim-45e76acaa053a077cab49b6606536d3f2646f033.tar.gz rneovim-45e76acaa053a077cab49b6606536d3f2646f033.tar.bz2 rneovim-45e76acaa053a077cab49b6606536d3f2646f033.zip |
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.
Diffstat (limited to 'test/functional/plugin/lsp/testutil.lua')
-rw-r--r-- | test/functional/plugin/lsp/testutil.lua | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/test/functional/plugin/lsp/testutil.lua b/test/functional/plugin/lsp/testutil.lua index 2595f6ad09..f60d111f87 100644 --- a/test/functional/plugin/lsp/testutil.lua +++ b/test/functional/plugin/lsp/testutil.lua @@ -21,6 +21,33 @@ function M.clear_notrace() } end +M.create_tcp_echo_server = function() + --- Create a TCP server that echos the first message it receives. + --- @param host string + ---@return uv.uv_tcp_t + ---@return integer + ---@return fun():string|nil + function _G._create_tcp_server(host) + local uv = vim.uv + local server = assert(uv.new_tcp()) + local init = nil + server:bind(host, 0) + server:listen(127, function(err) + assert(not err, err) + local socket = assert(uv.new_tcp()) + server:accept(socket) + socket:read_start(require('vim.lsp.rpc').create_read_loop(function(body) + init = body + socket:close() + end)) + end) + local port = server:getsockname().port + return server, port, function() + return init + end + end +end + M.create_server_definition = function() function _G._create_server(opts) opts = opts or {} |