Skip to content

Commit

Permalink
fix(lsp): support mixed encoding for lsp clients (#1004)
Browse files Browse the repository at this point in the history
## Description

Fixes a warning notification for the first hover/signature help
notification on nightly now that `offset_encoding` is required for
`make_position_params`
  • Loading branch information
tris203 authored Nov 26, 2024
1 parent 16ddc56 commit c6f6fb1
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions lua/noice/lsp/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -46,19 +46,28 @@ function M.setup()
end
end

local function make_position_params()
if vim.fn.has("nvim-0.11") == 1 then
return function(client)
return vim.lsp.util.make_position_params(nil, client.offset_encoding)
end
else
---@diagnostic disable-next-line: missing-parameter
return vim.lsp.util.make_position_params()
end
end

function M.scroll(delta)
return require("noice.lsp.docs").scroll(delta)
end

function M.hover()
---@diagnostic disable-next-line: missing-parameter
local params = vim.lsp.util.make_position_params()
local params = make_position_params()
vim.lsp.buf_request(0, "textDocument/hover", params, require("noice.lsp.hover").on_hover)
end

function M.signature()
---@diagnostic disable-next-line: missing-parameter
local params = vim.lsp.util.make_position_params()
local params = make_position_params()
vim.lsp.buf_request(0, "textDocument/signatureHelp", params, require("noice.lsp.signature").on_signature)
end

Expand Down

0 comments on commit c6f6fb1

Please sign in to comment.