diff --git a/lua/blink/cmp/sources/lib/provider/init.lua b/lua/blink/cmp/sources/lib/provider/init.lua index 0494dcc3..8d2acd84 100644 --- a/lua/blink/cmp/sources/lib/provider/init.lua +++ b/lua/blink/cmp/sources/lib/provider/init.lua @@ -112,6 +112,10 @@ function source:should_show_items(context, items) local current_keyword_length = context.bounds.length if current_keyword_length < min_keyword_length then return false end + -- check if the source wants to show items + if self.module.should_show_items ~= nil and not self.module:should_show_items(context, items) then return false end + + -- check if the user wants to show items if self.config.should_show_items == nil then return true end return self.config.should_show_items(context, items) end diff --git a/lua/blink/cmp/sources/lib/types.lua b/lua/blink/cmp/sources/lib/types.lua index b2bd7080..25a44cc6 100644 --- a/lua/blink/cmp/sources/lib/types.lua +++ b/lua/blink/cmp/sources/lib/types.lua @@ -12,7 +12,7 @@ --- @field enabled? fun(self: blink.cmp.Source): boolean --- @field get_trigger_characters? fun(self: blink.cmp.Source): string[] --- @field get_completions? fun(self: blink.cmp.Source, context: blink.cmp.Context, callback: fun(response?: blink.cmp.CompletionResponse)): (fun(): nil) | nil ---- @field should_show_completions? fun(self: blink.cmp.Source, context: blink.cmp.Context, response: blink.cmp.CompletionResponse): boolean +--- @field should_show_items? fun(self: blink.cmp.Source, context: blink.cmp.Context, items: blink.cmp.CompletionItem[]): boolean --- @field resolve? fun(self: blink.cmp.Source, item: blink.cmp.CompletionItem, callback: fun(resolved_item?: lsp.CompletionItem)): ((fun(): nil) | nil) --- @field execute? fun(self: blink.cmp.Source, context: blink.cmp.Context, item: blink.cmp.CompletionItem, callback: fun()): (fun(): nil) | nil --- @field get_signature_help_trigger_characters? fun(self: blink.cmp.Source): string[] @@ -23,7 +23,7 @@ --- @field enabled? fun(self: blink.cmp.Source): boolean --- @field get_trigger_characters? fun(self: blink.cmp.Source): string[] --- @field get_completions? fun(self: blink.cmp.Source, context: blink.cmp.Context, callback: fun(response: blink.cmp.CompletionResponse | nil)): (fun(): nil) | nil ---- @field should_show_completions? fun(self: blink.cmp.Source, context: blink.cmp.Context, response: blink.cmp.CompletionResponse): boolean +--- @field should_show_items? fun(self: blink.cmp.Source, context: blink.cmp.Context, items: blink.cmp.CompletionItem[]): boolean --- @field resolve? fun(self: blink.cmp.Source, item: blink.cmp.CompletionItem, callback: fun(resolved_item: lsp.CompletionItem | nil)): ((fun(): nil) | nil) --- @field execute? fun(self: blink.cmp.Source, context: blink.cmp.Context, item: blink.cmp.CompletionItem, callback: fun()): (fun(): nil) | nil --- @field get_signature_help_trigger_characters? fun(self: blink.cmp.Source): string[]