Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions lua/opencode/ui/completion/engines/blink_cmp.lua
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,14 @@ function Source:get_trigger_characters()
local mention_key = config.get_key_for_function('input_window', 'mention')
local slash_key = config.get_key_for_function('input_window', 'slash_commands')
local context_key = config.get_key_for_function('input_window', 'context_items')
local triggers = {}
return {
slash_key or '',
mention_key or '',
context_key or '',
}
end

function Source:is_available()
function Source:enabled()
return vim.bo.filetype == 'opencode'
end

Expand All @@ -44,7 +43,7 @@ function Source:get_completions(ctx, callback)
end

local context = {
input = trigger_match,
input = trigger_match, -- Pass input for search-based sources (e.g., files)
cursor_pos = col,
line = line,
trigger_char = trigger_char,
Expand All @@ -54,14 +53,17 @@ function Source:get_completions(ctx, callback)
for _, completion_source in ipairs(completion_sources) do
local source_items = completion_source.complete(context):await()
for i, item in ipairs(source_items) do
local insert_text = item.insert_text or item.label
table.insert(items, {
label = item.label,
kind = item.kind,
kind_icon = item.kind_icon,
kind_hl = item.kind_hl,
detail = item.detail,
documentation = item.documentation,
insertText = item.insert_text or item.label,
-- Use filterText for fuzzy matching against the typed text after trigger char
filterText = item.filter_text or item.label,
insertText = insert_text,
sortText = string.format(
'%02d_%02d_%02d_%s',
completion_source.priority or 999,
Expand Down Expand Up @@ -101,6 +103,7 @@ function M.setup(completion_sources)

blink.add_source_provider('opencode_mentions', {
module = 'opencode.ui.completion.engines.blink_cmp',
async = true,
})

return true
Expand Down