Skip to content
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

bug: vim.lsp.util.make_position_params() requires position/offset encoding on Nighly #606

Open
4 tasks done
lithammer opened this issue Nov 28, 2024 · 6 comments
Open
4 tasks done
Labels
bug Something isn't working

Comments

@lithammer
Copy link

Did you check docs and existing issues?

  • I have read all the trouble.nvim docs
  • I have updated the plugin to the latest version before submitting this issue
  • I have searched the existing issues of trouble.nvim
  • I have searched the existing issues of plugins related to this issue

Neovim version (nvim -v)

v0.11.0-dev-1247+g5897994cb7

Operating system/version

Debian Trixie

Describe the bug

On nightly, vim.lsp.util.make_position_params() requires a second argument position_encoding. Otherwise it generates this warning message:

position_encoding param is required in vim.lsp.util.make_position_params. Defaulting to position encoding of the first client.

local params = opts.params or vim.lsp.util.make_position_params(win)

Upstream change: neovim/neovim#31249

I guess client and/or client.offset_encoding has to be propagated.

Steps To Reproduce

  1. Open some buffer that attaches a language server.
  2. Run :Trouble lsp_implementations on some identifier.

Expected Behavior

Expect no warning.

Repro

No response

Copy link
Contributor

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 7 days.

@github-actions github-actions bot added the stale label Dec 29, 2024
@tan-wei
Copy link

tan-wei commented Dec 30, 2024

Is there any workaround for this message?

@github-actions github-actions bot removed the stale label Dec 30, 2024
@tan-wei
Copy link

tan-wei commented Jan 8, 2025

Seems since this PR neovim/neovim#31249, the function will cause warning.

@kenielf
Copy link

kenielf commented Jan 8, 2025

As for the first usage in line 175, I believe that you can probably just use the first client's offset encoding with something like:

local clients = vim.lsp.get_clients({ bufnr = buf })
local params = opts.params or vim.lsp.util.make_position_params(win, clients[1].offset_encoding or 'utf-16')

However, there is a second instance of vim.lsp.util.make_position_params all the way down in function M.call_hierarchy(cb, incoming), line 238, and that one I'm not really sure how to proceed, but I'm also not used to using the lsp interface all that well.

EDIT

I have tested this with a few of my own projects, and this is at the very least a workaround for the warning message on open. My use case does not require getting the full hierarchy and therefore it does not trigger the issue in regards to the second usage of lsp.util.make_position_params.

@tan-wei
Copy link

tan-wei commented Jan 8, 2025

@kenielf So I think we should wait for trouble.nvim changing the use of vim.lsp.util.make_position_params to fix these warnings? Seems the the upstream needs the parameter offset_encording.

@kenielf
Copy link

kenielf commented Jan 8, 2025

@tan-wei I applied the changes manually by modifying the ~/.local/share/nvim/lazy/trouble.nvim/lua/trouble/sources/lsp.lua, but yes, it'd be best to wait for a proper implementation in case using the first client isn't adequate.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants