add cmp.get_registered_sources and CmpRegisterSource /CmpUnregisterSource autocmd.
This commit is contained in:
@@ -54,13 +54,33 @@ end
|
||||
cmp.register_source = function(name, s)
|
||||
local src = source.new(name, s)
|
||||
cmp.core:register_source(src)
|
||||
vim.api.nvim_exec_autocmds('User', {
|
||||
pattern = 'CmpRegisterSource',
|
||||
data = {
|
||||
source_id = src.id
|
||||
}
|
||||
})
|
||||
return src.id
|
||||
end
|
||||
|
||||
---Unregister completion source
|
||||
---@param id integer
|
||||
cmp.unregister_source = function(id)
|
||||
cmp.core:unregister_source(id)
|
||||
local s = cmp.core:unregister_source(id)
|
||||
if s then
|
||||
vim.api.nvim_exec_autocmds('User', {
|
||||
pattern = 'CmpUnregisterSource',
|
||||
data = {
|
||||
source_id = id
|
||||
}
|
||||
})
|
||||
end
|
||||
end
|
||||
|
||||
---Get registered sources.
|
||||
---@return cmp.Source[]
|
||||
cmp.get_registered_sources = function()
|
||||
return cmp.core:get_registered_sources()
|
||||
end
|
||||
|
||||
---Get current configuration.
|
||||
|
||||
Reference in New Issue
Block a user