Skip to content

Commit

Permalink
feat(lsp): Support jump_to_location for incoming/outgoing calls
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewbraxton authored and ibhagwan committed Nov 20, 2024
1 parent def1d77 commit 63e4978
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion lua/fzf-lua/providers/lsp.lua
Original file line number Diff line number Diff line change
Expand Up @@ -178,17 +178,23 @@ local function location_handler(opts, cb, _, result, ctx, _)
end
end

local function call_hierarchy_handler(opts, cb, _, result, _, _)
local function call_hierarchy_handler(opts, cb, _, result, ctx, _)
local encoding = vim.lsp.get_client_by_id(ctx.client_id).offset_encoding
for _, call_hierarchy_call in pairs(result) do
--- "from" for incoming calls and "to" for outgoing calls
local call_hierarchy_item = call_hierarchy_call.from or call_hierarchy_call.to
for _, range in pairs(call_hierarchy_call.fromRanges) do
local location = {
uri = call_hierarchy_item.uri,
range = range,
filename = assert(vim.uri_to_fname(call_hierarchy_item.uri)),
text = call_hierarchy_item.name,
lnum = range.start.line + 1,
col = range.start.character + 1,
}
if opts.jump_to_single_result and #call_hierarchy_call.fromRanges == 1 then
jump_to_location(opts, location, encoding)
end
local entry = make_entry.lcol(location, opts)
entry = make_entry.file(entry, opts)
if entry then cb(entry) end
Expand Down

0 comments on commit 63e4978

Please sign in to comment.