Skip to content

Commit de52ce2

Browse files
committed
feat(completion): add highlight to switches in context completion
1 parent 8bb9ae7 commit de52ce2

File tree

5 files changed

+6
-1
lines changed

5 files changed

+6
-1
lines changed

lua/opencode/types.lua

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,7 @@
299299
---@field label string Display text for the completion item
300300
---@field kind string Type of completion item (e.g., 'file', 'subagent')
301301
---@field kind_icon string Icon representing the kind
302+
---@field kind_hl? string Highlight group for the kind
302303
---@field detail string Additional detail text
303304
---@field documentation string Documentation text
304305
---@field insert_text string Text to insert when selected

lua/opencode/ui/completion/context.lua

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ local function create_context_item(name, type, available, documentation, icon, a
2525
label = label,
2626
kind = 'context',
2727
kind_icon = icon or (available and icons.get('status_on') or icons.get('status_off')),
28+
kind_hl = not icon and available and 'OpencodeContextSwitchOn' or nil,
2829
detail = name,
2930
documentation = documentation or (available and name or 'Enable ' .. name .. ' for this message'),
3031
insert_text = '',

lua/opencode/ui/completion/engines/blink_cmp.lua

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ function Source:get_completions(ctx, callback)
5656
label = item.label,
5757
kind = item.kind,
5858
kind_icon = item.kind_icon,
59+
kind_hl = item.kind_hl,
5960
detail = item.detail,
6061
documentation = item.documentation,
6162
insertText = item.insert_text or item.label,

lua/opencode/ui/completion/engines/nvim_cmp.lua

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ function M.setup(completion_sources)
5757
cmp = {
5858
kind_text = item.kind_icon,
5959
},
60+
kind_hl_group = item.kind_hl,
6061
detail = item.detail,
6162
documentation = item.documentation,
6263
insertText = item.insert_text or '',

lua/opencode/ui/highlight.lua

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ function M.setup()
3131
vim.api.nvim_set_hl(0, 'OpencodeContextError', { link = '@label', default = true })
3232
vim.api.nvim_set_hl(0, 'OpencodeContextWarning', { link = 'DiagnosticWarn', default = true })
3333
vim.api.nvim_set_hl(0, 'OpencodeContextInfo', { link = 'DiagnosticInfo', default = true })
34+
vim.api.nvim_set_hl(0, 'OpencodeContextSwitchOn', { link = '@label', default = true })
3435
else
3536
vim.api.nvim_set_hl(0, 'OpencodeBorder', { fg = '#616161', default = true })
3637
vim.api.nvim_set_hl(0, 'OpencodeBackground', { link = 'Normal', default = true })
@@ -58,7 +59,7 @@ function M.setup()
5859
vim.api.nvim_set_hl(0, 'OpencodeContextSelection', { link = '@label', default = true })
5960
vim.api.nvim_set_hl(0, 'OpencodeContextError', { link = 'DiagnosticError', default = true })
6061
vim.api.nvim_set_hl(0, 'OpencodeContextWarning', { link = 'DiagnosticWarn', default = true })
61-
vim.api.nvim_set_hl(0, 'OpencodeContextInfo', { link = 'DiagnosticInfo', default = true })
62+
vim.api.nvim_set_hl(0, 'OpencodeContextSwitchOn', { link = '@label', default = true })
6263
end
6364
end
6465

0 commit comments

Comments
 (0)