Skip to content

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

Merged
merged 2 commits into from
Jul 4, 2025

Conversation

MariaSolOs
Copy link
Member

Minor fixes:

  • Hover doesn't need to check if contents is empty since we check if the results are empty here.
  • Let's use lsp.__unsupported_method in hierarchy for consistency.
  • Removing an extra (?) call to get_clients from the code actions handler.

@MariaSolOs MariaSolOs requested review from lewis6991 and ribru17 July 4, 2025 21:19
@github-actions github-actions bot added the lsp label Jul 4, 2025
@@ -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)
Copy link
Member

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 ?

Copy link
Member Author

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.

Copy link
Member

@lewis6991 lewis6991 Jul 4, 2025

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.

Copy link
Member

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.

Copy link
Member Author

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).

Copy link
Member

@justinmk justinmk left a 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.

@MariaSolOs MariaSolOs merged commit d9465e9 into neovim:master Jul 4, 2025
34 of 35 checks passed
@MariaSolOs MariaSolOs deleted the extra-notify branch July 4, 2025 21:46
@github-actions github-actions bot removed request for lewis6991 and ribru17 July 4, 2025 21:52
phanen added a commit to phanen/lua-language-server that referenced this pull request Jul 17, 2025
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.
phanen added a commit to phanen/lua-language-server that referenced this pull request Jul 17, 2025
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.
phanen added a commit to phanen/lua-language-server that referenced this pull request Jul 17, 2025
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants