Skip to content

Commit deba523

Browse files
committed
feat: expose source provider config to sources
1 parent 7f2e6e7 commit deba523

File tree

4 files changed

+8
-7
lines changed

4 files changed

+8
-7
lines changed

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ function source.new(config)
99
local self = setmetatable({}, { __index = source })
1010
self.name = config.name
1111
--- @type blink.cmp.Source
12-
self.module = require(config[1]).new(config.opts or {})
12+
self.module = require(config[1]).new(config)
1313
self.config = config
1414
self.last_response = nil
1515

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
--- @field items blink.cmp.CompletionItem[]
1010
---
1111
--- @class blink.cmp.Source
12-
--- @field new fun(opts: table): blink.cmp.Source
12+
--- @field new fun(config: blink.cmp.SourceProviderConfig): blink.cmp.Source
1313
--- @field get_trigger_characters (fun(self: blink.cmp.Source): string[]) | nil
1414
--- @field get_completions fun(self: blink.cmp.Source, context: blink.cmp.Context, callback: fun(response: blink.cmp.CompletionResponse)): (fun(): nil) | nil
1515
--- @field filter_completions (fun(self: blink.cmp.Source, response: blink.cmp.CompletionResponse): blink.cmp.CompletionItem[]) | nil

lua/blink/cmp/sources/path/init.lua

+3-3
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ local NAME_REGEX = '\\%([^/\\\\:\\*?<>\'"`\\|]\\)'
66
local PATH_REGEX =
77
assert(vim.regex(([[\%(\%(/PAT*[^/\\\\:\\*?<>\'"`\\| .~]\)\|\%(/\.\.\)\)*/\zePAT*$]]):gsub('PAT', NAME_REGEX)))
88

9-
function path.new(opts)
9+
function path.new(config)
1010
local self = setmetatable({}, { __index = path })
1111

12-
opts = vim.tbl_deep_extend('keep', opts, {
12+
local opts = vim.tbl_deep_extend('keep', config.opts or {}, {
1313
trailing_slash = false,
1414
label_trailing_slash = true,
1515
get_cwd = function(context) return vim.fn.expand(('#%d:p:h'):format(context.bufnr)) end,
@@ -22,7 +22,7 @@ function path.new(opts)
2222
show_hidden_files_by_default = { opts.show_hidden_files_by_default, 'boolean' },
2323
})
2424

25-
self.opts = opts or {}
25+
self.opts = opts
2626
return self
2727
end
2828

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

+3-2
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,12 @@
77

88
local snippets = {}
99

10-
--- @param opts blink.cmp.SnippetsOpts
11-
function snippets.new(opts)
10+
function snippets.new(config)
1211
local self = setmetatable({}, { __index = snippets })
1312
--- @type table<string, blink.cmp.CompletionItem[]>
1413
self.cache = {}
14+
--- @type blink.cmp.SnippetsOpts
15+
local opts = config.opts or {}
1516
self.registry = require('blink.cmp.sources.snippets.registry').new(opts)
1617
return self
1718
end

0 commit comments

Comments
 (0)