Skip to content

Commit

Permalink
refactor: make context first arg for getting completions from lsp
Browse files Browse the repository at this point in the history
  • Loading branch information
Saghen committed Dec 31, 2024
1 parent 1ef9bb9 commit c379422
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
5 changes: 4 additions & 1 deletion lua/blink/cmp/sources/lsp/completion.lua
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@ local CompletionTriggerKind = vim.lsp.protocol.CompletionTriggerKind

local completion = {}

function completion.get_completion_for_client(client, context)
--- @param context blink.cmp.Context
--- @param client vim.lsp.Client
--- @return blink.cmp.Task
function completion.get_completion_for_client(context, client)
return async.task.new(function(resolve)
local params = vim.lsp.util.make_position_params(0, client.offset_encoding)
params.context = {
Expand Down
2 changes: 1 addition & 1 deletion lua/blink/cmp/sources/lsp/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ function lsp:get_completions(context, callback)
-- TODO: implement a timeout before returning the menu as-is. In the future, it would be neat
-- to detect slow LSPs and consistently run them async
local task = async.task
.await_all(vim.tbl_map(function(client) return completion_lib.get_completion_for_client(client, context) end, clients))
.await_all(vim.tbl_map(function(client) return completion_lib.get_completion_for_client(context, client) end, clients))
:map(function(responses)
local final = { is_incomplete_forward = false, is_incomplete_backward = false, items = {} }
for _, response in ipairs(responses) do
Expand Down

0 comments on commit c379422

Please sign in to comment.