mirror of
https://github.com/neovim/neovim.git
synced 2025-09-08 04:18:18 +00:00
feat(lsp): improve signature help display #35190
- Add delimiter between function signature and documentation, matching hover formatting
- Show title only if there are multiple clients or multiple signatures
- Avoid duplicating the title inside the window if it's already shown in the border
(cherry picked from commit d26db4bfbf
)
This commit is contained in:

committed by
github-actions[bot]
![github-actions[bot]](/assets/img/avatar_default.png)
parent
8f2d6f7ce2
commit
5551da79c1
@@ -386,15 +386,19 @@ function M.signature_help(config)
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
local sfx = total > 1
|
-- Show title only if there are multiple clients or multiple signatures.
|
||||||
and string.format(' (%d/%d)%s', idx, total, can_cycle and ' (<C-s> to cycle)' or '')
|
if total > 1 then
|
||||||
or ''
|
local sfx = total > 1
|
||||||
config.title = config.title or string.format('Signature Help: %s%s', client.name, sfx)
|
and string.format(' (%d/%d)%s', idx, total, can_cycle and ' (<C-s> to cycle)' or '')
|
||||||
if not config.border then
|
or ''
|
||||||
table.insert(lines, 1, '# ' .. config.title)
|
config.title = config.title or string.format('Signature Help: %s%s', client.name, sfx)
|
||||||
if hl then
|
-- If no border is set, render title inside the window.
|
||||||
hl[1] = hl[1] + 1
|
if not (config.border or vim.o.winborder ~= '') then
|
||||||
hl[3] = hl[3] + 1
|
table.insert(lines, 1, '# ' .. config.title)
|
||||||
|
if hl then
|
||||||
|
hl[1] = hl[1] + 1
|
||||||
|
hl[3] = hl[3] + 1
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@@ -745,6 +745,10 @@ function M.convert_signature_help_to_markdown_lines(signature_help, ft, triggers
|
|||||||
if type(doc) == 'string' then
|
if type(doc) == 'string' then
|
||||||
signature.documentation = { kind = 'plaintext', value = doc }
|
signature.documentation = { kind = 'plaintext', value = doc }
|
||||||
end
|
end
|
||||||
|
-- Add delimiter if there is documentation to display
|
||||||
|
if signature.documentation.value ~= '' then
|
||||||
|
contents[#contents + 1] = '---'
|
||||||
|
end
|
||||||
M.convert_input_to_markdown_lines(signature.documentation, contents)
|
M.convert_input_to_markdown_lines(signature.documentation, contents)
|
||||||
end
|
end
|
||||||
if signature.parameters and #signature.parameters > 0 then
|
if signature.parameters and #signature.parameters > 0 then
|
||||||
|
@@ -3657,7 +3657,7 @@ describe('LSP', function()
|
|||||||
}
|
}
|
||||||
return vim.lsp.util.convert_signature_help_to_markdown_lines(signature_help, 'cs', { ',' })
|
return vim.lsp.util.convert_signature_help_to_markdown_lines(signature_help, 'cs', { ',' })
|
||||||
end)
|
end)
|
||||||
local expected = { '```cs', 'TestEntity.TestEntity()', '```', 'some doc' }
|
local expected = { '```cs', 'TestEntity.TestEntity()', '```', '---', 'some doc' }
|
||||||
eq(expected, result)
|
eq(expected, result)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user