Allow to take the full SourceConfig from source API (#561)

* - SourceConfig.opts -> SourceConfig.option
- Add SourceConfig.trigger_characters
- Allow accessing full SourceConfig from source

* fmt&lint
This commit is contained in:
hrsh7th
2021-11-23 21:17:03 +09:00
committed by GitHub
parent ea10d5bd2f
commit 1944b46336
7 changed files with 73 additions and 38 deletions

View File

@@ -78,9 +78,6 @@ config.get_source_config = function(name)
local c = config.get()
for _, s in ipairs(c.sources) do
if s.name == name then
if type(s.opts) ~= 'table' then
s.opts = {}
end
return s
end
end
@@ -98,6 +95,25 @@ config.normalize = function(c)
end
c.mapping = normalized
end
if c.sources then
for _, s in ipairs(c.sources) do
if s.opts and not s.option then
s.option = s.opts
s.opts = nil
vim.api.nvim_echo({
{ '[nvim-cmp] ', 'Normal' },
{ 'sources[number].opts', 'WarningMsg' },
{ ' is deprecated.\n', 'Normal' },
{ '[nvim-cmp] Please use ', 'Normal' },
{ 'sources[number].option', 'WarningMsg' },
{ ' instead.', 'Normal' },
}, true, {})
end
s.option = s.option or {}
end
end
return c
end