aboutsummaryrefslogtreecommitdiff
path: root/test/functional/plugin/lsp_spec.lua
diff options
context:
space:
mode:
authorMichael Lingelbach <m.j.lbach@gmail.com>2021-10-10 22:32:50 -0700
committerGitHub <noreply@github.com>2021-10-10 22:32:50 -0700
commitd288daac2bdc7e1e7da58656cd26a4311811120c (patch)
treeb257c86b5f93b10a67829ddeaab4f631e4c54d37 /test/functional/plugin/lsp_spec.lua
parentb3e0d6708eca3cd22695d364ba2aca7401cc0f8c (diff)
downloadrneovim-d288daac2bdc7e1e7da58656cd26a4311811120c.tar.gz
rneovim-d288daac2bdc7e1e7da58656cd26a4311811120c.tar.bz2
rneovim-d288daac2bdc7e1e7da58656cd26a4311811120c.zip
fix(lsp): do not invoke handlers for unsupported methods (#15926)
Closes https://github.com/neovim/neovim/issues/15174 Instead of invoking handlers with unsupported methods, pre-compute which clients support a given method and only notify the user if no clients support the given method.
Diffstat (limited to 'test/functional/plugin/lsp_spec.lua')
-rw-r--r--test/functional/plugin/lsp_spec.lua32
1 files changed, 6 insertions, 26 deletions
diff --git a/test/functional/plugin/lsp_spec.lua b/test/functional/plugin/lsp_spec.lua
index 026e6815dc..81ef8a9733 100644
--- a/test/functional/plugin/lsp_spec.lua
+++ b/test/functional/plugin/lsp_spec.lua
@@ -405,7 +405,7 @@ describe('LSP', function()
}
end)
- it('should call unsupported_method when trying to call an unsupported method', function()
+ it('should not call unsupported_method when trying to call an unsupported method', function()
local expected_handlers = {
{NIL, {}, {method="shutdown", client_id=1}};
}
@@ -415,24 +415,12 @@ describe('LSP', function()
exec_lua([=[
BUFFER = vim.api.nvim_get_current_buf()
lsp.buf_attach_client(BUFFER, TEST_RPC_CLIENT_ID)
- vim.lsp.handlers['textDocument/typeDefinition'] = function(err, result, ctx)
- local method = ctx.method
- vim.lsp._last_lsp_handler = { err = err; method = method }
- end
- vim.lsp._unsupported_method = function(method)
- vim.lsp._last_unsupported_method = method
- return 'fake-error'
- end
- vim.lsp.buf.type_definition()
+ vim.lsp.handlers['textDocument/typeDefinition'] = function() end
]=])
end;
on_init = function(client)
client.stop()
- local method = exec_lua("return vim.lsp._last_unsupported_method")
- eq("textDocument/typeDefinition", method)
- local lsp_cb_call = exec_lua("return vim.lsp._last_lsp_handler")
- eq("fake-error", lsp_cb_call.err)
- eq("textDocument/typeDefinition", lsp_cb_call.method)
+ exec_lua("vim.lsp.buf.type_definition()")
exec_lua [[
vim.api.nvim_command(BUFFER.."bwipeout")
]]
@@ -447,7 +435,7 @@ describe('LSP', function()
}
end)
- it('shouldn\'t call unsupported_method when no client and trying to call an unsupported method', function()
+ it('should not call unsupported_method when no client and trying to call an unsupported method', function()
local expected_handlers = {
{NIL, {}, {method="shutdown", client_id=1}};
}
@@ -455,20 +443,12 @@ describe('LSP', function()
test_name = "capabilities_for_client_supports_method";
on_setup = function()
exec_lua([=[
- vim.lsp.handlers['textDocument/typeDefinition'] = function(err, method)
- vim.lsp._last_lsp_handler = { err = err; method = method }
- end
- vim.lsp._unsupported_method = function(method)
- vim.lsp._last_unsupported_method = method
- return 'fake-error'
- end
- vim.lsp.buf.type_definition()
+ vim.lsp.handlers['textDocument/typeDefinition'] = function() end
]=])
end;
on_init = function(client)
client.stop()
- eq(NIL, exec_lua("return vim.lsp._last_unsupported_method"))
- eq(NIL, exec_lua("return vim.lsp._last_lsp_handler"))
+ exec_lua("vim.lsp.buf.type_definition()")
end;
on_exit = function(code, signal)
eq(0, code, "exit code", fake_lsp_logfile)