Skip to content

Commit

Permalink
fix: offset_encoding is required now in make_position_params
Browse files Browse the repository at this point in the history
Adapt to the upstream change
neovim/neovim@629483e
  • Loading branch information
rockyzhang24 committed Nov 24, 2024
1 parent 85922dd commit db1c752
Showing 1 changed file with 28 additions and 14 deletions.
42 changes: 28 additions & 14 deletions lua/telescope/builtin/__lsp.lua
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,10 @@ local function pick_call_hierarchy_item(call_hierarchy_items)
end

local function calls(opts, direction)
local params = vim.lsp.util.make_position_params()
vim.lsp.buf_request(opts.bufnr, "textDocument/prepareCallHierarchy", params, function(err, result)
local win = vim.api.nvim_get_current_win()
vim.lsp.buf_request(opts.bufnr, "textDocument/prepareCallHierarchy", function(client)
return vim.lsp.util.make_position_params(win, client.offset_encoding)
end, function(err, result)
if err then
vim.api.nvim_err_writeln("Error when preparing call hierarchy: " .. err)
return
Expand Down Expand Up @@ -171,7 +173,7 @@ end
---@param action telescope.lsp.list_or_jump_action
---@param title string prompt title
---@param funname string: name of the calling function
---@param params lsp.TextDocumentPositionParams
---@param params lsp.TextDocumentPositionParams|(fun(client: vim.lsp.Client, bufnr: integer): table?)
---@param opts table
local function list_or_jump(action, title, funname, params, opts)
opts.reuse_win = vim.F.if_nil(opts.reuse_win, false)
Expand Down Expand Up @@ -264,30 +266,41 @@ end
lsp.references = function(opts)
opts.include_current_line = vim.F.if_nil(opts.include_current_line, false)
---@class lsp.TextDocumentPositionParams
local params = vim.lsp.util.make_position_params(opts.winnr)
params.context = { includeDeclaration = vim.F.if_nil(opts.include_declaration, true) }
return list_or_jump("textDocument/references", "LSP References", "builtin.lsp_references", params, opts)
return list_or_jump("textDocument/references", "LSP References", "builtin.lsp_references", function(client)
local params = vim.lsp.util.make_position_params(opts.winnr, client.offset_encoding)
params.context = { includeDeclaration = vim.F.if_nil(opts.include_declaration, true) }
return params
end, opts)
end

lsp.definitions = function(opts)
local params = vim.lsp.util.make_position_params(opts.winnr)
return list_or_jump("textDocument/definition", "LSP Definitions", "builtin.lsp_definitions", params, opts)
return list_or_jump("textDocument/definition", "LSP Definitions", "builtin.lsp_definitions", function(client)
return vim.lsp.util.make_position_params(opts.winnr, client.offset_encoding)
end, opts)
end

lsp.type_definitions = function(opts)
local params = vim.lsp.util.make_position_params(opts.winnr)
return list_or_jump(
"textDocument/typeDefinition",
"LSP Type Definitions",
"builtin.lsp_type_definitions",
params,
function(client)
return vim.lsp.util.make_position_params(opts.winnr, client.offset_encoding)
end,
opts
)
end

lsp.implementations = function(opts)
local params = vim.lsp.util.make_position_params(opts.winnr)
return list_or_jump("textDocument/implementation", "LSP Implementations", "builtin.lsp_implementations", params, opts)
return list_or_jump(
"textDocument/implementation",
"LSP Implementations",
"builtin.lsp_implementations",
function(client)
return vim.lsp.util.make_position_params(opts.winnr, client.offset_encoding)
end,
opts
)
end

local symbols_sorter = function(symbols)
Expand Down Expand Up @@ -323,8 +336,9 @@ local symbols_sorter = function(symbols)
end

lsp.document_symbols = function(opts)
local params = vim.lsp.util.make_position_params(opts.winnr)
vim.lsp.buf_request(opts.bufnr, "textDocument/documentSymbol", params, function(err, result, _, _)
vim.lsp.buf_request(opts.bufnr, "textDocument/documentSymbol", function(client)
return vim.lsp.util.make_position_params(opts.winnr, client.offset_encoding)
end, function(err, result, _, _)
if err then
vim.api.nvim_err_writeln("Error when finding document symbols: " .. err.message)
return
Expand Down

0 comments on commit db1c752

Please sign in to comment.