diff --git a/runtime/lua/vim/lsp/buf.lua b/runtime/lua/vim/lsp/buf.lua index 2f8c1c02ac..49e2ff0a8c 100644 --- a/runtime/lua/vim/lsp/buf.lua +++ b/runtime/lua/vim/lsp/buf.lua @@ -404,15 +404,19 @@ function M.signature_help(config) return end - local sfx = total > 1 - and string.format(' (%d/%d)%s', idx, total, can_cycle and ' ( to cycle)' or '') - or '' - config.title = config.title or string.format('Signature Help: %s%s', client.name, sfx) - if not config.border then - table.insert(lines, 1, '# ' .. config.title) - if hl then - hl[1] = hl[1] + 1 - hl[3] = hl[3] + 1 + -- Show title only if there are multiple clients or multiple signatures. + if total > 1 then + local sfx = total > 1 + and string.format(' (%d/%d)%s', idx, total, can_cycle and ' ( to cycle)' or '') + or '' + config.title = config.title or string.format('Signature Help: %s%s', client.name, sfx) + -- If no border is set, render title inside the window. + if not (config.border or vim.o.winborder ~= '') then + table.insert(lines, 1, '# ' .. config.title) + if hl then + hl[1] = hl[1] + 1 + hl[3] = hl[3] + 1 + end end end diff --git a/runtime/lua/vim/lsp/util.lua b/runtime/lua/vim/lsp/util.lua index 37b9655244..753dbad9c4 100644 --- a/runtime/lua/vim/lsp/util.lua +++ b/runtime/lua/vim/lsp/util.lua @@ -822,6 +822,10 @@ function M.convert_signature_help_to_markdown_lines(signature_help, ft, triggers if type(doc) == 'string' then signature.documentation = { kind = 'plaintext', value = doc } 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) end if signature.parameters and #signature.parameters > 0 then diff --git a/test/functional/plugin/lsp_spec.lua b/test/functional/plugin/lsp_spec.lua index 71078f12b3..024ab31096 100644 --- a/test/functional/plugin/lsp_spec.lua +++ b/test/functional/plugin/lsp_spec.lua @@ -3774,7 +3774,7 @@ describe('LSP', function() } return vim.lsp.util.convert_signature_help_to_markdown_lines(signature_help, 'cs', { ',' }) end) - local expected = { '```cs', 'TestEntity.TestEntity()', '```', 'some doc' } + local expected = { '```cs', 'TestEntity.TestEntity()', '```', '---', 'some doc' } eq(expected, result) end)