1
1
--- @class blink.cmp.CompletionRenderContext
2
2
--- @field item blink.cmp.CompletionItem
3
3
--- @field label string
4
+ --- @field detail string
4
5
--- @field kind string
5
6
--- @field kind_icon string
6
7
--- @field icon_gap string
@@ -324,16 +325,19 @@ function autocomplete.draw()
324
325
for _ , item in ipairs (autocomplete .items ) do
325
326
local kind = require (' blink.cmp.types' ).CompletionItemKind [item .kind ] or ' Unknown'
326
327
local kind_icon = config .kind_icons [kind ] or config .kind_icons .Field
327
- -- Some LSPs can return labels with newlines.
328
+ -- Some LSPs can return labels and details with newlines.
328
329
-- Escape them to avoid errors in nvim_buf_set_lines when rendering the autocomplete menu.
329
330
local label = item .label :gsub (' \n ' , ' \\ n' )
331
+ local detail = (item .labelDetails and item .labelDetails .detail ) and
332
+ item .labelDetails .detail :gsub (' \n ' , ' \\ n' ) or ' '
330
333
if config .nerd_font_variant == ' normal' then label = label :gsub (' …' , ' … ' ) end
331
334
332
335
table.insert (
333
336
components_list ,
334
337
draw_fn ({
335
338
item = item ,
336
339
label = label ,
340
+ detail = detail ,
337
341
kind = kind ,
338
342
kind_icon = kind_icon ,
339
343
icon_gap = icon_gap ,
@@ -380,7 +384,7 @@ function autocomplete.draw_item_simple(ctx)
380
384
{
381
385
ctx .label ,
382
386
ctx .kind == ' Snippet' and ' ~' or ' ' ,
383
- ( ctx .item . labelDetails and ctx . item . labelDetails . detail ) and ctx . item . labelDetails . detail or ' ' ,
387
+ ctx .detail ,
384
388
fill = true ,
385
389
hl_group = ctx .deprecated and ' BlinkCmpLabelDeprecated' or ' BlinkCmpLabel' ,
386
390
max_width = 80 ,
@@ -397,7 +401,7 @@ function autocomplete.draw_item_reversed(ctx)
397
401
{
398
402
ctx .label ,
399
403
ctx .kind == ' Snippet' and ' ~' or nil ,
400
- ( ctx .item . labelDetails and ctx . item . labelDetails . detail ) and ctx . item . labelDetails . detail or ' ' ,
404
+ ctx .detail ,
401
405
fill = true ,
402
406
hl_group = ctx .deprecated and ' BlinkCmpLabelDeprecated' or ' BlinkCmpLabel' ,
403
407
max_width = 50 ,
@@ -421,7 +425,7 @@ function autocomplete.draw_item_minimal(ctx)
421
425
{
422
426
ctx .label ,
423
427
ctx .kind == ' Snippet' and ' ~' or nil ,
424
- ( ctx .item . labelDetails and ctx . item . labelDetails . detail ) and ctx . item . labelDetails . detail or ' ' ,
428
+ ctx .detail ,
425
429
fill = true ,
426
430
hl_group = ctx .deprecated and ' BlinkCmpLabelDeprecated' or ' BlinkCmpLabel' ,
427
431
max_width = 50 ,
0 commit comments