diff options
author | Mathias Fussenegger <f.mathias@zignar.net> | 2021-03-12 10:19:21 +0100 |
---|---|---|
committer | Mathias Fussenegger <f.mathias@zignar.net> | 2021-09-20 22:26:00 +0200 |
commit | 6c03601e3adb4c3c4d47f148df8df20401b88677 (patch) | |
tree | 8557c570d06fde14eeb25c97a320c1a86f979b13 /test/functional | |
parent | 187579fe197ddd844bc0b0979e7f53c646f4235e (diff) | |
download | rneovim-6c03601e3adb4c3c4d47f148df8df20401b88677.tar.gz rneovim-6c03601e3adb4c3c4d47f148df8df20401b88677.tar.bz2 rneovim-6c03601e3adb4c3c4d47f148df8df20401b88677.zip |
feat(lsp): add a registry for client side code action commands
This builds on https://github.com/neovim/neovim/pull/14112 and closes
https://github.com/neovim/neovim/issues/12326
Diffstat (limited to 'test/functional')
-rw-r--r-- | test/functional/plugin/lsp_spec.lua | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/test/functional/plugin/lsp_spec.lua b/test/functional/plugin/lsp_spec.lua index 7319a02533..27f2d2536f 100644 --- a/test/functional/plugin/lsp_spec.lua +++ b/test/functional/plugin/lsp_spec.lua @@ -2374,4 +2374,42 @@ describe('LSP', function() end end) + 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 + 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() + it('Accepts only string keys', function() + matches( + '.*The key for commands in `vim.lsp.commands` must be a string', + pcall_err(exec_lua, 'vim.lsp.commands[1] = function() end') + ) + end) + it('Accepts only function values', function() + matches( + '.*Command added to `vim.lsp.commands` must be a function', + pcall_err(exec_lua, 'vim.lsp.commands.dummy = 10') + ) + end) + end) end) |