Skip to content

Commit

Permalink
signatures: show all overloads (#774)
Browse files Browse the repository at this point in the history
* signatures: show all overloads

* dont show duplicates

* Update lua/blink/cmp/signature/window.lua

Co-authored-by: Liam Dyer <liamcdyer@gmail.com>

* simplify

---------

Co-authored-by: Liam Dyer <liamcdyer@gmail.com>
  • Loading branch information
hfn92 and Saghen authored Dec 29, 2024
1 parent d9513ee commit 8ffddd9
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
10 changes: 8 additions & 2 deletions lua/blink/cmp/lib/window/docs.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ local docs = {}

--- @class blink.cmp.RenderDetailAndDocumentationOpts
--- @field bufnr number
--- @field detail? string
--- @field detail? string|string[]
--- @field documentation? lsp.MarkupContent | string
--- @field max_width number
--- @field use_treesitter_highlighting boolean?
Expand All @@ -19,7 +19,13 @@ local docs = {}
--- @param opts blink.cmp.RenderDetailAndDocumentationOpts
function docs.render_detail_and_documentation(opts)
local detail_lines = {}
if opts.detail and opts.detail ~= '' then detail_lines = docs.split_lines(opts.detail) end

local details = type(opts.detail) == 'string' and { opts.detail } or opts.detail
details = require('blink.cmp.lib.utils').deduplicate(details)

for _, v in ipairs(details) do
vim.list_extend(detail_lines, docs.split_lines(v))
end

local doc_lines = {}
if opts.documentation ~= nil then
Expand Down
4 changes: 3 additions & 1 deletion lua/blink/cmp/signature/window.lua
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,12 @@ function signature.open_with_signature_help(context, signature_help)

local active_signature = signature_help.signatures[(signature_help.activeSignature or 0) + 1]

local labels = vim.tbl_map(function(signature) return signature.label end, signature_help.signatures)

if signature.shown_signature ~= active_signature then
require('blink.cmp.lib.window.docs').render_detail_and_documentation({
bufnr = signature.win:get_buf(),
detail = active_signature.label,
detail = labels,
documentation = active_signature.documentation,
max_width = config.max_width,
use_treesitter_highlighting = config.treesitter_highlighting,
Expand Down

0 comments on commit 8ffddd9

Please sign in to comment.