Skip to content

Commit

Permalink
feat: add snippet indicator back to label on render
Browse files Browse the repository at this point in the history
  • Loading branch information
Saghen committed Nov 8, 2024
1 parent f4dcebf commit 6f5ae79
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
5 changes: 3 additions & 2 deletions lua/blink/cmp/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -420,11 +420,12 @@ local config = {
text = function(ctx) return ctx.label .. (ctx.label_detail or '') end,
highlight = function(ctx)
-- label and label details
local label = ctx.label
local highlights = {
{ 0, #ctx.label, group = ctx.deprecated and 'BlinkCmpLabelDeprecated' or 'BlinkCmpLabel' },
{ 0, #label, group = ctx.deprecated and 'BlinkCmpLabelDeprecated' or 'BlinkCmpLabel' },
}
if ctx.label_detail then
table.insert(highlights, { #ctx.label, #ctx.label + #ctx.label_detail, group = 'BlinkCmpLabelDetail' })
table.insert(highlights, { #label, #label + #ctx.label_detail, group = 'BlinkCmpLabelDetail' })
end

-- characters matched on the label by the fuzzy matcher
Expand Down
2 changes: 1 addition & 1 deletion lua/blink/cmp/windows/render/context.lua
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ function context.new(draw, item, matched_indices)
local kind_icon = config.kind_icons[kind] or config.kind_icons.Field
-- Some LSPs can return labels with newlines.
-- Escape them to avoid errors in nvim_buf_set_lines when rendering the autocomplete menu.
local label = item.label:gsub('\n', '\\n')
local label = item.label:gsub('\n', '\\n') .. (kind == 'Snippet' and '~' or '')
if config.nerd_font_variant == 'normal' then label = label:gsub('', '') end

return {
Expand Down

0 comments on commit 6f5ae79

Please sign in to comment.