Skip to content

Commit

Permalink
Merge pull request #399 from Iron-E/patch-1
Browse files Browse the repository at this point in the history
  • Loading branch information
h-michael authored Nov 16, 2020
2 parents ba75ea5 + f572120 commit 35b0064
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 16 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2259,7 +2259,7 @@ require'lspconfig'.jdtls.setup{}
Commands:

Default Values:
callbacks = {
handlers = {
["textDocument/codeAction"] = <function 1>
}
filetypes = { "java" }
Expand Down
21 changes: 10 additions & 11 deletions lua/lspconfig/configs.lua
Original file line number Diff line number Diff line change
Expand Up @@ -33,26 +33,25 @@ function configs.__newindex(t, config_name, config_def)
-- The config here is the one which will be instantiated for the new server,
-- which is why this is a function, so that it can refer to the settings
-- object on the server.
local function add_callbacks(config)
config.callbacks["window/logMessage"] = function(err, method, params, client_id)
local function add_handlers(config)
assert(not config.callbacks, "lsp.callbacks has been obsoleted. See here for more: https://github.com/neovim/neovim/pull/12655")
config.handlers["window/logMessage"] = function(err, method, params, client_id)
if params and params.type <= config.log_level then
-- TODO(ashkan) remove this after things have settled.
assert(lsp.callbacks, "Update to Nvim HEAD. This is an incompatible interface.")
assert(lsp.callbacks["window/logMessage"], "Callback for window/logMessage notification is not defined")
lsp.callbacks["window/logMessage"](err, method, params, client_id)
assert(lsp.handlers["window/logMessage"], "Handler for window/logMessage notification is not defined")
lsp.handlers["window/logMessage"](err, method, params, client_id)
end
end

config.callbacks["window/showMessage"] = function(err, method, params, client_id)
config.handlers["window/showMessage"] = function(err, method, params, client_id)
if params and params.type <= config.message_level then
-- TODO(ashkan) remove this after things have settled.
assert(lsp.callbacks and lsp.callbacks[method], "Update to Nvim HEAD. This is an incompatible interface.")
assert(lsp.callbacks["window/showMessage"], "Callback for window/showMessage notification is not defined")
lsp.callbacks["window/showMessage"](err, method, params, client_id)
assert(lsp.handlers["window/showMessage"], "Handler for window/showMessage notification is not defined")
lsp.handlers["window/showMessage"](err, method, params, client_id)
end
end

config.callbacks["workspace/configuration"] = function(err, method, params, client_id)
config.handlers["workspace/configuration"] = function(err, method, params, client_id)
if err then error(tostring(err)) end
if not params.items then
return {}
Expand Down Expand Up @@ -124,7 +123,7 @@ function configs.__newindex(t, config_name, config_def)
}
})

add_callbacks(new_config)
add_handlers(new_config)
if config_def.on_new_config then
pcall(config_def.on_new_config, new_config, _root_dir)
end
Expand Down
6 changes: 3 additions & 3 deletions lua/lspconfig/jdtls.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
local configs = require 'lspconfig/configs'
local util = require 'lspconfig/util'
local callbacks = require 'vim.lsp.callbacks'
local handlers = require 'vim.lsp.handlers'
local path = util.path

local server_name = "jdtls"
Expand Down Expand Up @@ -101,7 +101,7 @@ configs[server_name] = {
jvm_args = {};
os_config = nil;
};
callbacks = {
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
Expand All @@ -113,7 +113,7 @@ configs[server_name] = {
end
end

callbacks['textDocument/codeAction'](a, b, actions)
handlers['textDocument/codeAction'](a, b, actions)
end
};
};
Expand Down
2 changes: 1 addition & 1 deletion lua/lspconfig/util.lua
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ M.default_config = {
message_level = lsp.protocol.MessageType.Warning;
settings = vim.empty_dict();
init_options = vim.empty_dict();
callbacks = {};
handlers = {};
}

function M.validate_bufnr(bufnr)
Expand Down

0 comments on commit 35b0064

Please sign in to comment.