120
120
--- @field winblend ? number
121
121
--- @field winhighlight ? string
122
122
--- @field scrolloff ? number
123
- --- @field draw ? ' simple ' | ' reversed ' | ' minimal ' | blink.cmp.CompletionDrawFn
123
+ --- @field draw ? blink.cmp.Draw
124
124
--- @field cycle ? blink.cmp.AutocompleteConfig.CycleConfig
125
125
126
126
--- @class blink.cmp.AutocompleteConfig.CycleConfig
@@ -389,11 +389,65 @@ local config = {
389
389
-- 'auto_insert' will not select any item by default, and insert the completion items automatically when selecting them
390
390
selection = ' preselect' ,
391
391
-- Controls how the completion items are rendered on the popup window
392
- -- 'simple' will render the item's kind icon the left alongside the label
393
- -- 'reversed' will render the label on the left and the kind icon + name on the right
394
- -- 'minimal' will render the label on the left and the kind name on the right
395
- -- 'function(blink.cmp.CompletionRenderContext): blink.cmp.Component[]' for custom rendering
396
- draw = ' simple' ,
392
+ draw = {
393
+ align_to_component = ' label' , -- or 'none' to disable
394
+ -- Left and right padding, optionally { left, right } for different padding on each side
395
+ padding = 1 ,
396
+ -- Gap between columns
397
+ gap = 1 ,
398
+ -- Components to render, grouped by column
399
+ columns = { { ' kind_icon' }, { ' label' , ' label_description' , gap = 1 } },
400
+ -- Definitions for possible components to render. Each component defines:
401
+ -- ellipsis: whether to add an ellipsis when truncating the text
402
+ -- width: control the min, max and fill behavior of the component
403
+ -- text function: will be called for each item
404
+ -- highlight function: will be called only when the line appears on screen
405
+ components = {
406
+ kind_icon = {
407
+ ellipsis = false ,
408
+ text = function (ctx ) return ctx .kind_icon .. ' ' end ,
409
+ highlight = function (ctx ) return ' BlinkCmpKind' .. ctx .kind end ,
410
+ },
411
+
412
+ kind = {
413
+ ellipsis = false ,
414
+ text = function (ctx ) return ctx .kind .. ' ' end ,
415
+ highlight = function (ctx ) return ' BlinkCmpKind' .. ctx .kind end ,
416
+ },
417
+
418
+ label = {
419
+ width = { fill = true , max = 60 },
420
+ text = function (ctx ) return ctx .label .. (ctx .label_detail or ' ' ) end ,
421
+ highlight = function (ctx )
422
+ -- label and label details
423
+ local highlights = {
424
+ { 0 , # ctx .label , group = ctx .deprecated and ' BlinkCmpLabelDeprecated' or ' BlinkCmpLabel' },
425
+ }
426
+ if ctx .label_detail then
427
+ table.insert (
428
+ highlights ,
429
+ { # ctx .label + 1 , # ctx .label + # ctx .label_detail , group = ' BlinkCmpLabelDetail' }
430
+ )
431
+ end
432
+
433
+ -- characters matched on the label by the fuzzy matcher
434
+ if ctx .label_matched_indices ~= nil then
435
+ for _ , idx in ipairs (ctx .label_matched_indices ) do
436
+ table.insert (highlights , { idx , idx + 1 , group = ' BlinkCmpLabelMatch' })
437
+ end
438
+ end
439
+
440
+ return highlights
441
+ end ,
442
+ },
443
+
444
+ label_description = {
445
+ width = { max = 30 },
446
+ text = function (ctx ) return ctx .label_description or ' ' end ,
447
+ highlight = ' BlinkCmpLabelDescription' ,
448
+ },
449
+ },
450
+ },
397
451
-- Controls the cycling behavior when reaching the beginning or end of the completion list.
398
452
cycle = {
399
453
-- When `true`, calling `select_next` at the *bottom* of the completion list will select the *first* completion item.
@@ -405,7 +459,7 @@ local config = {
405
459
documentation = {
406
460
max_width = 80 ,
407
461
max_height = 20 ,
408
- desired_min_width = 40 ,
462
+ desired_min_width = 50 ,
409
463
desired_min_height = 10 ,
410
464
border = ' padded' ,
411
465
winblend = 0 ,
@@ -496,6 +550,13 @@ local config = {
496
550
local M = {}
497
551
498
552
--- @param opts blink.cmp.Config
499
- function M .merge_with (opts ) config = vim .tbl_deep_extend (' force' , config , opts or {}) end
553
+ function M .merge_with (opts )
554
+ config = vim .tbl_deep_extend (' force' , config , opts or {})
555
+
556
+ -- TODO: remove on 1.0
557
+ if type (config .windows .autocomplete .draw ) == ' string' or type (config .windows .autocomplete .draw ) == ' function' then
558
+ error (' The blink.cmp autocomplete draw has been rewritten, please see the README for the new configuration' )
559
+ end
560
+ end
500
561
501
562
return setmetatable (M , { __index = function (_ , k ) return config [k ] end })
0 commit comments