fix(lsp): show CompletionItem.detail in info popup #38904

Problem: completionItem/resolve response's `detail` field is silently
dropped. Only `documentation` is shown in the popup.

Solution: Prepend `detail` as a fenced code block before `documentation`
in the info popup, skipping if documentation already contains it.

(cherry picked from commit b351afb1b1)
This commit is contained in:
glepnir
2026-04-19 03:43:20 +08:00
committed by github-actions[bot]
parent 326a7d5afb
commit 34cbfeca9c
2 changed files with 51 additions and 18 deletions

View File

@@ -747,9 +747,21 @@ function CompletionResolver:request(bufnr, param, selected_word)
return
end
local value = vim.tbl_get(result, 'documentation', 'value')
local value = vim.tbl_get(result, 'documentation', 'value') --[[@as string?]]
local kind = vim.tbl_get(result, 'documentation', 'kind')
local text_format = vim.tbl_get(result, 'insertTextFormat')
if result.detail and result.detail ~= '' then
if not value then
value = ('```%s\n%s\n```'):format(vim.bo.filetype, result.detail)
kind = kind or lsp.protocol.MarkupKind.Markdown
elseif not value:find(result.detail, 1, true) then
local detail_block = ('```%s\n%s\n```'):format(vim.bo.filetype, result.detail)
value = detail_block .. '\n' .. value
kind = kind or lsp.protocol.MarkupKind.Markdown
end
end
if not value then
if text_format ~= protocol.InsertTextFormat.Snippet then
return