Skip to content

Commit b4bbad1

Browse files
authored
feat: add minimal render style (#85)
1 parent d334b65 commit b4bbad1

File tree

3 files changed

+22
-1
lines changed

3 files changed

+22
-1
lines changed

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,7 @@ MiniDeps.add({
288288
-- Controls how the completion items are rendered on the popup window
289289
-- 'simple' will render the item's kind icon the left alongside the label
290290
-- 'reversed' will render the label on the left and the kind icon + name on the right
291+
-- 'minimal' will render the label on the left and the kind name on the right
291292
-- 'function(blink.cmp.CompletionRenderContext): blink.cmp.Component[]' for custom rendering
292293
draw = 'simple',
293294
-- Controls the cycling behavior when reaching the beginning or end of the completion list.

lua/blink/cmp/config.lua

+1-1
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@
9090
--- @field preselect? boolean
9191
--- @field winhighlight? string
9292
--- @field scrolloff? number
93-
--- @field draw? 'simple' | 'reversed' | function(blink.cmp.CompletionRenderContext): blink.cmp.Component[]
93+
--- @field draw? 'simple' | 'reversed' | 'minimal' | function(blink.cmp.CompletionRenderContext): blink.cmp.Component[]
9494
--- @field cycle? blink.cmp.AutocompleteConfig.CycleConfig
9595

9696
--- @class blink.cmp.AutocompleteConfig.CycleConfig

lua/blink/cmp/windows/autocomplete.lua

+20
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,8 @@ function autocomplete.get_draw_fn()
248248
return autocomplete.render_item_simple
249249
elseif autocmp_config.draw == 'reversed' then
250250
return autocomplete.render_item_reversed
251+
elseif autocmp_config.draw == 'minimal' then
252+
return autocomplete.render_item_minimal
251253
end
252254
error('Invalid autocomplete window draw config')
253255
end
@@ -260,6 +262,7 @@ function autocomplete.render_item_simple(ctx)
260262
{ ctx.kind_icon, ctx.icon_gap, hl_group = 'BlinkCmpKind' .. ctx.kind },
261263
{
262264
ctx.item.label,
265+
ctx.kind == 'Snippet' and '~' or nil,
263266
fill = true,
264267
hl_group = ctx.deprecated and 'BlinkCmpLabelDeprecated' or 'BlinkCmpLabel',
265268
max_width = 50,
@@ -275,6 +278,7 @@ function autocomplete.render_item_reversed(ctx)
275278
' ',
276279
{
277280
ctx.item.label,
281+
ctx.kind == 'Snippet' and '~' or nil,
278282
fill = true,
279283
hl_group = ctx.deprecated and 'BlinkCmpLabelDeprecated' or 'BlinkCmpLabel',
280284
max_width = 50,
@@ -285,6 +289,22 @@ function autocomplete.render_item_reversed(ctx)
285289
}
286290
end
287291

292+
function autocomplete.render_item_minimal(ctx)
293+
return {
294+
' ',
295+
{
296+
ctx.item.label,
297+
ctx.kind == 'Snippet' and '~' or nil,
298+
fill = true,
299+
hl_group = ctx.deprecated and 'BlinkCmpLabelDeprecated' or 'BlinkCmpLabel',
300+
max_width = 50,
301+
},
302+
' ',
303+
{ ctx.kind, hl_group = 'BlinkCmpKind' .. ctx.kind },
304+
' ',
305+
}
306+
end
307+
288308
---@return blink.cmp.CompletionItem?
289309
function autocomplete.get_selected_item()
290310
if not autocomplete.win:is_open() then return end

0 commit comments

Comments
 (0)