Skip to content

Commit 4212532

Browse files
committed
fix(completion): fix blink_cmp filtering and async support
- Rename is_available to enabled per blink_cmp API - Implement filterText for proper fuzzy matching - Add async flag to source provider configuration - Improve insert text fallback handling
1 parent 10be2ad commit 4212532

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

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

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ function Source:get_trigger_characters()
2121
}
2222
end
2323

24-
function Source:is_available()
24+
function Source:enabled()
2525
return vim.bo.filetype == 'opencode'
2626
end
2727

@@ -43,7 +43,7 @@ function Source:get_completions(ctx, callback)
4343
end
4444

4545
local context = {
46-
input = trigger_match,
46+
input = trigger_match, -- Pass input for search-based sources (e.g., files)
4747
cursor_pos = col,
4848
line = line,
4949
trigger_char = trigger_char,
@@ -53,14 +53,17 @@ function Source:get_completions(ctx, callback)
5353
for _, completion_source in ipairs(completion_sources) do
5454
local source_items = completion_source.complete(context):await()
5555
for i, item in ipairs(source_items) do
56+
local insert_text = item.insert_text or item.label
5657
table.insert(items, {
5758
label = item.label,
5859
kind = item.kind,
5960
kind_icon = item.kind_icon,
6061
kind_hl = item.kind_hl,
6162
detail = item.detail,
6263
documentation = item.documentation,
63-
insertText = item.insert_text or item.label,
64+
-- Use filterText for fuzzy matching against the typed text after trigger char
65+
filterText = item.filter_text or item.label,
66+
insertText = insert_text,
6467
sortText = string.format(
6568
'%02d_%02d_%02d_%s',
6669
completion_source.priority or 999,
@@ -100,6 +103,7 @@ function M.setup(completion_sources)
100103

101104
blink.add_source_provider('opencode_mentions', {
102105
module = 'opencode.ui.completion.engines.blink_cmp',
106+
async = true,
103107
})
104108

105109
return true

0 commit comments

Comments
 (0)