Skip to content

Commit a034865

Browse files
committed
feat: blink cmp specific winhighlights and highlights
1 parent d6a81d3 commit a034865

File tree

4 files changed

+23
-4
lines changed

4 files changed

+23
-4
lines changed

lua/blink/cmp/config.lua

+9-3
Original file line numberDiff line numberDiff line change
@@ -82,13 +82,14 @@
8282
--- @field order "top_down" | "bottom_up"
8383
--- @field direction_priority ("n" | "s")[]
8484
--- @field preselect boolean
85-
--- @field winhighlight string | nil
85+
--- @field winhighlight string
86+
--- @field scrolloff number
8687

8788
--- @class blink.cmp.DocumentationDirectionPriorityConfig
8889
--- @field autocomplete_north ("n" | "s" | "e" | "w")[]
8990
--- @field autocomplete_south ("n" | "s" | "e" | "w")[]
9091
---
91-
--- @alias blink.cmp.WindowBorder 'single' | 'double' | 'rounded' | 'solid' | 'shadow' | 'padded' | 'none'
92+
--- @alias blink.cmp.WindowBorder 'single' | 'double' | 'rounded' | 'solid' | 'shadow' | 'padded' | 'none' | string[]
9293
---
9394
--- @class blink.cmp.DocumentationConfig
9495
--- @field min_width number
@@ -99,13 +100,14 @@
99100
--- @field auto_show boolean
100101
--- @field auto_show_delay_ms number Delay before showing the documentation window
101102
--- @field update_delay_ms number Delay before updating the documentation window
102-
--- @field winhighlight string | nil
103+
--- @field winhighlight string
103104

104105
--- @class blink.cmp.SignatureHelpConfig
105106
--- @field min_width number
106107
--- @field max_width number
107108
--- @field max_height number
108109
--- @field border blink.cmp.WindowBorder
110+
--- @field winhighlight string
109111

110112
--- @class blink.cmp.Config
111113
--- @field keymap blink.cmp.KeymapConfig
@@ -210,6 +212,8 @@ local config = {
210212
max_width = 60,
211213
max_height = 10,
212214
border = 'none',
215+
winhighlight = 'Normal:BlinkCmpMenu,FloatBorder:BlinkCmpMenuBorder,CursorLine:BlinkCmpMenuSelection,Search:None',
216+
scrolloff = 2,
213217
-- todo: implement
214218
order = 'top_down',
215219
-- which directions to show the window,
@@ -223,6 +227,7 @@ local config = {
223227
max_width = 60,
224228
max_height = 20,
225229
border = 'padded',
230+
winhighlight = 'Normal:BlinkCmpDoc,FloatBorder:BlinkCmpDocBorder,CursorLine:BlinkCmpDocCursorLine,Search:None',
226231
-- which directions to show the documentation window,
227232
-- for each of the possible autocomplete window directions,
228233
-- falling back to the next direction when there's not enough space
@@ -239,6 +244,7 @@ local config = {
239244
max_width = 100,
240245
max_height = 10,
241246
border = 'padded',
247+
winhighlight = 'Normal:BlinkCmpSignatureHelp,FloatBorder:BlinkCmpSignatureHelpBorder',
242248
},
243249
},
244250

lua/blink/cmp/init.lua

+12
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,18 @@ cmp.add_default_highlights = function()
103103
set_hl('BlinkCmpLabelMatch', { link = use_nvim_cmp and 'CmpItemAbbrMatch' or 'Pmenu' })
104104
set_hl('BlinkCmpKind', { link = use_nvim_cmp and 'CmpItemKind' or 'Special' })
105105
set_hl('BlinkCmpSignatureHelpActiveParameter', { link = 'LspSignatureActiveParameter' })
106+
107+
set_hl('BlinkCmpMenu', { link = 'Pmenu' })
108+
set_hl('BlinkCmpMenuBorder', { link = 'Pmenu' })
109+
set_hl('BlinkCmpMenuSelection', { link = 'PmenuSel' })
110+
111+
set_hl('BlinkCmpDoc', { link = 'NormalFloat' })
112+
set_hl('BlinkCmpDocBorder', { link = 'FloatBorder' })
113+
set_hl('BlinkCmpDocCursorLine', { link = 'Visual' })
114+
115+
set_hl('BlinkCmpSignatureHelp', { link = 'NormalFloat' })
116+
set_hl('BlinkCmpSignatureHelpBorder', { link = 'FloatBorder' })
117+
106118
for _, kind in pairs(vim.lsp.protocol.CompletionItemKind) do
107119
set_hl('BlinkCmpKind' .. kind, { link = use_nvim_cmp and 'CmpItemKind' .. kind or 'BlinkCmpItemKind' })
108120
end

lua/blink/cmp/windows/documentation.lua

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ function docs.setup()
1010
max_width = config.max_width,
1111
max_height = config.max_height,
1212
border = config.border,
13-
winhighlight = config.winhighlight or 'Normal:Normal,FloatBorder:FloatBorder,CursorLine:Visual,Search:None',
13+
winhighlight = config.winhighlight,
1414
wrap = true,
1515
filetype = 'markdown',
1616
})

lua/blink/cmp/windows/signature.lua

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ function signature.setup()
1010
max_width = config.max_width,
1111
max_height = config.max_height,
1212
border = config.border,
13+
winhighlight = config.winhighlight,
1314
wrap = true,
1415
filetype = 'markdown',
1516
})

0 commit comments

Comments
 (0)