-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use handlers instead of callbacks #399
Conversation
I suspect you have to fix the obsolete |
You're right! I missed those. Gonna change them and commit. |
Changed the rest of them. |
lua/nvim_lsp/configs.lua
Outdated
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, "Update to Nvim HEAD. This is an incompatible interface.") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should assert(not lsp.callbacks, ...
with an informative message and a help section to look at .
Once we do that, we can merge. ("Update to Nvim HEAD" doesn't tell people what / how they need to fix anything)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did the most recent commit address this well?
lua/nvim_lsp/configs.lua
Outdated
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(not lsp.callbacks, "lsp.callbacks has been deprecated. See here for more: https://github.com/nvim-lua/diagnostic-nvim/issues/73") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this should be moved out of the inner function. This should be on line 36 I think (where we add the handlers).
We don't need to check this every time.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, it should reference this PR: neovim/neovim#12655 Which is the one with the most information and most context.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I moved the line out, although now every time I initiate an LSP it causes an error. The repo doesn't have any more mentions of callbacks, so is this working right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe what we should do is check this each time a new config is registered (to make sure no deprecated settings are being added).
I'll look into that more tonight, since it looks like callbacks
is getting populated still somehow.
lua/nvim_lsp/configs.lua
Outdated
local function add_callbacks(config) | ||
config.callbacks["window/logMessage"] = function(err, method, params, client_id) | ||
local function add_handlers(config) | ||
assert(not lsp.callbacks, "lsp.callbacks has been deprecated. See here for more: https://github.com/neovim/neovim/pull/12655") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, we should also chdck that config.callbacks is nil.
Sorry to be so pedantic about this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's no problem! We want to make sure it's right before it goes someplace people use it everyday.
I'll add it in a little bit and push, just leaving this here to say I've seen it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool, ping me on Monday if I haven't looked again. Idk what my schedule is tomorrow.
lua/nvim_lsp/configs.lua
Outdated
@@ -34,7 +34,7 @@ function configs.__newindex(t, config_name, config_def) | |||
-- which is why this is a function, so that it can refer to the settings | |||
-- object on the server. | |||
local function add_handlers(config) | |||
assert(not lsp.callbacks, "lsp.callbacks has been deprecated. See here for more: https://github.com/neovim/neovim/pull/12655") | |||
assert(not config.callbacks, "lsp.callbacks has been deprecated. See here for more: https://github.com/neovim/neovim/pull/12655") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tested JDT LS using the provided config on master and the proposed config in this pull. Using this assert
it fails on master
and works for patch-1
😌
As for lsp.callbacks
, I tried the following:
nvim -u NORC -c 'lua assert(not vim.lsp.callbacks, "Failed!")'
and it failed. So I replaced the lsp
reference with config
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah, yeah, that's what I mean to say. I wanted you to assert about the config (which is the thing the user can control).
lua/nvim_lsp/configs.lua
Outdated
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 and lsp.handlers[method], "Update to Nvim HEAD. This is an incompatible interface.") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think is needed anymore.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right. If we're aiming to assert on addition, we don't need to ship back a function which makes assertions about that again.
The recent changes in neovim head cause loading this file to create an error. These changes have resolved that on my machine
No problem. Good time to get that one through |
Co-authored-by: Hirokazu Hata <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tjdevries Is there anything else?
LGTM I think |
@Iron-E Thank you for your work :) |
Happy we could do it! |
The recent changes in Neovim head cause loading this file to create an error. These changes have resolved that on my machine.
Note: neovim/neovim#12655