feat(lsp): support CompletionItem.labelDetails #38403

Problem: CompletionItem.labelDetails is ignored, losing
function signatures and module info in the completion menu.

Solution: Append labelDetails.detail to abbr and use
labelDetails.description for menu with fallback to item.detail.

https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#completionItemLabelDetails
This commit is contained in:
glepnir
2026-03-22 07:07:26 +08:00
committed by GitHub
parent 2069be281c
commit cc518cf9ba
3 changed files with 18 additions and 2 deletions

View File

@@ -443,9 +443,9 @@ function M._lsp_to_complete_items(
local kind, kind_hlgroup = generate_kind(item)
local completion_item = {
word = word,
abbr = item.label,
abbr = ('%s%s'):format(item.label, vim.tbl_get(item, 'labelDetails', 'detail') or ''),
kind = kind,
menu = item.detail or '',
menu = vim.tbl_get(item, 'labelDetails', 'description') or item.detail or '',
info = get_doc(item),
icase = 1,
dup = 1,