diff options
| author | Christian Clason <c.clason@uni-graz.at> | 2021-12-02 20:55:07 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-12-02 20:55:07 +0100 |
| commit | 4edd1a7a51a9d7298706501066ead7e2c2703285 (patch) | |
| tree | f411d78b287a21e9779ff64bf9a0bee4033c03c8 | |
| parent | fix(eslint): openDoc function on Linux (#1529) (diff) | |
| download | nvim-lspconfig-4edd1a7a51a9d7298706501066ead7e2c2703285.tar nvim-lspconfig-4edd1a7a51a9d7298706501066ead7e2c2703285.tar.gz nvim-lspconfig-4edd1a7a51a9d7298706501066ead7e2c2703285.tar.bz2 nvim-lspconfig-4edd1a7a51a9d7298706501066ead7e2c2703285.tar.lz nvim-lspconfig-4edd1a7a51a9d7298706501066ead7e2c2703285.tar.xz nvim-lspconfig-4edd1a7a51a9d7298706501066ead7e2c2703285.tar.zst nvim-lspconfig-4edd1a7a51a9d7298706501066ead7e2c2703285.zip | |
chore!: remove compat shims for pre-0.5.1 handlers (#1530)
| -rw-r--r-- | lua/lspconfig/server_configurations/clangd.lua | 25 | ||||
| -rw-r--r-- | lua/lspconfig/server_configurations/denols.lua | 12 | ||||
| -rw-r--r-- | lua/lspconfig/server_configurations/jdtls.lua | 23 | ||||
| -rw-r--r-- | lua/lspconfig/server_configurations/texlab.lua | 34 | ||||
| -rw-r--r-- | lua/lspconfig/server_configurations/zk.lua | 27 | ||||
| -rw-r--r-- | lua/lspconfig/util.lua | 21 |
6 files changed, 43 insertions, 99 deletions
diff --git a/lua/lspconfig/server_configurations/clangd.lua b/lua/lspconfig/server_configurations/clangd.lua index cda6ef43..51c846e1 100644 --- a/lua/lspconfig/server_configurations/clangd.lua +++ b/lua/lspconfig/server_configurations/clangd.lua @@ -6,21 +6,16 @@ local function switch_source_header(bufnr) local clangd_client = util.get_active_client_by_name(bufnr, 'clangd') local params = { uri = vim.uri_from_bufnr(bufnr) } if clangd_client then - clangd_client.request( - 'textDocument/switchSourceHeader', - params, - util.compat_handler(function(err, result) - if err then - error(tostring(err)) - end - if not result then - print 'Corresponding file cannot be determined' - return - end - vim.api.nvim_command('edit ' .. vim.uri_to_fname(result)) - end), - bufnr - ) + clangd_client.request('textDocument/switchSourceHeader', params, function(err, result) + if err then + error(tostring(err)) + end + if not result then + print 'Corresponding file cannot be determined' + return + end + vim.api.nvim_command('edit ' .. vim.uri_to_fname(result)) + end, bufnr) else print 'method textDocument/switchSourceHeader is not supported by any servers active on the current buffer' end diff --git a/lua/lspconfig/server_configurations/denols.lua b/lua/lspconfig/server_configurations/denols.lua index 7bd3c928..0011df8f 100644 --- a/lua/lspconfig/server_configurations/denols.lua +++ b/lua/lspconfig/server_configurations/denols.lua @@ -76,13 +76,7 @@ local function denols_handler(err, result, ctx) end end - -- TODO remove this conditional when the handler is no longer being wrapped - -- with util.compat_handler (just use the else clause) - if vim.fn.has 'nvim-0.5.1' then - lsp.handlers[ctx.method](err, result, ctx) - else - lsp.handlers[ctx.method](err, ctx.method, result) - end + lsp.handlers[ctx.method](err, result, ctx) end local function denols_definition() @@ -120,8 +114,8 @@ return { unstable = false, }, handlers = { - ['textDocument/definition'] = util.compat_handler(denols_handler), - ['textDocument/references'] = util.compat_handler(denols_handler), + ['textDocument/definition'] = denols_handler, + ['textDocument/references'] = denols_handler, }, }, commands = { diff --git a/lua/lspconfig/server_configurations/jdtls.lua b/lua/lspconfig/server_configurations/jdtls.lua index 40d1341f..7f3fc3e2 100644 --- a/lua/lspconfig/server_configurations/jdtls.lua +++ b/lua/lspconfig/server_configurations/jdtls.lua @@ -50,15 +50,6 @@ local function fix_zero_version(workspace_edit) return workspace_edit end --- Compatibility shim added for breaking changes to the lsp handler signature in nvim-0.5.1 -local function remap_arguments(err, result, ctx) - if vim.fn.has 'nvim-0.5.1' == 1 then - handlers[ctx.method](err, result, ctx) - else - handlers[ctx.method](err, ctx.method, result) - end -end - local function on_textdocument_codeaction(err, actions, ctx) for _, action in ipairs(actions) do -- TODO: (steelsojka) Handle more than one edit? @@ -69,15 +60,15 @@ local function on_textdocument_codeaction(err, actions, ctx) end end - remap_arguments(err, actions, ctx) + handlers[ctx.method](err, actions, ctx) end local function on_textdocument_rename(err, workspace_edit, ctx) - remap_arguments(err, fix_zero_version(workspace_edit), ctx) + handlers[ctx.method](err, fix_zero_version(workspace_edit), ctx) end local function on_workspace_applyedit(err, workspace_edit, ctx) - remap_arguments(err, fix_zero_version(workspace_edit), ctx) + handlers[ctx.method](err, fix_zero_version(workspace_edit), ctx) end -- Non-standard notification that can be used to display progress @@ -141,10 +132,10 @@ return { handlers = { -- Due to an invalid protocol implementation in the jdtls we have to conform these to be spec compliant. -- https://github.com/eclipse/eclipse.jdt.ls/issues/376 - ['textDocument/codeAction'] = util.compat_handler(on_textdocument_codeaction), - ['textDocument/rename'] = util.compat_handler(on_textdocument_rename), - ['workspace/applyEdit'] = util.compat_handler(on_workspace_applyedit), - ['language/status'] = util.compat_handler(vim.schedule_wrap(on_language_status)), + ['textDocument/codeAction'] = on_textdocument_codeaction, + ['textDocument/rename'] = on_textdocument_rename, + ['workspace/applyEdit'] = on_workspace_applyedit, + ['language/status'] = vim.schedule_wrap(on_language_status), }, }, docs = { diff --git a/lua/lspconfig/server_configurations/texlab.lua b/lua/lspconfig/server_configurations/texlab.lua index 1e43976a..88bfa20c 100644 --- a/lua/lspconfig/server_configurations/texlab.lua +++ b/lua/lspconfig/server_configurations/texlab.lua @@ -21,17 +21,12 @@ local function buf_build(bufnr) textDocument = { uri = vim.uri_from_bufnr(bufnr) }, } if texlab_client then - texlab_client.request( - 'textDocument/build', - params, - util.compat_handler(function(err, result) - if err then - error(tostring(err)) - end - print('Build ' .. texlab_build_status[result.status]) - end), - bufnr - ) + texlab_client.request('textDocument/build', params, function(err, result) + if err then + error(tostring(err)) + end + print('Build ' .. texlab_build_status[result.status]) + end, bufnr) else print 'method textDocument/build is not supported by any servers active on the current buffer' end @@ -45,17 +40,12 @@ local function buf_search(bufnr) position = { line = vim.fn.line '.' - 1, character = vim.fn.col '.' }, } if texlab_client then - texlab_client.request( - 'textDocument/forwardSearch', - params, - util.compat_handler(function(err, result) - if err then - error(tostring(err)) - end - print('Search ' .. texlab_forward_status[result.status]) - end), - bufnr - ) + texlab_client.request('textDocument/forwardSearch', params, function(err, result) + if err then + error(tostring(err)) + end + print('Search ' .. texlab_forward_status[result.status]) + end, bufnr) else print 'method textDocument/forwardSearch is not supported by any servers active on the current buffer' end diff --git a/lua/lspconfig/server_configurations/zk.lua b/lua/lspconfig/server_configurations/zk.lua index d217471d..c2890451 100644 --- a/lua/lspconfig/server_configurations/zk.lua +++ b/lua/lspconfig/server_configurations/zk.lua @@ -18,23 +18,18 @@ return { }, ZkNew = { function(...) - vim.lsp.buf_request( - 0, - 'workspace/executeCommand', - { - command = 'zk.new', - arguments = { - vim.api.nvim_buf_get_name(0), - ..., - }, + vim.lsp.buf_request(0, 'workspace/executeCommand', { + command = 'zk.new', + arguments = { + vim.api.nvim_buf_get_name(0), + ..., }, - util.compat_handler(function(_, result, _, _) - if not (result and result.path) then - return - end - vim.cmd('edit ' .. result.path) - end) - ) + }, function(_, result, _, _) + if not (result and result.path) then + return + end + vim.cmd('edit ' .. result.path) + end) end, description = 'ZkNew', diff --git a/lua/lspconfig/util.lua b/lua/lspconfig/util.lua index c7f4eb53..477a41f5 100644 --- a/lua/lspconfig/util.lua +++ b/lua/lspconfig/util.lua @@ -19,27 +19,6 @@ M.default_config = { -- global on_setup hook M.on_setup = nil --- add compatibility shim for breaking signature change --- from https://github.com/mfussenegger/nvim-lsp-compl/ --- TODO: remove after Neovim release -function M.compat_handler(handler) - return function(...) - local config_or_client_id = select(4, ...) - local is_new = type(config_or_client_id) ~= 'number' - if is_new then - return handler(...) - else - local err = select(1, ...) - local method = select(2, ...) - local result = select(3, ...) - local client_id = select(4, ...) - local bufnr = select(5, ...) - local config = select(6, ...) - return handler(err, result, { method = method, client_id = client_id, bufnr = bufnr }, config) - end - end -end - function M.validate_bufnr(bufnr) validate { bufnr = { bufnr, 'n' }, |
