Skip to content

Commit f5d4dae

Browse files
committed
feat: put context via wrapper
1 parent 4650a35 commit f5d4dae

File tree

4 files changed

+5
-4
lines changed

4 files changed

+5
-4
lines changed

lua/blink/cmp/sources/buffer.lua

+1-1
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ function buffer.new(config) return setmetatable(config, { __index = buffer }) en
6868

6969
function buffer:get_completions(context, callback)
7070
local transformed_callback = function(items)
71-
callback({ is_incomplete_forward = false, is_incomplete_backward = false, context = context, items = items })
71+
callback({ is_incomplete_forward = false, is_incomplete_backward = false, items = items })
7272
end
7373

7474
local buf_text = get_buf_text()

lua/blink/cmp/sources/lib/source.lua

+2
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ function source:get_completions(context)
3838
return async.task
3939
.new(function(resolve) return self.module:get_completions(context, resolve) end)
4040
:map(function(response)
41+
response.context = context
42+
4143
self.last_response = response
4244

4345
-- add score offset if configured

lua/blink/cmp/sources/lsp.lua

+2-2
Original file line numberDiff line numberDiff line change
@@ -128,15 +128,15 @@ function lsp:get_completions(context, callback)
128128
-- todo: ideally pass multiple responses to the sources
129129
-- so that we can do fine-grained isIncomplete
130130
-- or do caching here
131-
local combined_response =
132-
{ is_incomplete_forward = false, is_incomplete_backward = false, context = context, items = {} }
131+
local combined_response = { is_incomplete_forward = false, is_incomplete_backward = false, items = {} }
133132
for _, response in pairs(responses) do
134133
combined_response.is_incomplete_forward = combined_response.is_incomplete_forward
135134
or response.is_incomplete_forward
136135
combined_response.is_incomplete_backward = combined_response.is_incomplete_backward
137136
or response.is_incomplete_backward
138137
vim.list_extend(combined_response.items, response.items)
139138
end
139+
140140
callback(combined_response)
141141
end)
142142
end

lua/blink/cmp/sources/snippets/init.lua

-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ function snippets:get_completions(context, callback)
3838
callback({
3939
is_incomplete_forward = false,
4040
is_incomplete_backward = false,
41-
context = context,
4241
items = self.cache[filetype],
4342
})
4443
end

0 commit comments

Comments
 (0)