diff options
author | Lewis Russell <lewis6991@gmail.com> | 2024-10-24 12:11:27 +0100 |
---|---|---|
committer | Lewis Russell <me@lewisr.dev> | 2024-10-24 15:37:34 +0100 |
commit | 7a7747f1e4d96aab53ff9c52d0c3492308c22c58 (patch) | |
tree | 9818d40a7d1df837d6d8567ed521a0f53ca22c42 /runtime/lua/vim/lsp/client.lua | |
parent | 39d79efa1e1e1e5c3476dee54cc2bc4abc725a8f (diff) | |
download | rneovim-7a7747f1e4d96aab53ff9c52d0c3492308c22c58.tar.gz rneovim-7a7747f1e4d96aab53ff9c52d0c3492308c22c58.tar.bz2 rneovim-7a7747f1e4d96aab53ff9c52d0c3492308c22c58.zip |
feat(lsp): deprecate execute_command with client:exec_cmd
Diffstat (limited to 'runtime/lua/vim/lsp/client.lua')
-rw-r--r-- | runtime/lua/vim/lsp/client.lua | 29 |
1 files changed, 13 insertions, 16 deletions
diff --git a/runtime/lua/vim/lsp/client.lua b/runtime/lua/vim/lsp/client.lua index d9d6b851d0..2718f40c96 100644 --- a/runtime/lua/vim/lsp/client.lua +++ b/runtime/lua/vim/lsp/client.lua @@ -859,10 +859,9 @@ end --- or via workspace/executeCommand (if supported by the server) --- --- @param command lsp.Command ---- @param context? {bufnr: integer} +--- @param context? {bufnr?: integer} --- @param handler? lsp.Handler only called if a server command ---- @param on_unsupported? function handler invoked when the command is not supported by the client. -function Client:_exec_cmd(command, context, handler, on_unsupported) +function Client:exec_cmd(command, context, handler) context = vim.deepcopy(context or {}, true) --[[@as lsp.HandlerContext]] context.bufnr = context.bufnr or api.nvim_get_current_buf() context.client_id = self.id @@ -875,25 +874,23 @@ function Client:_exec_cmd(command, context, handler, on_unsupported) local command_provider = self.server_capabilities.executeCommandProvider local commands = type(command_provider) == 'table' and command_provider.commands or {} + if not vim.list_contains(commands, cmdname) then - if on_unsupported then - on_unsupported() - else - vim.notify_once( - string.format( - 'Language server `%s` does not support command `%s`. This command may require a client extension.', - self.name, - cmdname - ), - vim.log.levels.WARN - ) - end + vim.notify_once( + string.format( + 'Language server `%s` does not support command `%s`. This command may require a client extension.', + self.name, + cmdname + ), + vim.log.levels.WARN + ) return end -- Not using command directly to exclude extra properties, -- see https://github.com/python-lsp/python-lsp-server/issues/146 + --- @type lsp.ExecuteCommandParams local params = { - command = command.command, + command = cmdname, arguments = command.arguments, } self.request(ms.workspace_executeCommand, params, handler, context.bufnr) |