Implement enabled=false configuration

This commit is contained in:
hrsh7th
2021-09-13 00:59:48 +09:00
parent 1cec1ecb31
commit a78894a09a
9 changed files with 69 additions and 48 deletions

View File

@@ -126,16 +126,25 @@ cmp.setup = setmetatable({
---Handle events
autocmd.subscribe('InsertEnter', function()
core.prepare()
core.on_change('InsertEnter')
-- Avoid unexpected mode detection (mode() function will returns `normal mode` on the InsertEnter event.)
vim.schedule(function()
if config.enabled() then
core.prepare()
core.on_change('InsertEnter')
end
end)
end)
autocmd.subscribe('TextChanged', function()
core.on_change('TextChanged')
if config.enabled() then
core.on_change('TextChanged')
end
end)
autocmd.subscribe('InsertLeave', function()
core.reset()
if config.enabled() then
core.reset()
end
end)
return cmp