From c3794225888195314217e2592865c76c87fc22b2 Mon Sep 17 00:00:00 2001 From: Liam Dyer Date: Tue, 31 Dec 2024 11:50:14 -0500 Subject: [PATCH] refactor: make context first arg for getting completions from lsp --- lua/blink/cmp/sources/lsp/completion.lua | 5 ++++- lua/blink/cmp/sources/lsp/init.lua | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/lua/blink/cmp/sources/lsp/completion.lua b/lua/blink/cmp/sources/lsp/completion.lua index 4a0ff619..5d542806 100644 --- a/lua/blink/cmp/sources/lsp/completion.lua +++ b/lua/blink/cmp/sources/lsp/completion.lua @@ -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 = { diff --git a/lua/blink/cmp/sources/lsp/init.lua b/lua/blink/cmp/sources/lsp/init.lua index 01a72a40..4dbfd8f0 100644 --- a/lua/blink/cmp/sources/lsp/init.lua +++ b/lua/blink/cmp/sources/lsp/init.lua @@ -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