aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Lingelbach <m.j.lbach@gmail.com>2020-12-31 05:41:43 -0800
committerMichael Lingelbach <m.j.lbach@gmail.com>2021-01-01 01:40:46 -0800
commitf3bbc92476df1112deb34b9c7408cd594ee47a50 (patch)
treec5ecfa4100bb029b55ca3087c336249255799535
parente467d29390495ac05dd99942339640bfaacd4108 (diff)
downloadrneovim-f3bbc92476df1112deb34b9c7408cd594ee47a50.tar.gz
rneovim-f3bbc92476df1112deb34b9c7408cd594ee47a50.tar.bz2
rneovim-f3bbc92476df1112deb34b9c7408cd594ee47a50.zip
LSP: add test for workspace/configuration handler
-rw-r--r--test/functional/fixtures/fake-lsp-server.lua17
-rw-r--r--test/functional/plugin/lsp_spec.lua42
2 files changed, 59 insertions, 0 deletions
diff --git a/test/functional/fixtures/fake-lsp-server.lua b/test/functional/fixtures/fake-lsp-server.lua
index a30eb748d0..252db88b6b 100644
--- a/test/functional/fixtures/fake-lsp-server.lua
+++ b/test/functional/fixtures/fake-lsp-server.lua
@@ -109,6 +109,23 @@ function tests.basic_init()
}
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()
skeleton {
on_init = function(params)
diff --git a/test/functional/plugin/lsp_spec.lua b/test/functional/plugin/lsp_spec.lua
index f01d90bbeb..ec06cb0639 100644
--- a/test/functional/plugin/lsp_spec.lua
+++ b/test/functional/plugin/lsp_spec.lua
@@ -262,6 +262,48 @@ describe('LSP', function()
}
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()
local expected_callbacks = {
{NIL, "shutdown", {}, 1};