From 3fbe21100a64079422af7dbf8a9132c308d3ae5c Mon Sep 17 00:00:00 2001 From: Mika Vilpas Date: Mon, 4 Nov 2024 20:00:19 +0200 Subject: [PATCH] refactor: resolve "no completions" as nil --- lua/blink-cmp-rg/init.lua | 22 +++------------------- 1 file changed, 3 insertions(+), 19 deletions(-) diff --git a/lua/blink-cmp-rg/init.lua b/lua/blink-cmp-rg/init.lua index 73b2509..1ba5bf5 100644 --- a/lua/blink-cmp-rg/init.lua +++ b/lua/blink-cmp-rg/init.lua @@ -9,7 +9,7 @@ ---@field prefix_min_len number ---@field get_command fun(context: blink.cmp.Context, prefix: string): string[] ---@field get_prefix fun(context: blink.cmp.Context): string ----@field get_completions? fun(self: blink.cmp.Source, context: blink.cmp.Context, callback: fun(response: blink.cmp.CompletionResponse)): (fun(): nil) | nil +---@field get_completions? fun(self: blink.cmp.Source, context: blink.cmp.Context, callback: fun(response: blink.cmp.CompletionResponse | nil)): (fun(): nil) | nil local RgSource = {} ---@param opts blink-cmp-rg.Options @@ -43,30 +43,14 @@ function RgSource:get_completions(context, resolve) local prefix = self.get_prefix(context) if string.len(prefix) < self.prefix_min_len then - resolve( - -- TODO check https://github.com/Saghen/blink.cmp/pull/254 - { - is_incomplete_forward = true, - is_incomplete_backward = true, - items = {}, - context = context, - } - ) + resolve() ---@diagnostic disable-next-line: missing-return-value return end vim.system(self.get_command(context, prefix), nil, function(result) if result.code ~= 0 then - resolve( - -- TODO check https://github.com/Saghen/blink.cmp/pull/254 - { - is_incomplete_forward = true, - is_incomplete_backward = true, - items = {}, - context = context, - } - ) + resolve() return end