aboutsummaryrefslogtreecommitdiff
path: root/test/functional/plugin/lsp_spec.lua
diff options
context:
space:
mode:
authorMathias Fußenegger <mfussenegger@users.noreply.github.com>2021-09-28 23:04:01 +0200
committerGitHub <noreply@github.com>2021-09-28 14:04:01 -0700
commitec4731d982031e363a59efd4566fc72234bb43c8 (patch)
treec0f6dabcdd7c0ae86da4fd74da44dd80abe2dba3 /test/functional/plugin/lsp_spec.lua
parent3507d58dfb87923aa4031cbefaf1ef576a45dcaf (diff)
downloadrneovim-ec4731d982031e363a59efd4566fc72234bb43c8.tar.gz
rneovim-ec4731d982031e363a59efd4566fc72234bb43c8.tar.bz2
rneovim-ec4731d982031e363a59efd4566fc72234bb43c8.zip
feat(lsp): add codeAction/resolve support (#15818)
Closes https://github.com/neovim/neovim/issues/15339 and https://github.com/neovim/neovim/issues/15828
Diffstat (limited to 'test/functional/plugin/lsp_spec.lua')
-rw-r--r--test/functional/plugin/lsp_spec.lua55
1 files changed, 36 insertions, 19 deletions
diff --git a/test/functional/plugin/lsp_spec.lua b/test/functional/plugin/lsp_spec.lua
index 27f2d2536f..572573a3a6 100644
--- a/test/functional/plugin/lsp_spec.lua
+++ b/test/functional/plugin/lsp_spec.lua
@@ -2376,26 +2376,43 @@ describe('LSP', function()
describe('vim.lsp.buf.code_action', function()
it('Calls client side command if available', function()
- eq(1, exec_lua [[
- local dummy_calls = 0
- vim.lsp.commands.dummy = function()
- dummy_calls = dummy_calls + 1
- end
- local actions = {
- {
- title = 'Dummy command',
- command = 'dummy',
- },
- }
- -- inputlist would require input and block the test;
- vim.fn.inputlist = function()
- return 1
+ local client
+ local expected_handlers = {
+ {NIL, {}, {method="shutdown", client_id=1}};
+ {NIL, {}, {method="start", client_id=1}};
+ }
+ test_rpc_server {
+ test_name = 'code_action_with_resolve',
+ on_init = function(client_)
+ client = client_
+ end,
+ on_setup = function()
+ end,
+ on_exit = function(code, signal)
+ eq(0, code, "exit code", fake_lsp_logfile)
+ eq(0, signal, "exit signal", fake_lsp_logfile)
+ end,
+ on_handler = function(err, result, ctx)
+ eq(table.remove(expected_handlers), {err, result, ctx})
+ if ctx.method == 'start' then
+ exec_lua([[
+ vim.lsp.commands['dummy1'] = function(cmd)
+ vim.lsp.commands['dummy2'] = function()
+ end
+ end
+ local bufnr = vim.api.nvim_get_current_buf()
+ vim.lsp.buf_attach_client(bufnr, TEST_RPC_CLIENT_ID)
+ vim.fn.inputlist = function()
+ return 1
+ end
+ vim.lsp.buf.code_action()
+ ]])
+ elseif ctx.method == 'shutdown' then
+ eq('function', exec_lua[[return type(vim.lsp.commands['dummy2'])]])
+ client.stop()
+ end
end
- local params = {}
- local handler = require'vim.lsp.handlers'['textDocument/codeAction']
- handler(nil, actions, { method = 'textDocument/codeAction', params = params }, nil)
- return dummy_calls
- ]])
+ }
end)
end)
describe('vim.lsp.commands', function()