-
-
Notifications
You must be signed in to change notification settings - Fork 6.2k
fix(lsp): consistent use of vim.notify
in lsp/buf.lua
#34789
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
Conversation
@@ -879,7 +872,7 @@ local hierarchy_methods = { | |||
local function hierarchy(method) | |||
local kind = hierarchy_methods[method] | |||
if not kind then | |||
error('unsupported method ' .. method) | |||
vim.notify(lsp._unsupported_method(method), vim.log.levels.WARN) |
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.
is this intentionally changing from error => warn level ?
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.
Yeah because I see no reason to error
here instead of logging/notifying as we do everywhere else.
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'm pretty sure this needs to remain an error as it's essentially an assertion on the input and can only trigger from incorrect internal usage. This is also missing a return
.
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.
If the callers of hierarchy
are passing string literals, we can probably just remove this check and rely on LuaLS to check 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.
Alright I’ll revert this soon (AFK rn).
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.
lgtm because improving consistency is helpful.
Though pretty soon the "niceness" of vim.notify
will be moot because of "ui2" (vim._extui
) which handles all messages in a nice way by default. So plugins no longer need to worry about errors being ugly, they can actually raise errors for actual error situations. And vim.notify
will be irrelevant.
Nvim show me an error(since: neovim/neovim#34789), when I hover an symbol whose definition cannot be found by luals ``` **/neovim/runtime/lua/vim/lsp/util.lua:1685: 'width' key must be a positive Integer ``` To reprodunce, hover on a with this file ```lua ---@type a ``` Haven't reproduced with other lsp but I think it's harmless to PR here.
Nvim show me an error(since: neovim/neovim#34789), when I hover an symbol whose definition cannot be found by luals ``` **/neovim/runtime/lua/vim/lsp/util.lua:1685: 'width' key must be a positive Integer ``` To reprodunce, hover on a with this file ```lua ---@type a ``` Haven't reproduced with other lsp but I think it's harmless to PR here.
Nvim show me an error(since: neovim/neovim#34789), when I hover an symbol whose definition cannot be found by luals ``` **/neovim/runtime/lua/vim/lsp/util.lua:1685: 'width' key must be a positive Integer ``` To reprodunce, hover on a with this file ```lua ---@type a ``` Haven't reproduced with other lsp but I think it's harmless to PR here.
Minor fixes:
contents
is empty since we check if the results are empty here.lsp.__unsupported_method
inhierarchy
for consistency.get_clients
from the code actions handler.