Skip to content

Commit 9d7e53d

Browse files
committed
feat(completion): add context trigger to nvim_cmp engine
1 parent a44fa81 commit 9d7e53d

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

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

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,17 @@ function M.setup(completion_sources)
1515
local config = require('opencode.config')
1616
local mention_key = config.get_key_for_function('input_window', 'mention')
1717
local slash_key = config.get_key_for_function('input_window', 'slash_commands')
18+
local context_key = config.get_key_for_function('input_window', 'context_items')
1819
local triggers = {}
1920
if mention_key then
2021
table.insert(triggers, mention_key)
2122
end
2223
if slash_key then
2324
table.insert(triggers, slash_key)
2425
end
26+
if context_key then
27+
table.insert(triggers, context_key)
28+
end
2529
return triggers
2630
end
2731

@@ -55,14 +59,20 @@ function M.setup(completion_sources)
5559
for j, item in ipairs(source_items) do
5660
table.insert(items, {
5761
label = item.label,
58-
kind = item.kind,
62+
kind = 1,
5963
cmp = {
6064
kind_text = item.kind_icon,
6165
},
6266
detail = item.detail,
6367
documentation = item.documentation,
64-
insertText = item.insert_text or item.label,
65-
sortText = string.format('%02d_%02d_%02d_%s', completion_source.priority or 999, item.priority or 999, j, item.label),
68+
insertText = item.insert_text or '',
69+
sortText = string.format(
70+
'%02d_%02d_%02d_%s',
71+
completion_source.priority or 999,
72+
item.priority or 999,
73+
j,
74+
item.label
75+
),
6676
data = {
6777
original_item = item,
6878
},

0 commit comments

Comments
 (0)