Skip to content

Commit ff1f5fa

Browse files
committed
feat: expose reload function for sources
closes #28
1 parent 90d6394 commit ff1f5fa

File tree

4 files changed

+25
-2
lines changed

4 files changed

+25
-2
lines changed

lua/blink/cmp/sources/lib/init.lua

+9
Original file line numberDiff line numberDiff line change
@@ -134,4 +134,13 @@ function sources.cancel_signature_help()
134134
end
135135
end
136136

137+
--- Misc ---
138+
139+
--- For external integrations to force reloading the source
140+
function sources.reload()
141+
for _, source in ipairs(sources.providers) do
142+
source:reload()
143+
end
144+
end
145+
137146
return sources

lua/blink/cmp/sources/lib/provider.lua

+8
Original file line numberDiff line numberDiff line change
@@ -114,4 +114,12 @@ function source:get_signature_help(context)
114114
end)
115115
end
116116

117+
--- Misc ---
118+
119+
--- For external integrations to force reloading the source
120+
function source:reload()
121+
if self.module.reload == nil then return end
122+
self.module:reload()
123+
end
124+
117125
return source

lua/blink/cmp/sources/lib/types.lua

+4
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@
1515
--- @field filter_completions (fun(self: blink.cmp.Source, response: blink.cmp.CompletionResponse): blink.cmp.CompletionItem[]) | nil
1616
--- @field should_show_completions (fun(self: blink.cmp.Source, context: blink.cmp.Context, response: blink.cmp.CompletionResponse): boolean) | nil
1717
--- @field resolve (fun(self: blink.cmp.Source, item: blink.cmp.CompletionItem, callback: fun(resolved_item: lsp.CompletionItem | nil)): ((fun(): nil) | nil)) | nil
18+
--- @field get_signature_help_trigger_characters fun(self: blink.cmp.Source): string[]
19+
--- @field get_signature_help fun(self: blink.cmp.Source, context: blink.cmp.SignatureHelpContext): blink.cmp.Task
20+
--- @field reload (fun(self: blink.cmp.Source): nil) | nil
1821
---
1922
--- @class blink.cmp.SourceProvider
2023
--- @field name string
@@ -27,3 +30,4 @@
2730
--- @field resolve fun(self: blink.cmp.SourceProvider, item: blink.cmp.CompletionItem): blink.cmp.Task
2831
--- @field get_signature_help_trigger_characters fun(self: blink.cmp.SourceProvider): string[]
2932
--- @field get_signature_help fun(self: blink.cmp.SourceProvider, context: blink.cmp.SignatureHelpContext): blink.cmp.Task
33+
--- @field reload (fun(self: blink.cmp.Source): nil) | nil

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

+4-2
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@ function snippets.new(config)
1212
--- @type table<string, blink.cmp.CompletionItem[]>
1313
self.cache = {}
1414
--- @type blink.cmp.SnippetsOpts
15-
local opts = config.opts or {}
16-
self.registry = require('blink.cmp.sources.snippets.registry').new(opts)
15+
self.registry = require('blink.cmp.sources.snippets.registry').new(config.opts or {})
1716
return self
1817
end
1918

@@ -59,4 +58,7 @@ function snippets:resolve(item, callback)
5958
callback(resolved_item)
6059
end
6160

61+
--- For external integrations to force reloading the snippets
62+
function snippets:reload() self.cache = {} end
63+
6264
return snippets

0 commit comments

Comments
 (0)