add cmp.get_registered_sources and CmpRegisterSource /CmpUnregisterSource autocmd.

This commit is contained in:
hrsh7th
2024-12-10 12:04:15 +09:00
parent ca4d3330d3
commit 1d57252744
3 changed files with 39 additions and 1 deletions

View File

@@ -47,8 +47,11 @@ end
---Unregister source
---@param source_id integer
---@return cmp.Source?
core.unregister_source = function(self, source_id)
local s = self.sources[source_id]
self.sources[source_id] = nil
return s
end
---Get new context
@@ -105,6 +108,12 @@ core.get_sources = function(self, filter)
return sources
end
---Return registered sources.
---@return cmp.Source[]
core.get_registered_sources = function(self)
return self.sources
end
---Keypress handler
core.on_keymap = function(self, keys, fallback)
local mode = api.get_mode()