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

Closed
4 tasks done
lithammer opened this issue Nov 28, 2024 · 10 comments · Fixed by #619
Closed
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.

@GitMurf
Copy link

GitMurf commented Jan 27, 2025

Does anyone know a workaround without having to fork Trouble.nvim or directly patch the data directory install? I don't want to have to manage a fork / workaround each time Trouble.nvim has an update. Thanks!

@mikelemo
Copy link

I'm also getting this warn message just clones todays nvim version...

2025-02-12T19:14:37 Warning  WARN position_encoding param is required in vim.lsp.util.make_position_params. Defaulting to position encoding of the first client.

@kenielf
Copy link

kenielf commented Feb 12, 2025

I'm also getting this warn message just clones todays nvim version...

2025-02-12T19:14:37 Warning  WARN position_encoding param is required in vim.lsp.util.make_position_params. Defaulting to position encoding of the first client.

Folke has a patch waiting merge that should be merged sometime soon, you can take a look at it here.

I have checked out this branch and on Neovim v0.11.0-dev-1484+g9b7905df16 that warning has disappeared.

folke pushed a commit that referenced this issue Feb 12, 2025
🤖 I have created a release *beep* *boop*
---


##
[3.7.1](v3.7.0...v3.7.1)
(2025-01-28)


### Bug Fixes

* **lsp:** make_position_params with offset encoding. Closes
[#606](#606)
([6f380b8](6f380b8))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
@mikelemo
Copy link

I'm also getting this warn message just clones todays nvim version...

2025-02-12T19:14:37 Warning  WARN position_encoding param is required in vim.lsp.util.make_position_params. Defaulting to position encoding of the first client.

Folke has a patch waiting merge that should be merged sometime soon, you can take a look at it here.

I have checked out this branch and on Neovim v0.11.0-dev-1484+g9b7905df16 that warning has disappeared.

Well I justupdated trouble now and this messages:

2025-02-12T23:07:56 Warning  WARN position_encoding param is required in vim.lsp.util.make_position_params. Defaulting to position encoding of the first client.
2025-02-12T23:07:56 Warning  WARN position_encoding param is required in vim.lsp.util.make_range_params. Defaulting to position encoding of the first client.

still appear. Probably comes from nvim it's self as I added enabled = false, in the trouble lua conf file

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

Successfully merging a pull request may close this issue.

5 participants