aboutsummaryrefslogtreecommitdiff
path: root/test/functional/plugin/lsp/helpers.lua
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2024-03-26 21:11:32 +0800
committerGitHub <noreply@github.com>2024-03-26 21:11:32 +0800
commit0c0be09eab66975e62c67522620fee10f82663d2 (patch)
treee71da19376756a3a0fa7dfa4805062cf4197323d /test/functional/plugin/lsp/helpers.lua
parent3f3c7299a14ff0025487a416462d8c32d922e04a (diff)
downloadrneovim-0c0be09eab66975e62c67522620fee10f82663d2.tar.gz
rneovim-0c0be09eab66975e62c67522620fee10f82663d2.tar.bz2
rneovim-0c0be09eab66975e62c67522620fee10f82663d2.zip
test(lsp): fix flaky basic_finish test again (#28041)
Problem: LSP basic_finish test modified in #27899 is flaky again after #28030. Solution: Run on_setup() immediately after setup using a before_init callback.
Diffstat (limited to 'test/functional/plugin/lsp/helpers.lua')
-rw-r--r--test/functional/plugin/lsp/helpers.lua15
1 files changed, 13 insertions, 2 deletions
diff --git a/test/functional/plugin/lsp/helpers.lua b/test/functional/plugin/lsp/helpers.lua
index 376de66c51..375bff06af 100644
--- a/test/functional/plugin/lsp/helpers.lua
+++ b/test/functional/plugin/lsp/helpers.lua
@@ -105,6 +105,11 @@ local function fake_lsp_server_setup(test_name, timeout_ms, options, settings)
uri = 'file://' .. vim.uv.cwd(),
name = 'test_folder',
}};
+ before_init = function(params, config)
+ vim.schedule(function()
+ vim.rpcrequest(1, "setup")
+ end)
+ end,
on_init = function(client, result)
TEST_RPC_CLIENT = client
vim.rpcrequest(1, "init", result)
@@ -173,6 +178,12 @@ function M.test_rpc_server(config)
--- @type integer, integer
local code, signal
local function on_request(method, args)
+ if method == 'setup' then
+ if config.on_setup then
+ config.on_setup()
+ end
+ return NIL
+ end
if method == 'init' then
if config.on_init then
config.on_init(client, unpack(args))
@@ -193,8 +204,8 @@ function M.test_rpc_server(config)
end
end
-- TODO specify timeout?
- -- run(on_request, on_notify, config.on_setup, 1000)
- run(on_request, on_notify, config.on_setup)
+ -- run(on_request, on_notify, nil, 1000)
+ run(on_request, on_notify, nil)
if config.on_exit then
config.on_exit(code, signal)
end