diff options
author | Mathias Fußenegger <mfussenegger@users.noreply.github.com> | 2022-08-29 18:26:14 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-08-29 18:26:14 +0200 |
commit | 126fe7fbc9c88c412c8067d9d146d998baf6dd47 (patch) | |
tree | df3b180aeb473deb95c68cf4cececfd7412f9bef /test | |
parent | 92bc11a891538e5c306915bffef437f097572d09 (diff) | |
parent | 60ec6e34d585a7f633d49aab790066c1740885e1 (diff) | |
download | rneovim-126fe7fbc9c88c412c8067d9d146d998baf6dd47.tar.gz rneovim-126fe7fbc9c88c412c8067d9d146d998baf6dd47.tar.bz2 rneovim-126fe7fbc9c88c412c8067d9d146d998baf6dd47.zip |
Merge pull request #19916 from mfussenegger/lsp-tcp
Adds TCP support for lsp.
Usage example:
```
vim.lsp.start({ name = 'godot', cmd = vim.lsp.rpc.connect('127.0.0.1', 6008) })
```
Diffstat (limited to 'test')
-rw-r--r-- | test/functional/plugin/lsp_spec.lua | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/test/functional/plugin/lsp_spec.lua b/test/functional/plugin/lsp_spec.lua index cd7415de90..fa731f6faf 100644 --- a/test/functional/plugin/lsp_spec.lua +++ b/test/functional/plugin/lsp_spec.lua @@ -3181,4 +3181,32 @@ describe('LSP', function() } end) end) + + describe('cmd', function() + it('can connect to lsp server via rpc.connect', function() + local result = exec_lua [[ + local uv = vim.loop + local server = uv.new_tcp() + local init = nil + server:bind('127.0.0.1', 0) + server:listen(127, function(err) + assert(not err, err) + local socket = 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 + vim.lsp.start({ name = 'dummy', cmd = vim.lsp.rpc.connect('127.0.0.1', port) }) + vim.wait(1000, function() return init ~= nil end) + assert(init, "server must receive `initialize` request") + server:close() + server:shutdown() + return vim.json.decode(init) + ]] + eq(result.method, "initialize") + end) + end) end) |