mirror of
https://github.com/neovim/neovim.git
synced 2026-06-15 16:23:48 +00:00
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:
committed by
github-actions[bot]
parent
326a7d5afb
commit
34cbfeca9c
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user