Improve vim source

This commit is contained in:
hrsh7th
2021-09-14 01:16:49 +09:00
parent 6173796b2b
commit 03f121fa23
3 changed files with 11 additions and 15 deletions

View File

@@ -72,9 +72,6 @@ end
---@type table<number, cmp.Source>
core.sources = {}
---@type table<string, cmp.Source>
core.sources_by_name = {}
---@type cmp.Context
core.context = context.new()
@@ -82,13 +79,11 @@ core.context = context.new()
---@param s cmp.Source
core.register_source = function(s)
core.sources[s.id] = s
core.sources_by_name[s.name] = s
end
---Unregister source
---@param source_id string
core.unregister_source = function(source_id)
core.sources_by_name[core.sources[source_id]] = nil
core.sources[source_id] = nil
end
@@ -123,11 +118,12 @@ end
core.get_sources = function(statuses)
local sources = {}
for _, c in pairs(config.get().sources) do
local s = core.sources_by_name[c.name]
if s then
if not statuses or vim.tbl_contains(statuses, s.status) then
if s:is_available() then
table.insert(sources, s)
for _, s in pairs(core.sources) do
if c.name == s.name then
if not statuses or vim.tbl_contains(statuses, s.status) then
if s:is_available() then
table.insert(sources, s)
end
end
end
end