mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
LSP: add test for workspace/configuration handler
This commit is contained in:
parent
e467d29390
commit
f3bbc92476
@ -109,6 +109,23 @@ function tests.basic_init()
|
|||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function tests.check_workspace_configuration()
|
||||||
|
skeleton {
|
||||||
|
on_init = function(_params)
|
||||||
|
return { capabilities = {} }
|
||||||
|
end;
|
||||||
|
body = function()
|
||||||
|
notify('start')
|
||||||
|
notify('workspace/configuration', { items = {
|
||||||
|
{ section = "testSetting1" };
|
||||||
|
{ section = "testSetting2" };
|
||||||
|
} })
|
||||||
|
expect_notification('workspace/configuration', { true; vim.NIL})
|
||||||
|
notify('shutdown')
|
||||||
|
end;
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
function tests.basic_check_capabilities()
|
function tests.basic_check_capabilities()
|
||||||
skeleton {
|
skeleton {
|
||||||
on_init = function(params)
|
on_init = function(params)
|
||||||
|
@ -262,6 +262,48 @@ describe('LSP', function()
|
|||||||
}
|
}
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
it('client should return settings via workspace/configuration handler', function()
|
||||||
|
local expected_callbacks = {
|
||||||
|
{NIL, "shutdown", {}, 1};
|
||||||
|
{NIL, "workspace/configuration", { items = {
|
||||||
|
{ section = "testSetting1" };
|
||||||
|
{ section = "testSetting2" };
|
||||||
|
}}, 1};
|
||||||
|
{NIL, "start", {}, 1};
|
||||||
|
}
|
||||||
|
local client
|
||||||
|
test_rpc_server {
|
||||||
|
test_name = "check_workspace_configuration";
|
||||||
|
on_init = function(_client)
|
||||||
|
client = _client
|
||||||
|
end;
|
||||||
|
on_exit = function(code, signal)
|
||||||
|
eq(0, code, "exit code", fake_lsp_logfile)
|
||||||
|
eq(0, signal, "exit signal", fake_lsp_logfile)
|
||||||
|
end;
|
||||||
|
on_callback = function(err, method, params, client_id)
|
||||||
|
eq(table.remove(expected_callbacks), {err, method, params, client_id}, "expected callback")
|
||||||
|
if method == 'start' then
|
||||||
|
exec_lua([=[
|
||||||
|
local client = vim.lsp.get_client_by_id(TEST_RPC_CLIENT_ID)
|
||||||
|
client.config.settings = {
|
||||||
|
testSetting1 = true;
|
||||||
|
testSetting2 = false;
|
||||||
|
}]=])
|
||||||
|
end
|
||||||
|
if method == 'workspace/configuration' then
|
||||||
|
local result = exec_lua([=[
|
||||||
|
local method, params = ...
|
||||||
|
return require'vim.lsp.handlers'['workspace/configuration'](err, method, params, TEST_RPC_CLIENT_ID)]=], method, params)
|
||||||
|
client.notify('workspace/configuration', result)
|
||||||
|
end
|
||||||
|
if method == 'shutdown' then
|
||||||
|
client.stop()
|
||||||
|
end
|
||||||
|
end;
|
||||||
|
}
|
||||||
|
end)
|
||||||
|
|
||||||
it('should verify capabilities sent', function()
|
it('should verify capabilities sent', function()
|
||||||
local expected_callbacks = {
|
local expected_callbacks = {
|
||||||
{NIL, "shutdown", {}, 1};
|
{NIL, "shutdown", {}, 1};
|
||||||
|
Loading…
Reference in New Issue
Block a user